Rudy::Global
This global class is used by all Huxtable objects. When a new CLI global is added, the appropriate field must be added to this class (optional: a default value in initialize).
Attributes
print_header | [RW] |
Public class methods
new
()
[show source]
# File lib/rudy/global.rb, line 50 50: def initialize 51: postprocess 52: # These attributes MUST have values. 53: @verbose ||= 0 54: @nocolor = true unless @nocolor == "false" || @nocolor == false 55: @quiet ||= false 56: @parallel ||= false 57: @force ||= false 58: @format ||= :string # as in, to_s 59: @print_header = true if @print_header == nil 60: end
Public instance methods
apply_config
(config)
[show source]
# File lib/rudy/global.rb, line 62 62: def apply_config(config) 63: 64: return unless config.is_a?(Rudy::Config) 65: clear_system_defaults # temporarily unapply default values 66: 67: if config.defaults? 68: # Apply the "color" default before "nocolor" so nocolor has presedence 69: @nocolor = !config.defaults.color unless config.defaults.color.nil? 70: # WARNING: Don't add user to this list. The global value should return 71: # the value specified on the command line or nil. If it is nil, we can 72: # check the value from the machines config. If that is nil, we use the 73: # value from the defaults config. 74: # WARNING: Don't add bucket either or any machines configuration param 75: # TODO: investigate removing this apply_config method 76: %w[region zone environment role position bucket 77: localhost nocolor quiet auto force parallel].each do |name| 78: curval, defval = self.send(name), config.defaults.send(name) 79: if curval.nil? && !defval.nil? 80: # Don't use the accessors. These are defaults so no Region magic. 81: self.instance_variable_set("@#{name}", defval) 82: end 83: end 84: end 85: 86: if config.accounts? && config.accounts.aws 87: %w[accesskey secretkey accountnum cert pkey].each do |name| 88: val = config.accounts.aws.send(name) 89: self.send("#{name}=", val) unless val.nil? 90: end 91: end 92: postprocess 93: end
region=
(r)
[show source]
# File lib/rudy/global.rb, line 106 106: def region=(r) 107: @region = r 108: @zone = "#{@region}b".to_sym 109: end
to_s
(*args)
[show source]
# File lib/rudy/global.rb, line 111 111: def to_s(*args) 112: super() 113: end
update
(ghash={})
[show source]
# File lib/rudy/global.rb, line 95 95: def update(ghash={}) 96: ghash = ghash.marshal_dump if ghash.is_a?(OpenStruct) 97: ghash.each_pair { |n,v| self.send("#{n}=", v) } 98: postprocess 99: end
zone=
(z)
[show source]
# File lib/rudy/global.rb, line 101 101: def zone=(z) 102: @zone = z 103: @region = @zone.to_s.gsub(/[a-z]$/, '').to_sym 104: end