Class: Paratrooper::LocalApiKeyExtractor

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

Defined Under Namespace

Classes: NetrcFileDoesNotExist

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ LocalApiKeyExtractor

Returns a new instance of LocalApiKeyExtractor.



13
14
15
16
# File 'lib/paratrooper/local_api_key_extractor.rb', line 13

def initialize(options = {})
  @netrc_klass = options[:netrc_klass] || Netrc
  @file_path   = options[:file_path] || netrc_klass.default_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



7
8
9
# File 'lib/paratrooper/local_api_key_extractor.rb', line 7

def file_path
  @file_path
end

#netrc_klassObject (readonly)

Returns the value of attribute netrc_klass.



7
8
9
# File 'lib/paratrooper/local_api_key_extractor.rb', line 7

def netrc_klass
  @netrc_klass
end

Class Method Details

.get_credentialsObject



9
10
11
# File 'lib/paratrooper/local_api_key_extractor.rb', line 9

def self.get_credentials
  new.read_credentials
end

Instance Method Details

#read_credentialsObject



18
19
20
# File 'lib/paratrooper/local_api_key_extractor.rb', line 18

def read_credentials
  ENV['HEROKU_API_KEY'] || read_credentials_for('api.heroku.com')
end