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.



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

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.



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

def file_path
  @file_path
end

#netrc_klassObject (readonly)

Returns the value of attribute netrc_klass.



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

def netrc_klass
  @netrc_klass
end

Class Method Details

.get_credentialsObject



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

def self.get_credentials
  new.read_credentials
end

Instance Method Details

#read_credentialsObject



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

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