global_registry 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/global_registry/base.rb +12 -8
- data/lib/global_registry/version.rb +1 -1
- data/spec/base_spec.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c1da68dc3d18b0e400a36959cc3490b8305854e
|
4
|
+
data.tar.gz: 1bcf5038d5945ea5f38ac765e8fd33df78519156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a24e9f1d705dae61f8f0927c2aab03aa27e7c728dc939140693b3e407c014d6cc79709dab665fd8849f0d8ff2bf053e35bf19591022bbe6430a8d3bc7b19159
|
7
|
+
data.tar.gz: 3da71e5ad1571c46d787ee3b172c6060eb1a5d87cbe3dfc387eff81898b6028f6cb6c038015c0a5f299de43edb56180674cb5662e1cce668a7ea3a8a3a20392f
|
data/lib/global_registry/base.rb
CHANGED
@@ -64,25 +64,29 @@ module GlobalRegistry
|
|
64
64
|
def request(method, params, path = nil, headers = {})
|
65
65
|
raise 'You need to configure GlobalRegistry with your access_token.' unless access_token
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
url = if base_url.starts_with? 'http'
|
68
|
+
Addressable::URI.parse(base_url)
|
69
|
+
else
|
70
|
+
Addressable::URI.parse("http://#{base_url}")
|
71
|
+
end
|
72
|
+
url.path = path || default_path
|
73
|
+
url.query_values = headers.delete(:params) if headers[:params]
|
71
74
|
|
72
75
|
case method
|
73
76
|
when :post
|
74
77
|
post_headers = default_headers.merge(content_type: :json, timeout: -1).merge(headers)
|
75
|
-
RestClient.post(url, params.to_json, post_headers) { |response, request, result, &block|
|
78
|
+
RestClient.post(url.to_s, params.to_json, post_headers) { |response, request, result, &block|
|
76
79
|
handle_response(response, request, result)
|
77
80
|
}
|
78
81
|
when :put
|
79
82
|
put_headers = default_headers.merge(content_type: :json, timeout: -1).merge(headers)
|
80
|
-
RestClient.put(url, params.to_json, put_headers) { |response, request, result, &block|
|
83
|
+
RestClient.put(url.to_s, params.to_json, put_headers) { |response, request, result, &block|
|
81
84
|
handle_response(response, request, result)
|
82
85
|
}
|
83
86
|
else
|
84
|
-
|
85
|
-
|
87
|
+
url.query_values = (url.query_values || {}).merge(params) if params.any?
|
88
|
+
get_args = { method: method, url: url.to_s, timeout: -1,
|
89
|
+
headers: default_headers.merge(headers)
|
86
90
|
}
|
87
91
|
RestClient::Request.execute(get_args) { |response, request, result, &block|
|
88
92
|
handle_response(response, request, result)
|
data/spec/base_spec.rb
CHANGED
@@ -14,13 +14,21 @@ describe 'Base' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'can be configured' do
|
17
|
-
@custom_gr_url = stub_request(:get, '
|
17
|
+
@custom_gr_url = stub_request(:get, 'https://cru.org/bases')
|
18
18
|
.with(headers: { authorization: 'Bearer qwer',
|
19
19
|
'X-Forwarded-For': '203.0.113.7' })
|
20
20
|
.to_return(:body => {a: 'b'}.to_json)
|
21
|
-
gr = GlobalRegistry::Base.new(access_token: 'qwer', base_url: 'cru.org', xff: '203.0.113.7')
|
21
|
+
gr = GlobalRegistry::Base.new(access_token: 'qwer', base_url: 'https://cru.org', xff: '203.0.113.7')
|
22
22
|
expect(gr.get).to be_a Hash
|
23
23
|
expect(@custom_gr_url).to have_been_requested
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
describe '#find' do
|
28
|
+
it 'correctly handles array params' do
|
29
|
+
@custom_gr_url = stub_request(:get, 'http://google.com/bases/1?a[]=b&a[]=c')
|
30
|
+
GlobalRegistry::Base.find(1, 'a[]': ['b','c'])
|
31
|
+
expect(@custom_gr_url).to have_been_requested
|
32
|
+
end
|
33
|
+
end
|
26
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global_registry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Starcher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|