Module: Crabfarm::Support::GLI
- Defined in:
- lib/crabfarm/support/gli.rb
Class Method Summary collapse
- .generate_options(_cmd) ⇒ Object
- .parse_options(_options) ⇒ Object
- .require_all ⇒ Object
- .setup_autoload ⇒ Object
Class Method Details
.generate_options(_cmd) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/crabfarm/support/gli.rb', line 4 def self.(_cmd) Configuration::OPTIONS.each do |opt| if opt.type != :mixed _cmd.desc opt.text _cmd.flag "cf-#{opt.name}" end end end |
.parse_options(_options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/crabfarm/support/gli.rb', line 22 def self.() config_overrides = {} Configuration::OPTIONS.each do |opt| value = ["cf-#{opt.name}"] next if value.nil? value = if opt.type.is_a? Array opt.type.find { |t| t.to_s == value } elsif opt.type == :integer then value.to_i elsif opt.type == :float then value.to_f elsif opt.type == :boolean then [true, false].find { |t| t.to_s == value } elsif opt.type == :string then value else nil end next if value.nil? config_overrides[opt.name] = value end config_overrides end |
.require_all ⇒ Object
18 19 20 |
# File 'lib/crabfarm/support/gli.rb', line 18 def self.require_all Dir.glob(File.join(CF_PATH, 'app', '**/*.rb')).each { |p| require p } end |
.setup_autoload ⇒ Object
13 14 15 16 |
# File 'lib/crabfarm/support/gli.rb', line 13 def self.setup_autoload require 'active_support/dependencies' ActiveSupport::Dependencies.autoload_paths += Dir.glob File.join(CF_PATH, 'app', '**') end |