Class: Mycommands::Application
- Inherits:
-
Object
- Object
- Mycommands::Application
- Defined in:
- lib/mycommands/application.rb
Constant Summary collapse
- OPTIONS =
[ {short: 'v', verbose: 'version', route: [:Application, :print_version], input: false, description: 'Prints the version'}, {short: 's', verbose: 'sort', route: [:Application, :sort_yaml_files], input: false, description: 'Sorts categories.yml and commands.yml alphabetically'}, {short: 'c', verbose: 'copy', route: [:Application, :copy_yaml_files], input: false, description: 'Copies categories.yml and commands.yml to ~/Mycommands/ so that they overrides the default ones'}, {short: 'h', verbose: 'help', route: [:Application, :help], input: false, description: 'Shows this help'} ]
Instance Method Summary collapse
- #dispatch(args) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
10 11 12 |
# File 'lib/mycommands/application.rb', line 10 def initialize @router = Factory::get(:Router) end |
Instance Method Details
#dispatch(args) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/mycommands/application.rb', line 20 def dispatch args controller, action, input= args.map &:to_s puts "Dispatching: #{controller}, #{action}, #{input}" if DEBUG if input.nil? Factory::get(controller+'Controller').send action else Factory::get(controller+'Controller').send action, input end end |
#run ⇒ Object
14 15 16 17 18 |
# File 'lib/mycommands/application.rb', line 14 def run route, input = dispatch route get_input if input end |