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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmU0ZmVmMzA3ZjZjNzI3MzViZTMzNGI0ZjhkNmI4MWMyMTQ5ZjBjNg==
4
+ ZDY3YjZlZThiYzg5NWQ3ZDFmNjA4N2ExMzU2YmMyM2QwNjliZmUyZQ==
5
5
  data.tar.gz: !binary |-
6
- MzdlZmFiMThhY2E1YjY5NTUyNmVmZjU3OTI0ZGM4ODg4MzkwOTY2NQ==
6
+ Nzc1MjIxZGYzNTE3YWRkNTc2OGJlOTIwMDU4ODhjODcyYTEwNTBkOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDRlYmU2ZDVjMGRjNjQ5ODMyNzIwZmQ4NjUwYjYxZDA5MWY4MDJhYWM3ZWQ2
10
- MzE5ZWQxMjY1ZGJiZDhkYzAxY2JmOTdiYWQ0ZTA5YzE2ZDM3NThiOTEyYjhl
11
- NTljNTY2NGNmODYwYTJmMGUwZjgyZGQ2ODBhMmViZmY4Y2U5YmY=
9
+ Y2VhNTAwODVkYjM3YTg0NDhmZjZkNDIyYzBlZTRkMzQ2ZTBiODRhNjNlNDMy
10
+ YzNiNjkyNWVjYmE1NGUyMTcyZTNlYTE3YWQ2Y2FjM2E5MTEwYWY5NTM1NGNj
11
+ M2FkYzQ1MmJkYjBhZGE4YTU1YjRhNTkxMjYzYTI0Njg0MDkwMzY=
12
12
  data.tar.gz: !binary |-
13
- ZGRlMDlkMzgyZGRlYmUyYTVkNjFiZWM5ZTIwMDVmN2FiODVkMjIyNDg5YWM3
14
- MGUwMWIwMGY4NDdhMTViMmY3MDhiZTNiZjdjY2VmZjIwNmJlMGUwZDRkNTNk
15
- NmNkZTIwMGI2YjUwNDE0YzlmNGFmNjkxOWQxMzdkZjk1NTlmYjU=
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.http_body}
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.http_body}
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
@@ -1,3 +1,3 @@
1
1
  module Pluct
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -8,15 +8,14 @@ describe Pluct::Helpers::Request do
8
8
  let(:client) { Client.new }
9
9
 
10
10
  request = [
11
- { http_code: 401, body: 'Unauthorized.', url: 'http://www.example.com/unauthorized', exception: Pluct::Errors::Unauthorized },
12
- { http_code: 404, body: 'Not found.', url: 'http://www.example.com/invalid-url', exception: Pluct::Errors::UrlNotFound},
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
- # expect { client.get req[:url] }.to raise_exception(req[:exception], {http_code: req[:http_code], error_description: req[:body]})
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
 
@@ -43,6 +43,7 @@ describe Pluct::Resource do
43
43
  expect(resource.class.instance_methods(false)).to include(method)
44
44
  end
45
45
  end
46
+
46
47
  end
47
48
 
48
49
  context 'invalid header' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alberto Leal