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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dfd4c62d32c8f73b4f3a6516efe07c1b4653f50
4
- data.tar.gz: 7db698ffaa50919b76cc593a79f3809bc6f671f1
3
+ metadata.gz: 8bfefdd5912cd681463438148356aa9f1d0d8363
4
+ data.tar.gz: 09f09c0510a514770a0ea1045ad8a454976b235f
5
5
  SHA512:
6
- metadata.gz: 521f570cc57fa3bcfa94eab4af094b64d63444c96ddcba4a136695254f3e5c44341964e10e42a7387567871c62c01b0ece00b56cbcd32e54aa3300d77bda98e9
7
- data.tar.gz: 25f3235571faf4917c2db72e1ea3f79a8acc0512ee1384f230907a441aca2ae8185cb004fd6e23358160abe5b3552c4202abe357178d6932cc4b2f3d6d678a79
6
+ metadata.gz: 2a29822652a7ba6fec690d041d06483b50c86d9793da1474b6ce61194586aff1aed70e6bec42f1d7aeda0ae0364f74c300835d445be542d1ca51c0b0e38b893b
7
+ data.tar.gz: a6a38ab577636192fc1a57d88561824a4a35f46e674d27c7b778290ccb6a1845020c3a676df78a0be0dd023467ee6b2b0b10d6d27e0688ff45aa79db00c60f4d
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  rvm:
2
- - 2.0.0
3
2
  - 2.1.0
4
- - 1.9.3
3
+ - 2.2.4
4
+ - 2.3.0
@@ -72,21 +72,27 @@ module CobotClient
72
72
  end
73
73
  end
74
74
 
75
- def rewrap_errors
76
- retries = 0
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
@@ -1,3 +1,3 @@
1
1
  module CobotClient
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
@@ -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.3
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-04 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus