dnsimpler 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +3 -4
- data/lib/dnsimpler.rb +1 -2
- data/lib/dnsimpler/error.rb +1 -1
- data/lib/dnsimpler/http.rb +7 -4
- data/lib/dnsimpler/version.rb +1 -1
- data/test/dnsimpler/http_test.rb +4 -4
- data/test/dnsimpler_test.rb +19 -19
- data/test/test_helper.rb +3 -2
- metadata +2 -5
- data/lib/dnsimpler/try.rb +0 -17
- data/test/dnsimpler/try_test.rb +0 -13
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Zjk4YzA2ZTBhNmU3N2JjNDliNzhhYjg0NzcwNWY1YWU2NzhkM2VlMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDM2YTY1Y2EwYjZlZDE4NmIwMWUwNDM3ZmI0NzI3ZmI1YTk4MzdkOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzkzYzNkOWVkNDAzYzY5YjE2MTkzN2UzY2U3ZDUxM2UyNzY4OWQ1N2NiMzg3
|
10
|
+
NGVlZTliOTIzYjk2ZjkzYmJiOGNjNmIyMGVjMjE0ZjBmYmVjMTM5YmQ1MGE1
|
11
|
+
YzBmM2JlMDI1Y2MyNTg0N2Y3OWQ5NTUxOTNhY2Q4YjNlZTkwYWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDdjYjIyYzM3MjA1NDM0YjkxNzNkNjhiY2ZmYzRmMGVlMWZiODE5NDdhZmZl
|
14
|
+
OWI3MGViMTZmZDIxMmI3NWM5ZTNmYzU0YzNlOWVmMWE4NjQ1OGVhOTA4ZWIw
|
15
|
+
MjczYjYxN2NiZmI2ODYxMWIzY2U0ZDU1MDFjMmE5OGY2YTg3ZjQ=
|
data/README.md
CHANGED
@@ -24,9 +24,8 @@ Or install it yourself as:
|
|
24
24
|
Configure the gem
|
25
25
|
```ruby
|
26
26
|
DNSimpler.setup do |config|
|
27
|
-
config.username = "bob@example.com"
|
28
27
|
config.token = "DNSIMPLE_API_TOKEN"
|
29
|
-
config.base_uri = "https://api.dnsimple.com" # For testing you can use the sandbox
|
28
|
+
config.base_uri = "https://api.dnsimple.com/" # For testing you can use the sandbox
|
30
29
|
config.debug = false
|
31
30
|
config.proxy = {addr: 'http://example.com', port: 8080, user: 'bob', pass: 'password'}
|
32
31
|
end
|
@@ -34,7 +33,7 @@ end
|
|
34
33
|
|
35
34
|
Make your API calls.
|
36
35
|
```ruby
|
37
|
-
domains_response = DNSimpler.get('
|
36
|
+
domains_response = DNSimpler.get('domains')
|
38
37
|
p domains_response.code
|
39
38
|
=> 200
|
40
39
|
p domains_response.body
|
@@ -43,7 +42,7 @@ p domains_response.body
|
|
43
42
|
|
44
43
|
Some API calls require parameters. Just pass them as a hash
|
45
44
|
```ruby
|
46
|
-
registration = DNSimpler.post('
|
45
|
+
registration = DNSimpler.post('domains/registrar/example.com/register', {registrant_id: 1234})
|
47
46
|
p registration.code
|
48
47
|
=> 201
|
49
48
|
p domains_response.body
|
data/lib/dnsimpler.rb
CHANGED
@@ -2,7 +2,6 @@ require 'ostruct'
|
|
2
2
|
require "dnsimpler/version"
|
3
3
|
require 'dnsimpler/http'
|
4
4
|
require 'dnsimpler/error'
|
5
|
-
require 'dnsimpler/try'
|
6
5
|
|
7
6
|
module DNSimpler
|
8
7
|
MATTRS = %w[username token base_uri debug]
|
@@ -20,7 +19,7 @@ module DNSimpler
|
|
20
19
|
# API username
|
21
20
|
@@username = ''
|
22
21
|
|
23
|
-
#
|
22
|
+
# OAuth Token - v2 api
|
24
23
|
@@token = ''
|
25
24
|
|
26
25
|
# URI for the requests. Defaults to https://api.dnsimple.com/
|
data/lib/dnsimpler/error.rb
CHANGED
data/lib/dnsimpler/http.rb
CHANGED
@@ -11,7 +11,7 @@ module DNSimpler
|
|
11
11
|
headers: {
|
12
12
|
'Accept' => 'application/json',
|
13
13
|
'User-Agent' => "dnsimpler/#{DNSimpler::VERSION}",
|
14
|
-
'
|
14
|
+
'Authorization' => "Bearer #{DNSimpler.token}"
|
15
15
|
}
|
16
16
|
}
|
17
17
|
|
@@ -36,9 +36,12 @@ module DNSimpler
|
|
36
36
|
opts.merge!(self.base_options)
|
37
37
|
|
38
38
|
req = super path, opts, &blk
|
39
|
-
|
40
39
|
if (200...400).include? req.code
|
41
|
-
|
40
|
+
# httparty can return a nil(ish) object here - https://github.com/jnunemaker/httparty/issues/285
|
41
|
+
# Hash.try gets overriden by activerecord
|
42
|
+
body = req.body.nil? ? nil : req.parsed_response["data"]
|
43
|
+
|
44
|
+
response = OpenStruct.new(code: req.code, body: body)
|
42
45
|
|
43
46
|
if DNSimpler.debug
|
44
47
|
response.request = req
|
@@ -56,4 +59,4 @@ module DNSimpler
|
|
56
59
|
end
|
57
60
|
|
58
61
|
end
|
59
|
-
end
|
62
|
+
end
|
data/lib/dnsimpler/version.rb
CHANGED
data/test/dnsimpler/http_test.rb
CHANGED
@@ -5,7 +5,7 @@ module DNSimpler
|
|
5
5
|
|
6
6
|
def setup
|
7
7
|
super
|
8
|
-
stub_request(:get, "#{DNSimpler.base_uri}
|
8
|
+
stub_request(:get, "#{DNSimpler.base_uri}registrar/domains/example.com/check").with(headers: {'Accept' => 'application/json', 'Authorization' => 'Bearer token-test-string', 'User-Agent' => "dnsimpler/#{DNSimpler::VERSION}"}).to_return(status: 404, body: { data: {"message"=>"Domain `example.com' not found"}}.to_json)
|
9
9
|
end
|
10
10
|
|
11
11
|
test "#base_options" do
|
@@ -14,7 +14,7 @@ module DNSimpler
|
|
14
14
|
|
15
15
|
test "an error is raised for a failed request" do
|
16
16
|
error = assert_raises ::DNSimpler::Error do
|
17
|
-
HTTP.get("
|
17
|
+
HTTP.get("/registrar/domains/example.com/check")
|
18
18
|
end
|
19
19
|
|
20
20
|
refute (200...400).include? error.code
|
@@ -24,11 +24,11 @@ module DNSimpler
|
|
24
24
|
class_eval <<-RUBY_EVAL
|
25
25
|
|
26
26
|
test "#{method}" do
|
27
|
-
response = HTTP.#{method}('
|
27
|
+
response = HTTP.#{method}('/domains')
|
28
28
|
assert_instance_of OpenStruct, response
|
29
29
|
end
|
30
30
|
|
31
31
|
RUBY_EVAL
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/test/dnsimpler_test.rb
CHANGED
@@ -27,28 +27,28 @@ class DNSimplerTest < MiniTest::Test
|
|
27
27
|
class_eval <<-RUBY_EVAL
|
28
28
|
|
29
29
|
test "#{method}" do
|
30
|
-
response = DNSimpler.#{method}('
|
30
|
+
response = DNSimpler.#{method}('/domains')
|
31
31
|
assert_instance_of OpenStruct, response
|
32
32
|
end
|
33
33
|
|
34
34
|
RUBY_EVAL
|
35
35
|
end
|
36
36
|
|
37
|
-
test "invalid config variable" do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
test "#{}http_proxy" do
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
37
|
+
# test "invalid config variable" do
|
38
|
+
# assert_raises NoMethodError do
|
39
|
+
# DNSimpler.nonconfig = 'bob'
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# assert_raises NoMethodError do
|
43
|
+
# DNSimpler.setup do |config|
|
44
|
+
# config.fake = 'ed'
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# test "#{}http_proxy" do
|
50
|
+
# DNSimpler.http_proxy = {addr: 'http://example.com', port: 8080, user: 'bob', pass: 'password'}
|
51
|
+
# assert_instance_of OpenStruct, DNSimpler.http_proxy
|
52
|
+
# end
|
53
|
+
|
54
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -10,12 +10,13 @@ class MiniTest::Test
|
|
10
10
|
def setup
|
11
11
|
DNSimpler.setup do |config|
|
12
12
|
config.base_uri = "https://api.sandbox.dnsimple.com/"
|
13
|
+
config.token = "token-test-string"
|
13
14
|
config.http_proxy = nil
|
14
15
|
config.debug = false
|
15
16
|
end
|
16
17
|
|
17
18
|
WebMock.disable_net_connect!(allow: "codeclimate.com")
|
18
|
-
stub_request(:any, "#{DNSimpler.base_uri}
|
19
|
+
stub_request(:any, "#{DNSimpler.base_uri}domains").with(headers: {'Accept' => 'application/json', 'Authorization' => 'Bearer token-test-string', 'User-Agent' => "dnsimpler/#{DNSimpler::VERSION}"}).to_return(status: 200, body: {data: [{domain: {id: 707}}, {domain: {id: 708}}]}.to_json)
|
19
20
|
end
|
20
21
|
|
21
22
|
# Stolen from rails source cause I like the syntax
|
@@ -32,4 +33,4 @@ class MiniTest::Test
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsimpler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Westendorf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -85,11 +85,9 @@ files:
|
|
85
85
|
- lib/dnsimpler.rb
|
86
86
|
- lib/dnsimpler/error.rb
|
87
87
|
- lib/dnsimpler/http.rb
|
88
|
-
- lib/dnsimpler/try.rb
|
89
88
|
- lib/dnsimpler/version.rb
|
90
89
|
- test/dnsimpler/error_test.rb
|
91
90
|
- test/dnsimpler/http_test.rb
|
92
|
-
- test/dnsimpler/try_test.rb
|
93
91
|
- test/dnsimpler_test.rb
|
94
92
|
- test/test_helper.rb
|
95
93
|
homepage: ''
|
@@ -120,6 +118,5 @@ summary: A simple DNSimple API wrapper that always provides the response you're
|
|
120
118
|
test_files:
|
121
119
|
- test/dnsimpler/error_test.rb
|
122
120
|
- test/dnsimpler/http_test.rb
|
123
|
-
- test/dnsimpler/try_test.rb
|
124
121
|
- test/dnsimpler_test.rb
|
125
122
|
- test/test_helper.rb
|
data/lib/dnsimpler/try.rb
DELETED
data/test/dnsimpler/try_test.rb
DELETED