Class: DoiExtractor::Secrets
- Inherits:
-
Object
- Object
- DoiExtractor::Secrets
- 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
-
#api_password ⇒ Object
readonly
Returns the value of attribute api_password.
-
#api_path ⇒ Object
readonly
Returns the value of attribute api_path.
-
#api_username ⇒ Object
readonly
Returns the value of attribute api_username.
Instance Method Summary collapse
-
#initialize(overrides = {}) ⇒ Secrets
constructor
A new instance of Secrets.
- #read_yaml(path) ⇒ Object
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_password ⇒ Object (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_path ⇒ Object (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_username ⇒ Object (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 |