Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F113213
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
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 24, 6:30 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38403
Default Alt Text
(1 KB)
Attached To
Mode
R13 elixir-captcha
Attached
Detach File
Event Timeline
Log In to Comment