Add support for multi-underscore command modules.
This commit is contained in:
parent
a5a54f1f85
commit
de9463b859
|
|
@ -29,8 +29,7 @@ defmodule CommandModules do
|
|||
file_name
|
||||
|> Path.basename
|
||||
|> Path.rootname(".ex")
|
||||
|> String.split("_")
|
||||
|> List.first
|
||||
|> String.replace_suffix("_command", "")
|
||||
end
|
||||
|
||||
# Takes a name (e.g., "status_command") and returns a {atom, string}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ defmodule CommandModulesTest do
|
|||
|
||||
filenames = [
|
||||
"#{source_dir}/imperial_command.ex",
|
||||
"#{source_dir}/lord_protectoral_command.ex",
|
||||
"#{source_dir}/polite_suggestion.ex",
|
||||
"#{source_dir}/royalcommand.ex",
|
||||
"#{source_dir}/ducal-command.ex",
|
||||
|
|
@ -40,6 +41,11 @@ defmodule CommandModulesTest do
|
|||
assert CommandModules.generate_module_map[:imperial] == "ImperialCommand"
|
||||
end
|
||||
|
||||
test "command with multiple underscores shows up in map" do
|
||||
assert CommandModules.generate_module_map[:lord_protectoral] ==
|
||||
"LordProtectoralCommand"
|
||||
end
|
||||
|
||||
test "command_modules does not have non-existent commands" do
|
||||
assert CommandModules.generate_module_map[:usurper] == nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue