Class: AwsKeychain::Keychain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Keychain

Initializes a new keychain from the specified keychain file



35
36
37
38
39
40
41
42
43
# File 'lib/keychain.rb', line 35

def initialize(options={})
  unless options.has_key?(:keychain_file) || options.has_key?(:keychain_data)
    raise ArgumentError, 'Either a keychain_file or keychain_data is required to create a new keychain class'
  end

  @keychain = options[:keychain_data] || JSON.parse(IO.read(options[:keychain_file]))

  # TODO: Validate that the hash is correct.
end

Instance Attribute Details

#keychainObject

Returns the value of attribute keychain.



27
28
29
# File 'lib/keychain.rb', line 27

def keychain
  @keychain
end

Instance Method Details

#[](key) ⇒ Hash

Array operator override to access keys by their name



56
57
58
# File 'lib/keychain.rb', line 56

def [](key)
  @keychain[key]
end

#listArray

Lists the names of all keys in the keychain



48
49
50
# File 'lib/keychain.rb', line 48

def list
  @keychain.keys
end