Packages

Generate ExUnit unit test skeleton modules for an application.

Current section

Files

Jump to
ex_unit_jumpstart lib ex_unit_jumpstart get_code_files.ex
Raw

lib/ex_unit_jumpstart/get_code_files.ex

defmodule ExUnitJumpstart.GetCodeFiles do
@moduledoc """
Get a list of code files and their modules.
"""
def get_code_files(config) do
Path.wildcard("#{config[:code_dir]}/**/*.ex")
|> Enum.map(fn path ->
%ExUnitJumpstart.CodeFile{
path: path |> String.replace(config[:code_dir] <> "/", ""),
modules: modules(path)
}
end)
end
defp modules(path) do
Code.compile_file(path)
|> Enum.map(fn {module, _binary} -> module end)
end
end