Class: DnsMadeEasy::Credentials::YamlFile
- Inherits:
-
Object
- Object
- DnsMadeEasy::Credentials::YamlFile
- Defined in:
- lib/dnsmadeeasy/credentials/yaml_file.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#mash ⇒ Object
Returns the value of attribute mash.
Instance Method Summary collapse
-
#initialize(file: default_credentials_path) ⇒ YamlFile
constructor
A new instance of YamlFile.
- #keys(account: nil, encryption_key: nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file: default_credentials_path) ⇒ YamlFile
Returns a new instance of YamlFile.
14 15 16 17 |
# File 'lib/dnsmadeeasy/credentials/yaml_file.rb', line 14 def initialize(file: default_credentials_path) self.filename = file parse! if exist? end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
12 13 14 |
# File 'lib/dnsmadeeasy/credentials/yaml_file.rb', line 12 def account @account end |
#filename ⇒ Object
Returns the value of attribute filename.
12 13 14 |
# File 'lib/dnsmadeeasy/credentials/yaml_file.rb', line 12 def filename @filename end |
#mash ⇒ Object
Returns the value of attribute mash.
12 13 14 |
# File 'lib/dnsmadeeasy/credentials/yaml_file.rb', line 12 def mash @mash end |
Instance Method Details
#keys(account: nil, encryption_key: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dnsmadeeasy/credentials/yaml_file.rb', line 19 def keys(account: nil, encryption_key: nil) return nil unless exist? return nil if mash.nil? creds = if mash.accounts.is_a?(Array) credentials_from_array(mash.accounts, account&.to_s) elsif mash.credentials mash.credentials else raise DnsMadeEasy::InvalidCredentialsFormatError, 'expected either "accounts" or "credentials" as the top-level key' end return nil unless creds ApiKeys.new creds.api_key, creds.api_secret, encryption_key || creds.encryption_key end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/dnsmadeeasy/credentials/yaml_file.rb', line 41 def to_s "file #{filename}" end |