Class: MFYNAB::CredentialsNormalizer
- Inherits:
-
Object
- Object
- MFYNAB::CredentialsNormalizer
- Defined in:
- lib/mfynab/credentials_normalizer.rb
Instance Method Summary collapse
-
#initialize(hash_config, logger) ⇒ CredentialsNormalizer
constructor
A new instance of CredentialsNormalizer.
- #normalize ⇒ Object
Constructor Details
#initialize(hash_config, logger) ⇒ CredentialsNormalizer
Returns a new instance of CredentialsNormalizer.
5 6 7 8 |
# File 'lib/mfynab/credentials_normalizer.rb', line 5 def initialize(hash_config, logger) @hash_config = hash_config @logger = logger end |
Instance Method Details
#normalize ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mfynab/credentials_normalizer.rb', line 10 def normalize config = hash_config["credentials"] if config.nil? logger.warn("No credentials found in configuration file. Please update your configuration file.") # This provides backwards compatibility with old configuration files # that did not include the new credentials. # TODO: at some point (major version bump), we should probably remove this. return { "ynab_access_token" => ENV.fetch("YNAB_ACCESS_TOKEN"), "moneyforward_username" => ENV.fetch("MONEYFORWARD_USERNAME"), "moneyforward_password" => ENV.fetch("MONEYFORWARD_PASSWORD"), } end config.transform_values { normalize_credential(_1) } end |