Class: ArticleFixtureGen::Exe::Trollop::OptionsWithDefaults

Inherits:
Object
  • Object
show all
Defined in:
lib/article_fixture_gen/exe/option_parser/trollop/options_with_defaults.rb

Overview

Builds an encapsulation of Trollop option menu and default values.

Class Method Summary collapse

Class Method Details

.call(all_specs) ⇒ Object

Reek says this method has :reek:TooManyStatements. Such is a DSL.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/article_fixture_gen/exe/option_parser/trollop/options_with_defaults.rb', line 23

def self.call(all_specs)
  defaults = {}
  options = ::Trollop.options do
    version VERSION_BANNER
    banner USAGE_BANNER
    all_specs.map { |spec| spec.add_option self }
    # Reminder: `all_specs` is our data. `Trollop.specs` is valid only
    #           inside the `.options` block
    specs.each { |attrib, spec| defaults[attrib] = spec[:default] }
  end
  Result.new defaults: defaults, options: options
end