Module: RakeCommander::Options::Result::ClassMethods
- Defined in:
- lib/rake-commander/options/result.rb
Instance Method Summary collapse
-
#install_task(&task_method) ⇒ Object
Extend method to ensure options are parsed before calling task.
-
#options_with_defaults(value = nil) ⇒ Boolean
Configuration Setting.
-
#parse_options(argv = ARGV, results: {}, leftovers: []) {|value, default, short, name, option| ... } ⇒ Object
It re-opens the method and adds a middleware to gather and return the results of the parsing (including the
leftovers
).
Instance Method Details
#install_task(&task_method) ⇒ Object
TODO:
think if it should rather raise an ArgumentError
when the task
was not defined in an instance object of his class.
Note:
- This allows stop before invoking the task, may there be options
that have this effect (i.e.
-h
) - We use
task_context
to open up extensibility.
Extend method to ensure options are parsed before calling task.
This only happens if task_method
has it's context (binding) with
an instance object of this class.
49 50 51 |
# File 'lib/rake-commander/options/result.rb', line 49 def install_task(&task_method) super(&task_context(&task_method)) end |
#options_with_defaults(value = nil) ⇒ Boolean
Configuration Setting.
16 17 18 19 20 21 22 |
# File 'lib/rake-commander/options/result.rb', line 16 def (value = nil) if value.nil? @options_with_defaults || false else @options_with_defaults = !!value end end |
#parse_options(argv = ARGV, results: {}, leftovers: []) {|value, default, short, name, option| ... } ⇒ Object
Note:
this extends the method parameters and changes the returned value.
It re-opens the method and adds a middleware to gather and return
the results of the parsing (including the leftovers
)
36 37 38 |
# File 'lib/rake-commander/options/result.rb', line 36 def (argv = ARGV, results: {}, leftovers: [], &middleware) leftovers.push(*super(argv, &results_collector(results, &middleware))) end |