Class: HttpKinesis::CredentialsFileReader

Inherits:
Object
  • Object
show all
Defined in:
lib/http-kinesis/credentials_file_reader.rb

Overview

Parses the credentials file and supplies the aws access key and aws secret for the specified section of the file.

Instance Method Summary collapse

Constructor Details

#initialize(config_file, section) ⇒ Object

Instantiate a HttpKinesis::CredentialsFileReader.

Parameters:

  • config_file (String)

    The name of the config file to parse.

  • section (String)

    The name of the section of the file to parse.


12
13
14
15
16
17
18
19
# File 'lib/http-kinesis/credentials_file_reader.rb', line 12

def initialize(config_file, section)
  @config = Hash.new( {} )
  @section = section
  file_name = config_file || "#{ENV['HOME']}/.aws/credentials"
  @lines = File.open(file_name).readlines
  @current_section = nil
  parse_config
end

Instance Method Details

#access_keyObject

Returns the AWS access key


22
23
24
# File 'lib/http-kinesis/credentials_file_reader.rb', line 22

def access_key
  @config[@section]['aws_access_key_id']
end

#secretObject

returns the AWS secret access key


27
28
29
# File 'lib/http-kinesis/credentials_file_reader.rb', line 27

def secret
  @config[@section]['aws_secret_access_key']
end