class HP::Cloud::Mangler::Config

Attributes

config_hash[RW]
settings_path[RW]
target[RW]

Public Class Methods

new(options={}) click to toggle source
# File lib/hpcloudmangler/config.rb, line 7
def initialize(options={})
  @settings_path = File.expand_path(HP::Cloud::Mangler::DEFAULT_CONFIG_PATH)
  @target = options[:target] || HP::Cloud::Mangler::DEFAULT_TARGET
  @config_hash = HP::Cloud::Mangler::Settings.load! || {}
end

Public Instance Methods

tokens() click to toggle source
# File lib/hpcloudmangler/config.rb, line 13
def tokens
  config_hash["tokens"] || {}
end
update(attr, value) click to toggle source
# File lib/hpcloudmangler/config.rb, line 17
def update(attr, value)
  if attr == :tokens
    config_hash["tokens"] = tokens.merge({ target => value })
  else
    config_hash[attr.to_s] = value
  end

  File.open(settings_path, 'w') do |out|
    YAML.dump(config_hash, out)
  end
end

Private Instance Methods

load_settings() click to toggle source
# File lib/hpcloudmangler/config.rb, line 31
def load_settings
  File.exists?(settings_path) ? YAML.load_file(settings_path) : nil
end