dnsmadeeasy 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1a352b3b93d581bfe8c2e6711071b7692abf19cf
4
- data.tar.gz: 6e39787c4c754e78fd69821bc4b3ad19d582bebe
2
+ SHA256:
3
+ metadata.gz: ed2f0693df9db3d005273c6ce41b114aab36b57516c84ed47ef7e27bd4a35339
4
+ data.tar.gz: 39389e4043a3976819594a40f4f8d64e1c653244c14783a6d08d59176bb06ed6
5
5
  SHA512:
6
- metadata.gz: 2e38fc6b2cbe5fb7303458545d58d0e60ae53cea1e8518e373aff3e058bf5c7f6c77ca1506e062b5fb5e17e932afaa663526100deca97e00bf3702dda85cb067
7
- data.tar.gz: b1f21eeb6ffe587c63d9ff5eab93a6afdfeb5765e14429d1951235522159d36cb8438b677480ae50a367d46e1212ef3ab99864f3ae52f60886eaaa680875b5c8
6
+ metadata.gz: 5f4f38240929d627ae8ad99d80255bf14d8cad007144876d856504a0a126370964dea4d521e54eceb99694bd13df4ef09ca7acea91f22a0ddaafc582e8c3fe13
7
+ data.tar.gz: 63a1ec57791474e042312bd6fdaa2ebaeba7b8b88f24d590bf9f5b620ea5f8dcd3dc5fcdf0a286652eee1a0bbb94ace257ee9bd20ba141e458c59b65f6d36874
data/README.md CHANGED
@@ -37,18 +37,7 @@ Once you have the key and the secret, you have several choices:
37
37
 
38
38
  DnsMadeEasy.domains.data.first.name #=> 'moo.gamespot.com'
39
39
  ```
40
-
41
- Once you configure the keys, you can also use the shortcut module to save you some typing:
42
-
43
- ```ruby
44
- require 'dnsmadeeasy/dme'
45
- DME.domains.data.first.name #=> 'moo.gamespot.com'
46
- ```
47
-
48
- This has the advantage of being much shorter, but might conflict with existing modules in your Ruby VM.
49
- In this case, just do not require `dnsmadeeasy/dme` and only require `dnsmadeeasy`, and you'll be fine.
50
- Otherwise, using `DME` is identical to using `DnsMadeEasy`, assuming you required `dnsmadeeasy/dme` file.
51
-
40
+
52
41
  3. Configuring API keys as above is easy, and can be done using environment variables. Alternatively, it may be convenient to store credentials in a YAML file.
53
42
 
54
43
  * If filename is not specified, there is default location where this file is searched, which is `~/.dnsmadeeasy/credentials.yml`.
@@ -85,16 +74,45 @@ Once you have the key and the secret, you have several choices:
85
74
 
86
75
  ```ruby
87
76
  require 'dnsmadeeasy'
88
- DnsMadeEasy.configure_from_file(file, account_name = nil, encryption_key = nil)
77
+ DnsMadeEasy.configure_from_file(file, account = nil, encryption_key = nil)
89
78
 
90
79
  # for example:
91
80
  DnsMadeEasy.configure_from_file('config/dme.yaml', 'production')
92
81
  DnsMadeEasy.domains #=> [ ... ]
93
82
 
94
83
  # or with encrypted key passed as an argument to decrypt YAML values:
