Merge pull request #158 from iamvery/elixir-1-4-warnings

Fix Elixir 1 4 warnings
This commit is contained in:
Felipe Seré
2017-01-21 14:28:30 +00:00
committed by GitHub
5 changed files with 25 additions and 25 deletions

View File

@@ -2,7 +2,7 @@ defmodule Display.Paint do
def red(str), do: painter().red(str) def red(str), do: painter().red(str)
def cyan(str), do: painter().cyan(str) def cyan(str), do: painter().cyan(str)
def green(str), do: painter().green(str) def green(str), do: painter().green(str)
def yellow(str), do: painter.yellow(str) def yellow(str), do: painter().yellow(str)
defp painter do defp painter do
case Mix.env do case Mix.env do

View File

@@ -4,17 +4,17 @@ defmodule Processes do
@intro "Processes" @intro "Processes"
koan "You are a process" do koan "You are a process" do
assert Process.alive?(self) == ___ assert Process.alive?(self()) == ___
end end
koan "You can ask a process to introduce itself" do koan "You can ask a process to introduce itself" do
information = Process.info(self) information = Process.info(self())
assert information[:status] == ___ assert information[:status] == ___
end end
koan "Processes are referenced by their process ID (pid)" do koan "Processes are referenced by their process ID (pid)" do
assert is_pid(self) == ___ assert is_pid(self()) == ___
end end
koan "New processes are spawned functions" do koan "New processes are spawned functions" do
@@ -24,7 +24,7 @@ defmodule Processes do
end end
koan "Processes can send and receive messages" do koan "Processes can send and receive messages" do
send self, "hola!" send self(), "hola!"
receive do receive do
msg -> assert msg == ___ msg -> assert msg == ___
@@ -32,8 +32,8 @@ defmodule Processes do
end end
koan "Received messages are queued, first in first out" do koan "Received messages are queued, first in first out" do
send self, "hola!" send self(), "hola!"
send self, "como se llama?" send self(), "como se llama?"
assert_receive ___ assert_receive ___
assert_receive ___ assert_receive ___
@@ -48,7 +48,7 @@ defmodule Processes do
pid = spawn(greeter) pid = spawn(greeter)
send pid, {:hello, self} send pid, {:hello, self()}
assert_receive ___ assert_receive ___
end end
@@ -56,17 +56,17 @@ defmodule Processes do
receive do receive do
{caller, value} -> {caller, value} ->
send caller, String.upcase(value) send caller, String.upcase(value)
yelling_echo_loop yelling_echo_loop()
end end
end end
koan "Use tail recursion to receive multiple messages" do koan "Use tail recursion to receive multiple messages" do
pid = spawn_link(&yelling_echo_loop/0) pid = spawn_link(&yelling_echo_loop/0)
send pid, {self, "o"} send pid, {self(), "o"}
assert_receive ___ assert_receive ___
send pid, {self, "hai"} send pid, {self(), "hai"}
assert_receive ___ assert_receive ___
end end
@@ -86,16 +86,16 @@ defmodule Processes do
state(initial_state) state(initial_state)
end) end)
send pid, {self, :get} send pid, {self(), :get}
assert_receive ___ assert_receive ___
send pid, {self, :set, "bar"} send pid, {self(), :set, "bar"}
send pid, {self, :get} send pid, {self(), :get}
assert_receive ___ assert_receive ___
end end
koan "Waiting for a message can get boring" do koan "Waiting for a message can get boring" do
parent = self parent = self()
spawn(fn -> receive do spawn(fn -> receive do
after after
5 -> send parent, {:waited_too_long, "I am impatient"} 5 -> send parent, {:waited_too_long, "I am impatient"}
@@ -106,7 +106,7 @@ defmodule Processes do
end end
koan "Trapping will allow you to react to someone terminating the process" do koan "Trapping will allow you to react to someone terminating the process" do
parent = self parent = self()
pid = spawn(fn -> pid = spawn(fn ->
Process.flag(:trap_exit, true) Process.flag(:trap_exit, true)
send parent, :ready send parent, :ready
@@ -126,13 +126,13 @@ defmodule Processes do
koan "Parent processes can trap exits for children they are linked to" do koan "Parent processes can trap exits for children they are linked to" do
Process.flag(:trap_exit, true) Process.flag(:trap_exit, true)
spawn_link(fn -> Process.exit(self, :normal) end) spawn_link(fn -> Process.exit(self(), :normal) end)
assert_receive {:EXIT, _pid, ___} assert_receive {:EXIT, _pid, ___}
end end
koan "If you monitor your children, you'll be automatically informed for their depature" do koan "If you monitor your children, you'll be automatically informed for their depature" do
spawn_monitor(fn -> Process.exit(self, :normal) end) spawn_monitor(fn -> Process.exit(self(), :normal) end)
assert_receive {:DOWN, _ref, :process, _pid, ___} assert_receive {:DOWN, _ref, :process, _pid, ___}
end end

View File

@@ -20,15 +20,15 @@ defmodule Tracker do
end end
def visited do def visited do
summarize[:visited_modules] summarize()[:visited_modules]
end end
def complete? do def complete? do
%{total: total, current: completed} = summarize %{total: total, current: completed} = summarize()
total == completed total == completed
end end
def summarize, do: get |> summarize def summarize, do: get() |> summarize()
defp summarize(%{total: total, defp summarize(%{total: total,
koans: completed, koans: completed,
visited_modules: modules}) do visited_modules: modules}) do

View File

@@ -6,7 +6,7 @@ defmodule Koans.Mixfile do
version: "0.0.1", version: "0.0.1",
elixir: ">= 1.2.1 and <= 1.4.0", elixir: ">= 1.2.1 and <= 1.4.0",
elixirc_paths: elixirc_path(Mix.env), elixirc_paths: elixirc_path(Mix.env),
deps: deps] deps: deps()]
end end
def application do def application do
@@ -14,7 +14,7 @@ defmodule Koans.Mixfile do
end end
defp deps do defp deps do
[{:exfswatch, "~> 0.1.1"}] [{:exfswatch, "~> 0.3"}]
end end
defp elixirc_path(:test), do: ["lib/", "test/support"] defp elixirc_path(:test), do: ["lib/", "test/support"]

View File

@@ -1,2 +1,2 @@
%{"exfswatch": {:hex, :exfswatch, "0.1.1", "7ccf6fc9b443d04dada3e50b21f910b4d0e4546ce7772dc6d4181fb929ea186f", [:mix], [{:fs, "~> 0.9", [hex: :fs, optional: false]}]}, %{"exfswatch": {:hex, :exfswatch, "0.3.0", "4b07f871460c931e66a4a6af00510dfab9a9c8db3e519f21152a88bec4797a46", [:mix], [{:fs, "~> 2.12", [hex: :fs, optional: false]}]},
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []}} "fs": {:hex, :fs, "2.12.0", "ad631efacc9a5683c8eaa1b274e24fa64a1b8eb30747e9595b93bec7e492e25e", [:rebar3], []}}