pluct 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/pluct/helpers/request.rb +9 -9
- data/lib/pluct/version.rb +1 -1
- data/spec/pluct/helpers/request_spec.rb +3 -4
- data/spec/pluct/resource_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDY3YjZlZThiYzg5NWQ3ZDFmNjA4N2ExMzU2YmMyM2QwNjliZmUyZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Nzc1MjIxZGYzNTE3YWRkNTc2OGJlOTIwMDU4ODhjODcyYTEwNTBkOQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2VhNTAwODVkYjM3YTg0NDhmZjZkNDIyYzBlZTRkMzQ2ZTBiODRhNjNlNDMy
|
10
|
+
YzNiNjkyNWVjYmE1NGUyMTcyZTNlYTE3YWQ2Y2FjM2E5MTEwYWY5NTM1NGNj
|
11
|
+
M2FkYzQ1MmJkYjBhZGE4YTU1YjRhNTkxMjYzYTI0Njg0MDkwMzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzgyY2VkYjZlNjRjZWJmMDExZjllNzUzYjBkMTBhNzI1N2Y1ZDA2MjhkZWNj
|
14
|
+
MDNlOWUxMzgzNGEyYzQ3NzlmY2RmOGNiNjA1OGQzOTk1MGMzYjFlMWViYjg5
|
15
|
+
OTE0ZmVkYzE1NTJiODVkYzU0ZTNlM2ViMjMwYTY2MzcxY2VhNjI=
|
@@ -14,7 +14,7 @@ module Pluct
|
|
14
14
|
options = (options ? DEFAULT_HEADERS.merge(options) : DEFAULT_HEADERS)
|
15
15
|
resource.get(options)
|
16
16
|
rescue RestClient::Exception => e
|
17
|
-
raise_exception(e)
|
17
|
+
raise_exception(url, e)
|
18
18
|
end
|
19
19
|
|
20
20
|
def head(url, *opts)
|
@@ -23,7 +23,7 @@ module Pluct
|
|
23
23
|
options = (options ? DEFAULT_HEADERS.merge(options) : DEFAULT_HEADERS)
|
24
24
|
resource.head(options)
|
25
25
|
rescue RestClient::Exception => e
|
26
|
-
raise_exception(e)
|
26
|
+
raise_exception(url, e)
|
27
27
|
end
|
28
28
|
|
29
29
|
def delete(url, *opts)
|
@@ -32,7 +32,7 @@ module Pluct
|
|
32
32
|
options = (options ? DEFAULT_HEADERS.merge(options) : DEFAULT_HEADERS)
|
33
33
|
resource.delete(options)
|
34
34
|
rescue RestClient::Exception => e
|
35
|
-
raise_exception(e)
|
35
|
+
raise_exception(url, e)
|
36
36
|
end
|
37
37
|
|
38
38
|
def post(url, *opts)
|
@@ -42,7 +42,7 @@ module Pluct
|
|
42
42
|
options = (options ? DEFAULT_HEADERS.merge(options) : DEFAULT_HEADERS)
|
43
43
|
resource.post(data.to_json, options)
|
44
44
|
rescue RestClient::Exception => e
|
45
|
-
raise_exception(e)
|
45
|
+
raise_exception(url, e)
|
46
46
|
end
|
47
47
|
|
48
48
|
def put(url, *opts)
|
@@ -52,7 +52,7 @@ module Pluct
|
|
52
52
|
options = (options ? DEFAULT_HEADERS.merge(options) : DEFAULT_HEADERS)
|
53
53
|
resource.put(data.to_json, options)
|
54
54
|
rescue RestClient::Exception => e
|
55
|
-
raise_exception(e)
|
55
|
+
raise_exception(url, e)
|
56
56
|
end
|
57
57
|
|
58
58
|
def patch(url, *opts)
|
@@ -62,16 +62,16 @@ module Pluct
|
|
62
62
|
options = (options ? DEFAULT_HEADERS.merge(options) : DEFAULT_HEADERS)
|
63
63
|
resource.patch(data.to_json, options)
|
64
64
|
rescue RestClient::Exception => e
|
65
|
-
raise_exception(e)
|
65
|
+
raise_exception(url, e)
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
|
-
def raise_exception(exception)
|
69
|
+
def raise_exception(url, exception)
|
70
70
|
case exception.http_code
|
71
71
|
when 401
|
72
|
-
raise Pluct::Errors::Unauthorized, {http_code: 401, error_description: exception.
|
72
|
+
raise Pluct::Errors::Unauthorized, {http_code: 401, error_description: "Url: #{url} - Exception Message: #{exception.message}"}
|
73
73
|
when 404
|
74
|
-
raise Pluct::Errors::UrlNotFound, {http_code: 404, error_description: exception.
|
74
|
+
raise Pluct::Errors::UrlNotFound, {http_code: 404, error_description: "Url: #{url} - Exception Message: #{exception.message}"}
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/lib/pluct/version.rb
CHANGED
@@ -8,15 +8,14 @@ describe Pluct::Helpers::Request do
|
|
8
8
|
let(:client) { Client.new }
|
9
9
|
|
10
10
|
request = [
|
11
|
-
{ http_code: 401,
|
12
|
-
{ http_code: 404,
|
11
|
+
{ http_code: 401, message: '401 Unauthorized', url: 'http://www.example.com/unauthorized', exception: Pluct::Errors::Unauthorized },
|
12
|
+
{ http_code: 404, message: '404 Resource Not Found', url: 'http://www.example.com/invalid-url', exception: Pluct::Errors::UrlNotFound},
|
13
13
|
]
|
14
14
|
|
15
15
|
request.each do |req|
|
16
16
|
it "raises an exception #{req[:http_code]}" do
|
17
17
|
stub_request(:get, req[:url]).to_return(body: req[:body], status: req[:http_code])
|
18
|
-
|
19
|
-
expect { client.send(:get, req[:url]) }.to raise_exception(req[:exception], {http_code: req[:http_code], error_description: req[:body]})
|
18
|
+
expect { client.send(:get, req[:url]) }.to raise_exception(req[:exception], {http_code: req[:http_code], error_description: "Url: #{req[:url]} - Exception Message: #{req[:message]}"})
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
data/spec/pluct/resource_spec.rb
CHANGED