Class: LxcForge::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/lxc_forge/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Config

Returns a new instance of Config.



7
8
9
# File 'lib/lxc_forge/config.rb', line 7

def initialize(options)
  @options = options
end

Instance Attribute Details

#access_key_idObject

Returns the value of attribute access_key_id.



5
6
7
# File 'lib/lxc_forge/config.rb', line 5

def access_key_id
  @access_key_id
end

#bucketObject

Returns the value of attribute bucket.



5
6
7
# File 'lib/lxc_forge/config.rb', line 5

def bucket
  @bucket
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/lxc_forge/config.rb', line 5

def options
  @options
end

#regionObject

Returns the value of attribute region.



5
6
7
# File 'lib/lxc_forge/config.rb', line 5

def region
  @region
end

#secret_access_keyObject

Returns the value of attribute secret_access_key.



5
6
7
# File 'lib/lxc_forge/config.rb', line 5

def secret_access_key
  @secret_access_key
end

Instance Method Details

#config_fileObject



11
12
13
# File 'lib/lxc_forge/config.rb', line 11

def config_file
  File.join(ENV["HOME"], ".lxc_forge.yml")
end

#loadObject



15
16
17
# File 'lib/lxc_forge/config.rb', line 15

def load
  load_file(config_file)
end

#load_file(filename) ⇒ Object

TODO: Break up



36
37
38
39
40
41
42
# File 'lib/lxc_forge/config.rb', line 36

def load_file(filename)
  data = File.read(filename)
  c = YAML.load(data)
  c.each do |k, v|
    send("#{k}=", v)
  end
end

#saveObject

TODO: Break up



29
30
31
32
33
# File 'lib/lxc_forge/config.rb', line 29

def save
  File.open(config_file, 'w') do |f|
    f.write(to_hash.to_yaml)
  end
end

#to_hashObject



19
20
21
22
23
24
25
26
# File 'lib/lxc_forge/config.rb', line 19

def to_hash
  {
    :access_key_id => access_key_id,
    :secret_access_key => secret_access_key,
    :region => region,
    :bucket => bucket
  }
end