Hook tracker into Execute module via hook
This commit is contained in:
@@ -1,12 +1,18 @@
|
|||||||
defmodule Execute do
|
defmodule Execute do
|
||||||
def run_module(module) do
|
def run_module(module, callback \\ fn(result, koan) -> nil end) do
|
||||||
Enum.reduce_while(module.all_koans, :passed, fn(koan, _) ->
|
Enum.reduce_while(module.all_koans, :passed, fn(koan, _) ->
|
||||||
module
|
module
|
||||||
|> run_koan(koan)
|
|> run_koan(koan)
|
||||||
|
|> hook(koan, callback)
|
||||||
|> continue?
|
|> continue?
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp hook(result,koan, callback) do
|
||||||
|
callback.(result, koan)
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
defp continue?(:passed), do: {:cont, :passed}
|
defp continue?(:passed), do: {:cont, :passed}
|
||||||
defp continue?(result), do: {:halt, result}
|
defp continue?(result), do: {:halt, result}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ defmodule Mix.Tasks.Meditate do
|
|||||||
Code.compiler_options(ignore_module_conflict: true)
|
Code.compiler_options(ignore_module_conflict: true)
|
||||||
Watcher.start
|
Watcher.start
|
||||||
|
|
||||||
|
Tracker.start(Runner.modules)
|
||||||
Options.start(args)
|
Options.start(args)
|
||||||
Runner.run
|
Runner.run
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ defmodule Runner do
|
|||||||
]
|
]
|
||||||
|
|
||||||
def koan?(koan), do: Enum.member?(@modules, koan)
|
def koan?(koan), do: Enum.member?(@modules, koan)
|
||||||
|
def modules, do: @modules
|
||||||
|
|
||||||
def run do
|
def run do
|
||||||
Options.initial_koan
|
Options.initial_koan
|
||||||
@@ -35,11 +36,14 @@ defmodule Runner do
|
|||||||
def run_module(module) do
|
def run_module(module) do
|
||||||
module
|
module
|
||||||
|> Display.considering
|
|> Display.considering
|
||||||
|> Execute.run_module
|
|> Execute.run_module(&track/2)
|
||||||
|> display
|
|> display
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp track(:passed, koan), do: Tracker.completed(koan)
|
||||||
|
defp track(_, _), do: nil
|
||||||
|
|
||||||
defp display({:failed, error, module, name}) do
|
defp display({:failed, error, module, name}) do
|
||||||
Display.show_failure(error, module, name)
|
Display.show_failure(error, module, name)
|
||||||
:failed
|
:failed
|
||||||
|
|||||||
Reference in New Issue
Block a user