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