95
- DnsMadeEasy.configure_from_file('config/dme.yaml', 'production', ENV['PRODUCTION_KEY'])
84
+ DnsMadeEasy.configure_from_file(
85
+ 'config/dme.yaml',
86
+ 'production',
87
+ ENV['PRODUCTION_KEY'])
96
88
  ```
97
89
 
90
+ 3. Finally, you can use `DME.credentials_from_file` method that, unlike the method above, uses hash arguments:
91
+
92
+ ```ruby
93
+ @creds = DnsMadeEasy.credentials_from_file(file: 'my-creds.yml',
94
+ account: 'production',
95
+ encryption_key: 'MY_KEY')
96
+ @creds.api_key # => ...
97
+ @creds.api_secret # => ...
98
+ ```
99
+
100
+ Method above simply returns the credentials instance, but does not "save" it as the default credentials like `configure_from_file`. Therefore, if you need to access multiple accounts at the same time, this method will help you maintain multiple credentials at the same time.
101
+
102
+ ___
103
+
104
+ Once you configure the keys, you can also use the shortcut module to save you some typing:
105
+
106
+ ```ruby
107
+ require 'dnsmadeeasy/dme'
108
+ DME.domains.data.first.name #=> 'moo.gamespot.com'
109
+ ```
110
+
111
+ This has the advantage of being much shorter, but might conflict with existing modules in your Ruby VM.
112
+ In this case, just do not require `dnsmadeeasy/dme` and only require `dnsmadeeasy`, and you'll be fine.
113
+ Otherwise, using `DME` is identical to using `DnsMadeEasy`, assuming you required `dnsmadeeasy/dme` file.
114
+
115
+
98
116
  ### Which Namespace to Use? What is `DME` versus `DnsMadeEasy`?
99
117
 
100
118
  Since `DnsMadeEasy` is a bit of a mouthful, we decided to offer (in addition to the standard `DnsMadeEasy` namespace) the abbreviated module `DME` that simply forwards all messages to the module `DnsMadeEasy`. If in your Ruby VM there is no conflicting top-level class `DME`, then you can `require 'dnsmadeeasy/dme'` to get all of the DnsMadeEasy client library functionality without having to type the full name once. You can even do `require 'dme'`.
@@ -6,9 +6,11 @@ require 'dnsmadeeasy/version'
6
6
 
7
7
  DnsMadeEasy::DESCRIPTION = <<-eof
8
8
  This is a fully-featured DNS API client for DnsMadeEasy.com, that includes
9
- both the Ruby API and (soon to follow – a CLI). This gem used to be called
10
- dnsmadeeasy-rest-api, but the original author Phil Cohen kindly passed on
11
- the RubyGems namespace, and now you can install just plane simple "dnsmadeeasy".
9
+ both the Ruby API and a corresponding CLI interface. This gem is based on the
10
+ "dnsmadeeasy-rest-api". We also wish to thank the original author Phil Cohen who
11
+ kindly passed on the RubyGems namespace, and now you can install just plain simple
12
+ install "dnsmadeeasy" gem. The gem additionally supports storing credentials in the
13
+ ~/.dnsmadeeasy/credentials.yml file, supports multiple accounts, encryption, and more.
12
14
  eof
13
15
 
14
16
  Gem::Specification.new do |spec|
data/lib/dme.rb CHANGED
@@ -15,7 +15,3 @@ module DME
15
15
  end
16
16
  end
17
17
  end
18
-
19
-
20
-
21
-
@@ -3,6 +3,7 @@ module DnsMadeEasy
3
3
  API_BASE_URL_SANDBOX = 'https://sandboxapi.dnsmadeeasy.com/V2.0'
4
4
  end
5
5
 
6
+ require 'dnsmadeeasy/version'
6
7
  require 'dnsmadeeasy/credentials'
7
8
  require 'dnsmadeeasy/api/client'
8
9
 
@@ -31,12 +32,12 @@ module DnsMadeEasy
31
32
  end
32
33
 
33
34
  def configure_from_file(file = nil,
34
- account_name = nil,
35
+ account = nil,
35
36
  encryption_key = nil)
36
37
 
37
38
  credentials = ::DnsMadeEasy::Credentials.keys_from_file(
38
- filename: file || ::DnsMadeEasy::Credentials.default_credentials_path(user: ENV['USER']),
39
- account_name: account_name,
39
+ file: file || ::DnsMadeEasy::Credentials.default_credentials_path(user: ENV['USER']),
40
+ account: account,
40
41
  encryption_key: encryption_key)
41
42
  if credentials
42
43
  configure do |config|
@@ -48,6 +49,15 @@ module DnsMadeEasy
48
49
  end
49
50
  end
50
51
 
52
+ def credentials_from_file(file: DnsMadeEasy::Credentials.default_credentials_path,
53
+ account: nil,
54
+ encryption_key: nil)
55
+
56
+ DnsMadeEasy::Credentials.keys_from_file file: file,
57
+ account: account,
58
+ encryption_key: encryption_key
59
+ end
60
+
51
61
  def api_key=(value)
52
62
  self.default_api_key = value
53
63
  end
@@ -23,7 +23,7 @@ module DnsMadeEasy
23
23
  # api_secret: 43009899-abcc-ffcc-eeee-09f809808098
24
24
  # ````
25
25
  #
26
- # @creds = DnsMadeEasy::Credentials.keys_from_file(filename: file)
26
+ # @creds = DnsMadeEasy::Credentials.keys_from_file(file: file)
27
27
  # @creds.api_key #=> '12345678-a8f8-4466-ffff-2324aaaa9098'
28
28
  #
29
29
  # #### From a default filename ~/.dnsmadeeasy/credentials.yml
@@ -55,7 +55,7 @@ module DnsMadeEasy
55
55
  # ```
