Class: Cloud::Sh::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
# File 'lib/cloud/sh/config.rb', line 8

def initialize
  @accounts = []
  read_config
end

Instance Attribute Details

#accountsObject (readonly)

Returns the value of attribute accounts.



6
7
8
# File 'lib/cloud/sh/config.rb', line 6

def accounts
  @accounts
end

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/cloud/sh/config.rb', line 6

def raw
  @raw
end

Instance Method Details

#aliases_fileObject



29
30
31
# File 'lib/cloud/sh/config.rb', line 29

def aliases_file
  File.expand_path(".cloud_sh_aliases", "~/")
end

#config_fileObject



25
26
27
# File 'lib/cloud/sh/config.rb', line 25

def config_file
  File.expand_path(".config/cloud-sh.yml", "~")
end

#load_accountsObject



19
20
21
22
23
# File 'lib/cloud/sh/config.rb', line 19

def load_accounts
  raw["accounts"].each do ||
    accounts << .new()
  end
end

#read_configObject



13
14
15
16
17
# File 'lib/cloud/sh/config.rb', line 13

def read_config
  return unless File.exist?(config_file)
  @raw = YAML.safe_load(File.read(config_file))
  load_accounts
end