cobot_client 1.2.3 → 1.2.4
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 -2
- data/lib/cobot_client/api_client.rb +17 -11
- data/lib/cobot_client/version.rb +1 -1
- data/spec/cobot_client/api_client_spec.rb +24 -0
- 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: 8bfefdd5912cd681463438148356aa9f1d0d8363
|
4
|
+
data.tar.gz: 09f09c0510a514770a0ea1045ad8a454976b235f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a29822652a7ba6fec690d041d06483b50c86d9793da1474b6ce61194586aff1aed70e6bec42f1d7aeda0ae0364f74c300835d445be542d1ca51c0b0e38b893b
|
7
|
+
data.tar.gz: a6a38ab577636192fc1a57d88561824a4a35f46e674d27c7b778290ccb6a1845020c3a676df78a0be0dd023467ee6b2b0b10d6d27e0688ff45aa79db00c60f4d
|
data/.travis.yml
CHANGED
@@ -72,21 +72,27 @@ module CobotClient
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def rewrap_errors
|
76
|
-
|
77
|
-
yield
|
78
|
-
rescue RestClient::BadGateway, SocketError => e
|
79
|
-
if retries < 3
|
80
|
-
sleep self.class.retry_time
|
81
|
-
retries += 1
|
82
|
-
retry
|
83
|
-
else
|
84
|
-
raise e
|
85
|
-
end
|
75
|
+
def rewrap_errors(&block)
|
76
|
+
retry_errors(&block)
|
86
77
|
rescue RestClient::Exception => e
|
87
78
|
fail CobotClient::Exceptions::EXCEPTIONS_MAP[e.class].new(e.response)
|
88
79
|
end
|
89
80
|
|
81
|
+
def retry_errors
|
82
|
+
retries = 0
|
83
|
+
begin
|
84
|
+
yield
|
85
|
+
rescue RestClient::BadGateway, SocketError, RestClient::RequestTimeout => e
|
86
|
+
if retries < 3
|
87
|
+
sleep self.class.retry_time
|
88
|
+
retries += 1
|
89
|
+
retry
|
90
|
+
else
|
91
|
+
raise e
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
90
96
|
def parse_args(*args)
|
91
97
|
if args.last.is_a?(Hash)
|
92
98
|
params = args.pop
|
data/lib/cobot_client/version.rb
CHANGED
@@ -191,6 +191,30 @@ describe CobotClient::ApiClient do
|
|
191
191
|
end.to raise_error(CobotClient::ResourceNotFound)
|
192
192
|
end
|
193
193
|
|
194
|
+
it 'retries a RestClient::RequestTimeout' do
|
195
|
+
count = 0
|
196
|
+
allow(RestClient).to receive(:get) do
|
197
|
+
if count == 0
|
198
|
+
count += 1
|
199
|
+
fail RestClient::RequestTimeout
|
200
|
+
else
|
201
|
+
double(:response, body: '{}')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
expect(RestClient).to receive(:get).exactly(2).times
|
206
|
+
|
207
|
+
api_client.get('co-up', '/invoices')
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'converts a RestClient::RequestTimeout into a CobotClient::RequestTimeout' do
|
211
|
+
allow(RestClient).to receive(:get).and_raise(RestClient::RequestTimeout)
|
212
|
+
|
213
|
+
expect do
|
214
|
+
api_client.get('co-up', '/invoices')
|
215
|
+
end.to raise_error(CobotClient::RequestTimeout)
|
216
|
+
end
|
217
|
+
|
194
218
|
it 'includes the response, http code and http body in the exception' do
|
195
219
|
response = double(:response, code: 404, body: 'boom')
|
196
220
|
error = RestClient::ResourceNotFound.new(response)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobot_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|