Collect all intro printing into display
This commit is contained in:
@@ -20,9 +20,15 @@ defmodule Display do
|
|||||||
defp name("Elixir." <> module), do: module
|
defp name("Elixir." <> module), do: module
|
||||||
defp name(module), do: name(Atom.to_string(module))
|
defp name(module), do: name(Atom.to_string(module))
|
||||||
|
|
||||||
def intro(module) do
|
def show_failure(failure, module, name) do
|
||||||
show_intro(module.intro)
|
intro(module, Tracker.visited)
|
||||||
module
|
IO.puts(format(failure, module, name))
|
||||||
|
end
|
||||||
|
|
||||||
|
defp intro(module, modules) do
|
||||||
|
if ! module in modules do
|
||||||
|
show_intro(module.intro)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp show_intro(""), do: nil
|
defp show_intro(""), do: nil
|
||||||
@@ -32,9 +38,6 @@ defmodule Display do
|
|||||||
|> IO.puts
|
|> IO.puts
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_failure(failure, module, name) do
|
|
||||||
IO.puts(format(failure, module, name))
|
|
||||||
end
|
|
||||||
|
|
||||||
def format(failure, module, name) do
|
def format(failure, module, name) do
|
||||||
"""
|
"""
|
||||||
|
@@ -40,15 +40,9 @@ defmodule Runner do
|
|||||||
defp track(_, _, _), do: nil
|
defp track(_, _, _), do: nil
|
||||||
|
|
||||||
defp display({:failed, error, module, name}) do
|
defp display({:failed, error, module, name}) do
|
||||||
intro(module, Tracker.summarize)
|
|
||||||
Display.show_failure(error, module, name)
|
Display.show_failure(error, module, name)
|
||||||
:failed
|
:failed
|
||||||
end
|
end
|
||||||
defp display(_), do: :passed
|
defp display(_), do: :passed
|
||||||
|
|
||||||
defp intro(module, %{visited_modules: modules}) do
|
|
||||||
if ! module in modules do
|
|
||||||
Display.intro(module)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@@ -19,6 +19,10 @@ defmodule Tracker do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visited do
|
||||||
|
summarize[:visited_modules]
|
||||||
|
end
|
||||||
|
|
||||||
def complete? do
|
def complete? do
|
||||||
%{total: total, current: completed} = summarize
|
%{total: total, current: completed} = summarize
|
||||||
total == completed
|
total == completed
|
||||||
|
Reference in New Issue
Block a user