Parent

Class/Module Index [+]

Quicksearch

Rudy::Global

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

Public Class Methods

new() click to toggle source
# File lib/rudy/global.rb, line 50
def initialize
  postprocess
  # These attributes MUST have values. 
  @verbose ||= 0
  @nocolor = true unless @nocolor == "false" || @nocolor == false
  @quiet ||= false
  @parallel ||= false
  @force ||= false
  @format ||= :string # as in, to_s
  @print_header = true if @print_header == nil
end

Public Instance Methods

apply_config(config) click to toggle source
# File lib/rudy/global.rb, line 62
def apply_config(config)

  return unless config.is_a?(Rudy::Config)
  clear_system_defaults  # temporarily unapply default values
  
  if config.defaults?
    # Apply the "color" default before "nocolor" so nocolor has presedence
    @nocolor = !config.defaults.color unless config.defaults.color.nil?
    # WARNING: Don't add user to this list. The global value should return
    # the value specified on the command line or nil. If it is nil, we can
    # check the value from the machines config. If that is nil, we use the
    # value from the defaults config. 
    # WARNING: Don't add bucket either or any machines configuration param 
    # TODO: investigate removing this apply_config method
    ]region zone environment role position bucket
       localhost nocolor quiet auto force parallel].each do |name|
      curval, defval = self.send(name), config.defaults.send(name)
      if curval.nil? && !defval.nil?
        # Don't use the accessors. These are defaults so no Region  magic. 
        self.instance_variable_set("@#{name}", defval) 
      end
    end
  end
  
  if config.accounts? && config.accounts.aws
    ]accesskey secretkey accountnum cert pkey].each do |name|
      val = config.accounts.aws.send(name)
      self.send("#{name}=", val) unless val.nil?
    end
  end
  postprocess
end
region=(r) click to toggle source
# File lib/rudy/global.rb, line 106
def region=(r)
  @region = r
  @zone = "#{@region}b".to_sym
end
to_s(*args) click to toggle source
# File lib/rudy/global.rb, line 111
def to_s(*args)
  super()
end
update(ghash={}) click to toggle source
# File lib/rudy/global.rb, line 95
def update(ghash={})
  ghash = ghash.marshal_dump if ghash.is_a?(OpenStruct) 
  ghash.each_pair { |n,v| self.send("#{n}=", v) } 
  postprocess
end
zone=(z) click to toggle source
# File lib/rudy/global.rb, line 101
def zone=(z)
  @zone = z
  @region = @zone.to_s.gsub(/[a-z]$/, '').to_sym
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.