Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85830711
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/captcha.ex b/lib/captcha.ex
index caed0ca..8863df6 100644
--- a/lib/captcha.ex
+++ b/lib/captcha.ex
@@ -1,19 +1,8 @@
defmodule Captcha do
- # allow customize receive timeout, default: 10_000
- def get(timeout \\ 1_000) do
- pid = Port.open({:spawn, Path.join(:code.priv_dir(:captcha), "captcha")}, [:binary])
-
- # Allow set receive timeout
- receive do
- {^pid, {:data, data}} ->
- <<text::bytes-size(5), img::binary>> = data
- {:ok, text, img}
-
- other ->
- other
- after
- timeout ->
- {:error, :timeout}
+ def get() do
+ case System.cmd(Application.app_dir(:captcha, "priv/captcha"), []) do
+ {<<text::bytes-size(5), img::binary>>, 0} -> {:ok, text, img}
+ _other -> :error
end
end
end
diff --git a/test/elixir_captcha_test.exs b/test/elixir_captcha_test.exs
index ddf2620..9977049 100644
--- a/test/elixir_captcha_test.exs
+++ b/test/elixir_captcha_test.exs
@@ -1,12 +1,8 @@
defmodule CaptchaTest do
use ExUnit.Case
doctest Captcha
test "successfully generates an image" do
assert {:ok, _, _} = Captcha.get()
end
-
- test "respects the timeout" do
- assert {:error, :timeout} = Captcha.get(0)
- end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Nov 1, 6:16 AM (16 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1802644
Default Alt Text
(1 KB)
Attached To
Mode
R13 elixir-captcha
Attached
Detach File
Event Timeline