56
56
  #
57
57
  # Here we have multiple credentials account, one of which can have 'default_account: true'
58
- # Each account has a name that's used in `account_name` argument. Finally, if the keys
58
+ # Each account has a name that's used in `account` argument. Finally, if the keys
59
59
  # are encrypted, the key can either be referenced in the YAML file itself (in the above
60
60
  # case it points to a file name — see documentation on the gem Sym about various formats
61
61
  # of the key).
@@ -64,8 +64,8 @@ module DnsMadeEasy
64
64
  # actually specifies the key.
65
65
  #
66
66
  # @creds = DnsMadeEasy::Credentials.keys_from_file(
67
- # filename: 'spec/fixtures/credentials-multi-account.yml',
68
- # account_name: 'production')
67
+ # file: 'spec/fixtures/credentials-multi-account.yml',
68
+ # account: 'production')
69
69
  #
70
70
  #
71
71
  # )
@@ -79,12 +79,12 @@ module DnsMadeEasy
79
79
  ApiKeys.new(key, secret, encryption_key)
80
80
  end
81
81
 
82
- def keys_from_file(filename: default_credentials_path,
83
- account_name: nil,
82
+ def keys_from_file(file: default_credentials_path,
83
+ account: nil,
84
84
  encryption_key: nil)
85
85
 
86
- YamlFile.new(filename: filename).keys(account_name: account_name,
87
- encryption_key: encryption_key)
86
+ YamlFile.new(file: file).keys(account: account,
87
+ encryption_key: encryption_key)
88
88
  end
89
89
 
90
90
  # @return String path to the default credentials file.
@@ -17,15 +17,15 @@ module DnsMadeEasy
17
17
  :api_secret,
18
18
  :encryption_key,
19
19
  :default,
20
- :account_name
20
+ :account
21
21
 
22
22
  include Sym
23
23
 
24
- def initialize(key, secret, encryption_key = nil, default: false, account_name: nil)
24
+ def initialize(key, secret, encryption_key = nil, default: false, account: nil)
25
25
  raise InvalidCredentialKeys, "Key and Secret can not be nil" if key.nil? || secret.nil?
26
26
 
27
27
  @default = default
28
- @account_name = account_name
28
+ @account = account
29
29
 
30
30
  if !valid?(key, secret) && encryption_key
31
31
  @encryption_key = sym_resolve(encryption_key)
@@ -10,24 +10,27 @@ module DnsMadeEasy
10
10
  class YamlFile
11
11
  attr_accessor :filename, :account, :mash
12
12
 
13
- def initialize(filename: default_credentials_path)
14
- self.filename = filename
13
+ def initialize(file: default_credentials_path)
14
+ self.filename = file
15
15
  parse! if exist?
16
16
  end
17
17
 
18
- def keys(account_name: nil, encryption_key: nil)
18
+ def keys(account: nil, encryption_key: nil)
19
19
  return nil unless exist?
20
20
  return nil if mash.nil?
21
21
 
22
22
  creds = if mash.accounts.is_a?(Array)
23
- account = if account_name
24
- mash.accounts.find { |a| a.name == account_name.to_s }
23
+ account = if account
24
+ mash.accounts.find { |a| a.name == account.to_s }
25
+ elsif
26
+ mash.accounts.size == 1
27
+ mash.accounts.first
25
28
  else
26
29
  mash.accounts.find { |a| a.default_account }
27
30
  end
28
31
 
29
32
  raise DnsMadeEasy::APIKeyAndSecretMissingError,
30
- (account_name ? "account #{account_name} was not found" : 'default account does not exist') unless account
33
+ (account ? "account #{account} was not found" : 'default account does not exist') unless account
31
34
 
32
35
  raise DnsMadeEasy::InvalidCredentialsFormatError,
33
36
  'Expected account entry to have "credentials" key' unless account.credentials
@@ -107,7 +107,7 @@ module DnsMadeEasy
107
107
 
108
108
  def configure_authentication
109
109
  keys = DnsMadeEasy::Credentials.keys_from_file(
110
- filename: ENV['DNSMADEEASY_CREDENTIALS_FILE'] || DnsMadeEasy::Credentials.default_credentials_path(user: ENV['USER'])
110
+ file: ENV['DNSMADEEASY_CREDENTIALS_FILE'] || DnsMadeEasy::Credentials.default_credentials_path(user: ENV['USER'])
111
111
  )
112
112
  if keys
113
113
  DnsMadeEasy.api_key = keys.api_key
@@ -1,3 +1,3 @@
1
1
  module DnsMadeEasy
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsmadeeasy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2018-01-12 00:00:00.000000000 Z
15
+ date: 2018-01-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: sym
@@ -182,11 +182,12 @@ dependencies:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
- description: |
186
- This is a fully-featured DNS API client for DnsMadeEasy.com, that includes
187
- both the Ruby API and (soon to follow a CLI). This gem used to be called
188
- dnsmadeeasy-rest-api, but the original author Phil Cohen kindly passed on
189
- the RubyGems namespace, and now you can install just plane simple "dnsmadeeasy".
185
+ description: "This is a fully-featured DNS API client for DnsMadeEasy.com, that includes\nboth
186
+ the Ruby API and a corresponding CLI interface. This gem is based on the \n\"dnsmadeeasy-rest-api\".
187
+ We also wish to thank the original author Phil Cohen who \nkindly passed on the
188
+ RubyGems namespace, and now you can install just plain simple\ninstall \"dnsmadeeasy\"
189
+ gem. The gem additionally supports storing credentials in the\n~/.dnsmadeeasy/credentials.yml
190
+ file, supports multiple accounts, encryption, and more.\n"
190
191
  email:
191
192
  - kigster@gmail.com
192
193
  - letuboy@gmail.com
@@ -242,11 +243,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
243
  version: '0'
243
244
  requirements: []
244
245
  rubyforge_project:
245
- rubygems_version: 2.6.13
246
+ rubygems_version: 2.7.3
246
247
  signing_key:
247
248
  specification_version: 4
248
249
  summary: This is a fully-featured DNS API client for DnsMadeEasy.com, that includes
249
- both the Ruby API and (soon to follow – a CLI). This gem used to be called dnsmadeeasy-rest-api,
250
- but the original author Phil Cohen kindly passed on the RubyGems namespace, and
251
- now you can install just plane simple "dnsmadeeasy".
250
+ both the Ruby API and a corresponding CLI interface. This gem is based on the "dnsmadeeasy-rest-api".
251
+ We also wish to thank the original author Phil Cohen who kindly passed on the RubyGems
252
+ namespace, and now you can install just plain simple install "dnsmadeeasy" gem.
253
+ The gem additionally supports storing credentials in the ~/.dnsmadeeasy/credentials.yml
254
+ file, supports multiple accounts, encryption, and more.
252
255
  test_files: []