class AwsKeychain::Keychain

Attributes

keychain[RW]

Public Class Methods

new(options={}) click to toggle source

Initializes a new keychain from the specified keychain file

@param [Hash] options A hash of options for the class where the keys are one of

:keychain_file relative or absolute path to a json file containing the keychain data
:keychain_data a hash containing the keychain data where keys are the name of the credential
  and values are a hash with any keys ("key" and "secret" are required keys)
# 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

Public Instance Methods

[](key) click to toggle source

Array operator override to access keys by their name

@param [String] key The string name of the key to return @return [Hash] The desired hash

# File lib/keychain.rb, line 56
def [](key)
  @keychain[key]
end
list() click to toggle source

Lists the names of all keys in the keychain

@return [Array] The names of all keys in the keychain

# File lib/keychain.rb, line 48
def list
  @keychain.keys
end