Module: Rodish

Defined in:
lib/rodish.rb,
lib/rodish/dsl.rb,
lib/rodish/errors.rb,
lib/rodish/command.rb,
lib/rodish/plugins.rb,
lib/rodish/processor.rb,
lib/rodish/plugins/is.rb,
lib/rodish/option_parser.rb,
lib/rodish/plugins/_wrap.rb,
lib/rodish/plugins/run_is.rb,
lib/rodish/plugins/usages.rb,
lib/rodish/plugins/help_order.rb,
lib/rodish/plugins/help_examples.rb,
lib/rodish/plugins/post_commands.rb,
lib/rodish/plugins/cache_help_output.rb,
lib/rodish/plugins/after_options_hook.rb,
lib/rodish/plugins/help_option_values.rb,
lib/rodish/plugins/skip_option_parsing.rb,
lib/rodish/plugins/invalid_args_message.rb,
lib/rodish/plugins/_context_sensitive_help.rb,
lib/rodish/plugins/wrapped_options_separator.rb

Defined Under Namespace

Modules: Plugins, Processor Classes: Command, CommandExit, CommandFailure, DSL, OptionParser, ProgramBug

Class Method Summary collapse

Class Method Details

.processor(klass, &block) ⇒ Object

Install a Rodish processor in the given class. This extends the class with Rodish::Processor, and uses the block to configure the processor using Rodish::DSL.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rodish.rb', line 10

def self.processor(klass, &block)
  klass.extend(Processor)

  dsl_class = Class.new(DSL)
  klass.const_set(:DSL, dsl_class)

  command_class = Class.new(Command)
  dsl_class.const_set(:Command, command_class)

  option_parser_class = Class.new(OptionParser)
  dsl_class.const_set(:OptionParser, option_parser_class)

  option_parser = option_parser_class.new
  option_parser.set_banner("")
  option_parser.freeze
  command_class.const_set(:DEFAULT_OPTION_PARSER, option_parser)

  klass.instance_variable_set(:@command, dsl_class.command([].freeze, &block))
  klass
end