Class: DoiExtractor::Secrets

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

Constant Summary collapse

DEFAULT_API_PATH =
'/pkg/mpctools/secrets/api_creds.yml'
DEFAULT_API_USERNAME =

‘doi_extractor’

'terrapop'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overrides = {}) ⇒ Secrets

Returns a new instance of Secrets.



8
9
10
11
12
# File 'lib/doi_extractor/secrets.rb', line 8

def initialize(overrides = {})
  @api_path = overrides[:api_path] || DEFAULT_API_PATH
  @api_username = overrides[:api_username] || DEFAULT_API_USERNAME
  @api_password = overrides[:api_password] || read_yaml(@api_path)[@api_username]
end

Instance Attribute Details

#api_passwordObject (readonly)

Returns the value of attribute api_password.



6
7
8
# File 'lib/doi_extractor/secrets.rb', line 6

def api_password
  @api_password
end

#api_pathObject (readonly)

Returns the value of attribute api_path.



6
7
8
# File 'lib/doi_extractor/secrets.rb', line 6

def api_path
  @api_path
end

#api_usernameObject (readonly)

Returns the value of attribute api_username.



6
7
8
# File 'lib/doi_extractor/secrets.rb', line 6

def api_username
  @api_username
end

Instance Method Details

#read_yaml(path) ⇒ Object



14
15
16
# File 'lib/doi_extractor/secrets.rb', line 14

def read_yaml(path)
  YAML.load(ERB.new(IO.read(path)).result)
end