Class: Aws::ASMR::Alias
- Inherits:
-
Struct
- Object
- Struct
- Aws::ASMR::Alias
- Defined in:
- lib/aws/asmr/alias.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
-
#arn ⇒ Object
Returns the value of attribute arn.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id
6 7 8 |
# File 'lib/aws/asmr/alias.rb', line 6 def access_key_id @access_key_id end |
#arn ⇒ Object
Returns the value of attribute arn
6 7 8 |
# File 'lib/aws/asmr/alias.rb', line 6 def arn @arn end |
#profile ⇒ Object
Returns the value of attribute profile
6 7 8 |
# File 'lib/aws/asmr/alias.rb', line 6 def profile @profile end |
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key
6 7 8 |
# File 'lib/aws/asmr/alias.rb', line 6 def secret_access_key @secret_access_key end |
Class Method Details
.base ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/aws/asmr/alias.rb', line 31 def base @base ||= begin if File.exist?(PATH) parse(File.readlines(PATH)) else {} end end end |
.first ⇒ Object
41 42 43 44 |
# File 'lib/aws/asmr/alias.rb', line 41 def first k,v = base.first get(k) end |
.get(alias_name) ⇒ Object
46 47 48 |
# File 'lib/aws/asmr/alias.rb', line 46 def get(alias_name) base[alias_name] && new(base[alias_name]) end |
.parse(lines) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/aws/asmr/alias.rb', line 11 def parse(lines) lines = lines.map(&:strip).select{! _1.start_with?('#')} arr = lines.reduce([]) do |acc,line| m = line.match(/\A\[([^\[\]]+)\]\z/) if m acc << [m[1], []] else alias_name, alias_props = acc.last if alias_name k, v = line.split('=').map(&:strip) if k and v alias_props << [k, v] end end end acc end arr.map{|k,v| [k,v.to_h]}.select{|k,v| v["arn"] and !v["arn"].empty?}.to_h end |
Instance Method Details
#set_environment_variables! ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/aws/asmr/alias.rb', line 51 def set_environment_variables! if access_key_id and !access_key_id.empty? ENV["AWS_ACCESS_KEY_ID"] = access_key_id ENV["AWS_SECRET_ACCESS_KEY"] = secret_access_key elsif profile and !profile.empty? ENV["AWS_PROFILE"] = profile end end |