Class: Gotsha::ActionDispatcher
- Inherits:
-
Object
- Object
- Gotsha::ActionDispatcher
- Defined in:
- lib/gotsha/action_dispatcher.rb
Constant Summary collapse
- SKIP_CONFIG_VERIFICATION_FOR =
%w[init configure uninstall help -h --help].freeze
- DEFAULT_ACTION =
"help"- HELP_ACTION_SHORTCUT =
"-h"- VERSION_ACTION_SHORTCUT =
"-v"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(action_name = DEFAULT_ACTION, *args) ⇒ Object
10 11 12 13 14 |
# File 'lib/gotsha/action_dispatcher.rb', line 10 def self.call(action_name = DEFAULT_ACTION, *args) action_name ||= DEFAULT_ACTION new.call(action_name, *args) end |
Instance Method Details
#call(action_name, *args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gotsha/action_dispatcher.rb', line 16 def call(action_name, *args) @action_name = action_name return Actions::Help.new.call(action_name) if args == [HELP_ACTION_SHORTCUT] return Actions::Help.new.call(action_name) if args == ["--help"] verify_configuration! action_class.new.call(*args) rescue ArgumentError raise Errors::HardFail, "too many arguments" end |