Class: Cloud::Sh::Config
- Inherits:
-
Object
- Object
- Cloud::Sh::Config
- Defined in:
- lib/cloud/sh/config.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #aliases_file ⇒ Object
- #config_file ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_accounts ⇒ Object
- #read_config ⇒ Object
Constructor Details
#initialize ⇒ Config
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
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
6 7 8 |
# File 'lib/cloud/sh/config.rb', line 6 def accounts @accounts end |
#raw ⇒ Object (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_file ⇒ Object
29 30 31 |
# File 'lib/cloud/sh/config.rb', line 29 def aliases_file File.(".cloud_sh_aliases", "~/") end |
#config_file ⇒ Object
25 26 27 |
# File 'lib/cloud/sh/config.rb', line 25 def config_file File.(".config/cloud-sh.yml", "~") end |
#load_accounts ⇒ Object
19 20 21 22 23 |
# File 'lib/cloud/sh/config.rb', line 19 def load_accounts raw["accounts"].each do |account_config| accounts << Account.new(account_config) end end |
#read_config ⇒ Object
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 |