Module: Awsam::Accounts
- Defined in:
- lib/awsam/accounts.rb
Constant Summary collapse
- @@accounts =
{}
Class Method Summary collapse
- .active ⇒ Object
- .find(name) ⇒ Object
- .get ⇒ Object
- .get_default ⇒ Object
- .load! ⇒ Object
- .remove_default ⇒ Object
- .set_default(name) ⇒ Object
Class Method Details
.active ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/awsam/accounts.rb', line 22 def self.active active = ENV['AWSAM_ACTIVE_ACCOUNT'] return nil unless active acct = find(active) unless acct puts "No account named '#{active}' found." return nil end acct end |
.find(name) ⇒ Object
39 40 41 |
# File 'lib/awsam/accounts.rb', line 39 def self.find(name) @@accounts[name] end |
.get ⇒ Object
35 36 37 |
# File 'lib/awsam/accounts.rb', line 35 def self.get return @@accounts end |
.get_default ⇒ Object
52 53 54 55 |
# File 'lib/awsam/accounts.rb', line 52 def self.get_default dflt = Utils::get_default(Awsam::get_accts_dir) dflt ? find(dflt) : nil end |
.load! ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/awsam/accounts.rb', line 11 def self.load! accts = Hash.new accts_dir = Awsam::get_accts_dir Utils::confdir_scan(accts_dir) do |name| acct = Account::load_from_disk(File.join(accts_dir, name)) accts[name] = acct if acct end @@accounts = accts end |
.remove_default ⇒ Object
57 58 59 |
# File 'lib/awsam/accounts.rb', line 57 def self.remove_default Utils::remove_default(Awsam::get_accts_dir) end |
.set_default(name) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/awsam/accounts.rb', line 43 def self.set_default(name) unless find(name) $stderr.puts "Failed to find account #{name}" return false end Utils::set_default(Awsam::get_accts_dir, name) end |