Congratulate when koans are complete
This commit is contained in:
@@ -16,6 +16,8 @@ defmodule Mix.Tasks.Meditate do
|
|||||||
|> Tracker.start
|
|> Tracker.start
|
||||||
|> Runner.run
|
|> Runner.run
|
||||||
|
|
||||||
|
if Tracker.complete?, do: Display.congratulate
|
||||||
|
|
||||||
receive do
|
receive do
|
||||||
{:DOWN, _references, :process, watcher, _reason} -> nil
|
{:DOWN, _references, :process, watcher, _reason} -> nil
|
||||||
end
|
end
|
||||||
|
@@ -19,6 +19,11 @@ defmodule Tracker do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def complete? do
|
||||||
|
{total, completed} = Agent.get(__MODULE__, &(&1))
|
||||||
|
total == Enum.count(completed)
|
||||||
|
end
|
||||||
|
|
||||||
def summarize({total, completed}) do
|
def summarize({total, completed}) do
|
||||||
%{total: total, current: MapSet.size(completed)}
|
%{total: total, current: MapSet.size(completed)}
|
||||||
end
|
end
|
||||||
|
@@ -12,6 +12,8 @@ defmodule Watcher do
|
|||||||
rescue
|
rescue
|
||||||
e -> Display.show_compile_error(e)
|
e -> Display.show_compile_error(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Tracker.complete?, do: Display.congratulate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user