Update Console.ex port calls
Updates the port calls to work properly.
Closes issue
#
defmodule Console do
+ @compile {:no_warn_undefined, [AVMPort]}
+
def puts(device \\ :stdio, item) do
pid =
case :erlang.whereis(device) do
:undefined ->
case device do
:stdio ->
- new_pid = :erlang.open_port({:spawn, "console"}, [])
+ new_pid = AVMPort.open({:spawn, "console"}, [])
:erlang.register(:stdio, new_pid)
new_pid
@@ -40,12 +42,6 @@ defmodule Console do
write(pid, item)
end
- defp write(console, string) do
- send(console, {self(), string})
-
- receive do
- return_status ->
- return_status
- end
- end
+ defp write(console, string),
+ do: AVMPort.call(console, {:puts, string})
end
