dnsmadeeasy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -8
- data/README.md +137 -49
- data/dnsmadeeasy.gemspec +1 -0
- data/exe/dme +3 -2
- data/lib/dme.rb +17 -0
- data/lib/dnsmadeeasy.rb +28 -2
- data/lib/dnsmadeeasy/api/client.rb +2 -1
- data/lib/dnsmadeeasy/credentials.rb +135 -0
- data/lib/dnsmadeeasy/dme.rb +5 -0
- data/lib/dnsmadeeasy/version.rb +1 -1
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e64f1077e858bdf6f2f0610f25435d4a5e47ba76
|
4
|
+
data.tar.gz: b9960e5fc0e030d18bd0cb94688ca7d816ea8547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08d663e73e365d22490e6066e94342aedc03519ad40a2a7ce99909a7b6369aa5344d6697c0410c5a8e6bb2e4935c3eaabdf78d862a6132be837a43ed4c2311e6'
|
7
|
+
data.tar.gz: 8f6b7e12f70dafd2ec645ef21edad1dc81af84b69fa8193996060d0dd06dac71ed2bd27c9e23827f4225368408a88b6275b1ec734b4c21ca629bfee44b17ef6f
|
data/.travis.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
env:
|
2
2
|
global:
|
3
|
-
- CC_TEST_REPORTER_ID=
|
3
|
+
- CC_TEST_REPORTER_ID=6883fa6e8b9493573f7c6daeea4c33c0964a07d1b3e87bee799425cd72875a3e
|
4
4
|
sudo: false
|
5
5
|
language: ruby
|
6
6
|
cache: bundler
|
@@ -17,10 +17,4 @@ script:
|
|
17
17
|
- bundle exec rspec
|
18
18
|
after_script:
|
19
19
|
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
20
|
-
|
21
|
-
webhooks:
|
22
|
-
urls:
|
23
|
-
- secure: fgpv34jAm3rDNjiWuQtuijE0p9B2bpsCWdoCQ82pDZwktSITmNjanYCoZC0hlEw/kqMBDKRN78HfIIidy8dS664sLz8KyaFXq7RWAFsMP9fn/GMG/r9B+S3YumifQ/Zy+3OGa+0Qz76075q291QfNSPv0Y5QDMoAU5VljIVashC/qJS6DRO+vekDaDKIhi4Dr/+JpHPnjchqS4VaMB8gEIrDpeSYNlhrj1oAI/8GwgqZ8UR4sZGxNpIzUg+XGJSYz5/cAB3P18ENSQvOwaNefJa7qIVNjMD7YwXKmfX9cyr5RHM5sibq/S5fHH/N7pig+aveTquGGVxInJr1IEDiyr2TsFARjPitp9KJSFLHLsA2jm1cZfNW0/d6ii+51HdLPKorHom3fPjb0jkIe1LPa9CrrjnfSrAE9a/w4qpSnDv7OjAzkieepz+VQCtpQGIzQxJcHWaFX32iZ6RQ6pmKc/22E0OZwsNM2FHrB5V1b+rfczl8Ej7/R1wAOtHWkbLbfwZ9Ux2N0N0EKW8r8cOjEbsxmN8FFQubTwl68uqjJLhEtrOUbM28JM/NkX+Ue1KRw+NJAdMFEZQKPb/b/X6s3nwPD4/4yLyUDCGyr8aGpzSBD5uIu5uSJNiWdNDjcnXtJJ6TlGGZqj91r7FckjA8FuSA6S3yA8epMNG3FTUxPVE=
|
24
|
-
on_success: always
|
25
|
-
on_failure: onchange
|
26
|
-
on_start: never
|
20
|
+
|
data/README.md
CHANGED
@@ -1,76 +1,144 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/dnsmadeeasy.svg)](https://badge.fury.io/rb/dnsmadeeasy)
|
2
2
|
[![Build Status](https://travis-ci.org/kigster/dnsmadeeasy.svg?branch=master)](https://travis-ci.org/kigster/dnsmadeeasy)
|
3
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/
|
4
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/7a48648b482b5a5c9257/maintainability)](https://codeclimate.com/github/kigster/dnsmadeeasy/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/7a48648b482b5a5c9257/test_coverage)](https://codeclimate.com/github/kigster/dnsmadeeasy/test_coverage)
|
5
5
|
|
6
|
-
DnsMadeEasy — Ruby Client API (Supporting SDK V2.0)
|
7
|
-
==============
|
8
6
|
|
9
|
-
|
7
|
+
# DnsMadeEasy — Ruby Client API (Supporting SDK V2.0)
|
10
8
|
|
11
|
-
|
9
|
+
This is a fully featured REST API client for DnsMadeEasy provider. DME is an **excellent** provider, and is highly recommended for their ease of use, very solid API, and great customer support. They also offer free DNS failover with business accounts, which is highly recommended for the arrays of load balancers in front of your app.
|
12
10
|
|
13
|
-
|
14
|
-
gem 'dnsmadeeasy'
|
15
|
-
```
|
11
|
+
## Usage
|
16
12
|
|
17
|
-
|
13
|
+
**DnsMadeEasy** allows you to fetch, create, update DNS records, as long as you know your API key and the secret.
|
18
14
|
|
19
|
-
|
20
|
-
$ bundle
|
21
|
-
```
|
15
|
+
You can find your API Key and Secret on the [Account Settings Page](https://cp.dnsmadeeasy.com/account/info) of their UI.
|
22
16
|
|
23
|
-
|
17
|
+
Once you have the key and the secret, you have several choices:
|
24
18
|
|
25
|
-
|
26
|
-
$ gem install dnsmadeeasy
|
27
|
-
```
|
19
|
+
1. Perhaps the most conveniently, you can store them in a small YAML file, that must be placed in a specific location within your home folder: `~/.dnsmadeeasy/credentials.yml`. The file should look like this one below (NOTE: these are not real credentials, btw):
|
28
20
|
|
29
|
-
|
21
|
+
```yaml
|
22
|
+
# file: ~/.dnsmadeeasy/credentials.yml
|
23
|
+
credentials:
|
24
|
+
api_key: 2062259f-f666b17-b1fa3b48-042ad4030
|
25
|
+
api_secret: 2265bc3-e31ead-95b286312e-c215b6a0
|
26
|
+
```
|
30
27
|
|
31
|
-
|
28
|
+
With this file existing, you can query right away, by using the shortcut module `DME`, such as
|
32
29
|
|
33
|
-
|
34
|
-
|
30
|
+
```ruby
|
31
|
+
require 'dnsmadeeasy/dme' # this loads a `DME` shortcut.
|
32
|
+
DME.domains.data.first.name #=> 'moo.gamespot.com'
|
33
|
+
```
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
### Recommended Usage
|
35
|
+
2. Or, you can directly instantiate a new instance of the `Client` class, by passing your API key and API secrets as arguments:
|
39
36
|
|
40
|
-
|
37
|
+
```ruby
|
38
|
+
require 'dnsmadeeasy'
|
39
|
+
@client = DnsMadeEasy::Api::Client.new(api_key, api_secret)
|
40
|
+
```
|
41
41
|
|
42
|
+
The advantage of this method is that you can query multiple DnsMadeEasy accounts from the same Ruby VM. With other methods, only one account can be connected to.
|
42
43
|
|
43
|
-
|
44
|
-
require 'dnsmadeeasy'
|
45
|
-
DnsMadeEasy.configure do |config|
|
46
|
-
config.api_key = 'XXXX'
|
47
|
-
config.api_secret = 'YYYY'
|
48
|
-
end
|
44
|
+
3. Or, you can use the `DnsMadeEasy.configure` method to configure the key/secret pair, and then use `DnsMadeEasy` namespace to call the methods:
|
49
45
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
```ruby
|
47
|
+
require 'dnsmadeeasy'
|
48
|
+
|
49
|
+
DnsMadeEasy.configure do |config|
|
50
|
+
config.api_key = 'XXXX'
|
51
|
+
config.api_secret = 'YYYY'
|
52
|
+
end
|
53
|
+
|
54
|
+
DnsMadeEasy.domains.data.first.name #=> 'moo.gamespot.com'
|
55
|
+
```
|
56
|
+
|
57
|
+
### Shortcut Module `DME` and `DnsMadeEasy` Namespaces
|
58
|
+
|
59
|
+
Since `DnsMadeEasy` is a bit of a mouthful, we decided to offer (in addition) the abbreviated module `DME` that simply forwards all method calls to `DnsMadeEasy`. You can now `require 'dme'` to get all of the DnsMadeEasy client library loaded up, assuming it does not clash with any other `dme` file in your project.
|
60
|
+
|
61
|
+
And then you can use `DME.method(*args)` as you would on `DnsMadeEasy.method(*args)` or on the instance of the actual worker-horse class of this library, the gorgeous blone with a very long name: `DnsMadeEasy::Api::Client`.
|
62
|
+
|
63
|
+
|
64
|
+
### Examples
|
65
|
+
|
66
|
+
If you are not planning on accessing more than one DnsMadeEasy account from the same Ruby VM, it's recommended to save the credentials in the above mentioned file. **DO NOT check that file into any repository.**
|
67
|
+
|
68
|
+
Assuming my credentials are stored, I can access everything about my domains as follows (let's pretend that I own a bunch of `gamespot` domains):
|
54
69
|
|
55
|
-
### Advanced Usage
|
56
70
|
|
57
|
-
You can also instantiate a `Client` object with a different set of API key and secret, should you need to manage multiple accounts from within the same Ruby VM. The `DnsMadeEasy.configure` method is not used in this case, and the values passed to the constructor will be used instead.
|
58
|
-
|
59
71
|
```ruby
|
60
|
-
require 'dnsmadeeasy/api/client'
|
61
72
|
|
62
|
-
api_key = 'XXXX'
|
63
|
-
api_secret = 'YYYY'
|
64
73
|
|
65
|
-
|
74
|
+
IRB(main):003:0> require 'dme' #=> true
|
75
|
+
IRB(main):003:0> DME.domains.data.map(&:name)
|
76
|
+
⤷ ["demo.gamespot.systems",
|
77
|
+
"dev.gamespot.systems",
|
78
|
+
"gamespot.live",
|
79
|
+
"gamespot.systems",
|
80
|
+
"prod.gamespot.systems"
|
81
|
+
]
|
82
|
+
|
83
|
+
IRB(main):008:0> DME.api_key
|
84
|
+
⤷ "2062259f-f666b17-b1fa3b48-042ad4030"
|
85
|
+
|
86
|
+
IRB(main):009:0> DME.api_secret
|
87
|
+
⤷ "2265bc3-e31ead-95b286312e-c215b6a0"
|
88
|
+
|
89
|
+
IRB(main):010:0> @client = DME.client
|
90
|
+
⤷ #<DnsMadeEasy::Api::Client:0x00007fb6b416a4c8
|
91
|
+
@api_key="2062259f-f666b17-b1fa3b48-042ad4030",
|
92
|
+
@api_secret="2265bc3-e31ead-95b286312e-c215b6a0",
|
93
|
+
@options={},
|
94
|
+
@requests_remaining=149,
|
95
|
+
@request_limit=150,
|
96
|
+
@base_uri="https://api.dnsmadeeasy.com/V2.0">
|
66
97
|
```
|
67
98
|
|
68
|
-
|
99
|
+
### Return Values
|
100
|
+
|
101
|
+
Whever DnsMadeEasy returns is typically a Hash, but we wrap it in a [`Hashie::Mash`](https://github.com/intridea/hashie) instance, which offers some additional benefits, such as the ability to call nested values via method calls instead of using square brackets. You can always call either `to_hash` or `to_h` on an instance of a `Hashie::Mash` to get a pure hash representation.
|
69
102
|
|
70
103
|
All return values are the direct JSON responses from DNS Made Easy converted into a Hash.
|
71
104
|
|
72
105
|
For more information on the actual JSON API, please refer to the [following PDF document](http://www.dnsmadeeasy.com/integration/pdf/API-Docv2.pdf).
|
73
106
|
|
107
|
+
## Method Calls
|
108
|
+
|
109
|
+
Here is the complete of all methods supported by the `DnsMadeEasy::Api::Client`:
|
110
|
+
|
111
|
+
* `base_uri=`
|
112
|
+
* `base_uri`
|
113
|
+
* `create_a_record`
|
114
|
+
* `create_aaaa_record`
|
115
|
+
* `create_cname_record`
|
116
|
+
* `create_domain`
|
117
|
+
* `create_domains`
|
118
|
+
* `create_httpred_record`
|
119
|
+
* `create_mx_record`
|
120
|
+
* `create_ns_record`
|
121
|
+
* `create_ptr_record`
|
122
|
+
* `create_record`
|
123
|
+
* `create_spf_record`
|
124
|
+
* `create_srv_record`
|
125
|
+
* `create_txt_record`
|
126
|
+
* `delete_all_records`
|
127
|
+
* `delete_domain`
|
128
|
+
* `delete_record`
|
129
|
+
* `delete_records`
|
130
|
+
* `domain`
|
131
|
+
* `domains`
|
132
|
+
* `find_record_id`
|
133
|
+
* `find`
|
134
|
+
* `get_id_by_domain`
|
135
|
+
* `records_for`
|
136
|
+
* `request_limit`
|
137
|
+
* `requests_remaining`
|
138
|
+
* `update_record`
|
139
|
+
* `update_records`
|
140
|
+
|
141
|
+
|
74
142
|
### Managing Domains
|
75
143
|
|
76
144
|
To retrieve all domains:
|
@@ -152,7 +220,7 @@ To create a record:
|
|
152
220
|
# Arguments are: domain_name, name, priority, weight, port, value, options = {}
|
153
221
|
@client.create_srv_record ('test.io', 'woah', 1, 5, 80, '127.0.0.1', {})
|
154
222
|
# Arguments are: domain_name, name, value, redirectType, description, keywords, title, options = {}
|
155
|
-
@client.create_httpred_record('test.io', 'woah', '127.0.0.1', 'STANDARD - 302',
|
223
|
+
@client.create_httpred_record('test.io', 'woah', '127.0.0.1', 'STANDARD - 302',
|
156
224
|
'a description', 'keywords', 'a title', {})
|
157
225
|
```
|
158
226
|
|
@@ -166,15 +234,15 @@ To update a record:
|
|
166
234
|
To update several records:
|
167
235
|
|
168
236
|
```ruby
|
169
|
-
@client.update_records('test.io',
|
237
|
+
@client.update_records('test.io',
|
170
238
|
[
|
171
|
-
{ 'id' => 123,
|
172
|
-
'name' => 'buddy',
|
239
|
+
{ 'id' => 123,
|
240
|
+
'name' => 'buddy',
|
173
241
|
'type' => 'A',
|
174
242
|
'value'=> '127.0.0.1'
|
175
243
|
}
|
176
244
|
], { 'ttl' => '60' })
|
177
|
-
|
245
|
+
|
178
246
|
```
|
179
247
|
|
180
248
|
To get the number of API requests remaining after a call:
|
@@ -193,6 +261,26 @@ To get the API request total limit after a call:
|
|
193
261
|
```
|
194
262
|
>Information is not available until an API call has been made
|
195
263
|
|
264
|
+
## Installation
|
265
|
+
|
266
|
+
Add this line to your application's Gemfile:
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
gem 'dnsmadeeasy'
|
270
|
+
```
|
271
|
+
|
272
|
+
And then execute:
|
273
|
+
|
274
|
+
```
|
275
|
+
$ bundle
|
276
|
+
```
|
277
|
+
|
278
|
+
Or install it yourself:
|
279
|
+
|
280
|
+
```
|
281
|
+
$ gem install dnsmadeeasy
|
282
|
+
```
|
283
|
+
|
196
284
|
|
197
285
|
## Development
|
198
286
|
|
@@ -207,7 +295,7 @@ The current maintainer [Konstantin Gredeskoul](https://github.com/kigster) wishe
|
|
207
295
|
* Arnoud Vermeer for the original `dnsmadeeasy-rest-api` gem
|
208
296
|
* Andre Arko, Paul Henry, James Hart formerly of [Wanelo](wanelo.com) fame, for bringing the REST API gem up to the level.
|
209
297
|
* Phil Cohen, who graciously transferred the ownership of this gem on RubyGems to the current maintainer.
|
210
|
-
|
298
|
+
|
211
299
|
|
212
300
|
## Contributing
|
213
301
|
|
data/dnsmadeeasy.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
|
+
spec.add_dependency 'hashie'
|
33
34
|
|
34
35
|
spec.add_development_dependency 'yard'
|
35
36
|
spec.add_development_dependency 'simplecov'
|
data/exe/dme
CHANGED
data/lib/dme.rb
ADDED
data/lib/dnsmadeeasy.rb
CHANGED
@@ -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_relative 'dnsmadeeasy/credentials'
|
6
7
|
require_relative 'dnsmadeeasy/api/client'
|
7
8
|
|
8
9
|
module DnsMadeEasy
|
@@ -12,12 +13,20 @@ module DnsMadeEasy
|
|
12
13
|
class << self
|
13
14
|
attr_accessor :api_key, :api_secret
|
14
15
|
|
16
|
+
def credentials=(file)
|
17
|
+
@creds = ::DnsMadeEasy::Credentials.load(file)
|
18
|
+
if @creds && @creds.valid?
|
19
|
+
configure do |config|
|
20
|
+
config.api_key = @creds.api_key
|
21
|
+
config.api_secret = @creds.api_secret
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
15
25
|
|
16
26
|
def configure
|
17
27
|
yield(self) if block_given?
|
18
28
|
end
|
19
29
|
|
20
|
-
|
21
30
|
def client(**options)
|
22
31
|
@client ||= create_client(false, **options)
|
23
32
|
end
|
@@ -27,13 +36,30 @@ module DnsMadeEasy
|
|
27
36
|
@sandbox_client ||= create_client(true, **options)
|
28
37
|
end
|
29
38
|
|
39
|
+
# Basically delegate it all to the Client instance
|
40
|
+
# if the method call is supported.
|
41
|
+
#
|
42
|
+
def method_missing(method, *args, &block)
|
43
|
+
if client.respond_to?(method)
|
44
|
+
client.send(method, *args, &block)
|
45
|
+
else
|
46
|
+
super(method, *args, &block)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def default!
|
51
|
+
if Credentials.exist?
|
52
|
+
self.credentials = Credentials.default_file
|
53
|
+
end
|
54
|
+
end
|
30
55
|
|
31
56
|
private
|
32
57
|
|
33
58
|
def create_client(sandbox = false, **options)
|
59
|
+
default! unless api_key && api_secret
|
34
60
|
raise APIKeyAndSecretMissingError, 'Please set #api_key and #api_secret' unless api_key && api_secret
|
35
61
|
::DnsMadeEasy::Api::Client.new(api_key, api_secret, sandbox, **options)
|
36
62
|
end
|
37
|
-
|
38
63
|
end
|
64
|
+
|
39
65
|
end
|
@@ -3,6 +3,7 @@ require 'openssl'
|
|
3
3
|
require 'json'
|
4
4
|
require 'uri'
|
5
5
|
require 'net/http'
|
6
|
+
require 'hashie/mash'
|
6
7
|
|
7
8
|
module DnsMadeEasy
|
8
9
|
module Api
|
@@ -247,7 +248,7 @@ module DnsMadeEasy
|
|
247
248
|
|
248
249
|
unparsed_json = response.body.to_s.empty? ? '{}' : response.body
|
249
250
|
|
250
|
-
JSON.parse(unparsed_json)
|
251
|
+
Hashie::Mash.new(JSON.parse(unparsed_json))
|
251
252
|
end
|
252
253
|
|
253
254
|
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module DnsMadeEasy
|
4
|
+
# Credentials file should look like this:
|
5
|
+
#
|
6
|
+
# Usage:
|
7
|
+
#
|
8
|
+
# Example 1. Assuming file ~/.dnsmadeeasy/credentials.yml exists:
|
9
|
+
#
|
10
|
+
# DnsMadeEasy::Credentials.exist? #=> true
|
11
|
+
# creds = DnsMadeEasy::Credentials.load
|
12
|
+
#
|
13
|
+
# creds.api_key #=> key
|
14
|
+
# creds.api_secret #=> secret
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# Example 2. Assuming another file: ~/.private/dnsmadeeasy.yml:
|
18
|
+
#
|
19
|
+
# DnsMadeEasy::Credentials.exist? #=> false
|
20
|
+
# DnsMadeEasy::Credentials.exist?('~/.private/dnsmadeeasy.yml') #=> true
|
21
|
+
#
|
22
|
+
# creds = DnsMadeEasy::Credentials.load('~/.private/dnsmadeeasy.yml')
|
23
|
+
# creds.api_key #=> key
|
24
|
+
# creds.api_secret #=> secret
|
25
|
+
#
|
26
|
+
#
|
27
|
+
class Credentials < Hash
|
28
|
+
DEFAULT_CREDENTIALS_FILE = File.expand_path('~/.dnsmadeeasy/credentials.yml').freeze
|
29
|
+
|
30
|
+
class CredentialsFileNotFound < StandardError
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Class Methods
|
35
|
+
#
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def exist?(file = DEFAULT_CREDENTIALS_FILE)
|
39
|
+
File.exist?(file)
|
40
|
+
end
|
41
|
+
|
42
|
+
def load(file = DEFAULT_CREDENTIALS_FILE)
|
43
|
+
validate_argument(file)
|
44
|
+
|
45
|
+
new.tap do |local|
|
46
|
+
local.merge!(parse_file(file)) if exist?(file)
|
47
|
+
local.symbolize!
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def default_file
|
52
|
+
DEFAULT_CREDENTIALS_FILE
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def validate_argument(file)
|
59
|
+
unless file && File.exist?(file)
|
60
|
+
raise CredentialsFileNotFound, "File #{file} could not be found"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def parse_file(file)
|
66
|
+
YAML.load(read_file(file))
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def read_file(file)
|
71
|
+
File.read(file)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# Instance Methods
|
77
|
+
# NOTE: we are subclassing Hash, which isn't awesome, but gets the job done.
|
78
|
+
|
79
|
+
def symbolize(param_hash = self)
|
80
|
+
Hash.new.tap { |hash|
|
81
|
+
param_hash.each_pair do |key, key_value|
|
82
|
+
value = recurse_if_needed(key_value)
|
83
|
+
symbolize_key(hash, key, value)
|
84
|
+
end
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
public
|
89
|
+
|
90
|
+
def valid?
|
91
|
+
api_key && api_secret
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def symbolize!
|
96
|
+
hash = symbolize(self)
|
97
|
+
clear
|
98
|
+
merge!(hash)
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
def api_key
|
103
|
+
credentials && credentials[:api_key]
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def api_secret
|
108
|
+
credentials && credentials[:api_secret]
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def symbolize_key(hash, key, value)
|
115
|
+
case key
|
116
|
+
when String, Symbol
|
117
|
+
hash[key.to_sym] = value
|
118
|
+
else
|
119
|
+
hash[key] = value
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def recurse_if_needed(key_value)
|
125
|
+
key_value.is_a?(Hash) ? symbolize(key_value) : key_value
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def credentials
|
130
|
+
self[:credentials] || {}
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
data/lib/dnsmadeeasy/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Gredeskoul
|
@@ -14,6 +14,20 @@ bindir: exe
|
|
14
14
|
cert_chain: []
|
15
15
|
date: 2017-12-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: hashie
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
17
31
|
- !ruby/object:Gem::Dependency
|
18
32
|
name: yard
|
19
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,8 +165,11 @@ files:
|
|
151
165
|
- bin/setup
|
152
166
|
- dnsmadeeasy.gemspec
|
153
167
|
- exe/dme
|
168
|
+
- lib/dme.rb
|
154
169
|
- lib/dnsmadeeasy.rb
|
155
170
|
- lib/dnsmadeeasy/api/client.rb
|
171
|
+
- lib/dnsmadeeasy/credentials.rb
|
172
|
+
- lib/dnsmadeeasy/dme.rb
|
156
173
|
- lib/dnsmadeeasy/version.rb
|
157
174
|
homepage: https://github.com/kigster/dnsmadeeasy
|
158
175
|
licenses:
|