Extract prefix constant for koans
This commit is contained in:
@@ -39,6 +39,6 @@ defmodule Display do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp display_koan(name) do
|
defp display_koan(name) do
|
||||||
String.replace(to_string(name), "koan: ", "")
|
String.replace(to_string(name), Koans.prefix, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
defmodule Koans do
|
defmodule Koans do
|
||||||
|
@prefix "koan: "
|
||||||
|
|
||||||
defmacro koan(name, body) do
|
defmacro koan(name, body) do
|
||||||
compiled_name = :"koan: #{name}"
|
compiled_name = :"#{prefix}#{name}"
|
||||||
quote do
|
quote do
|
||||||
def unquote(compiled_name)() do
|
def unquote(compiled_name)() do
|
||||||
try do
|
try do
|
||||||
@@ -19,4 +21,8 @@ defmodule Koans do
|
|||||||
import ExUnit.Assertions
|
import ExUnit.Assertions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefix do
|
||||||
|
@prefix
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,6 +50,6 @@ defmodule Runner do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp koan?(fun_name) do
|
defp koan?(fun_name) do
|
||||||
String.starts_with?(to_string(fun_name), "koan: ")
|
String.starts_with?(to_string(fun_name), Koans.prefix)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user