nationbuilder-rb 1.3.1 → 1.3.2

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: c5c62829ecbd0990f8fd4860b910df7553ea5c15
4
- data.tar.gz: 026d923800c4985952d4a37c389d5bbdfaf96f3a
3
+ metadata.gz: a2a9e95e72f4cd31b317649c6542b23341ced9d4
4
+ data.tar.gz: 9151348b994b64949318fe8dd7de00d695c872ff
5
5
  SHA512:
6
- metadata.gz: d86bd8926ae26c03477dc0259ac064eef739546b4bdc3700470a2e66af61b52b5eb659f95d0bb43b7ff22fb442ee1cd3de2ed52384a5a7e09eedd663773c4fee
7
- data.tar.gz: b07d522bf665d40727fa7661d79a7085821a7d225aeeffb90a81a0eb572929341bb79cf2fe04fd19e1c572209516798c184077088babf5e699bc42448d168bb0
6
+ metadata.gz: 5f36cae292f6a27e6ba670f6afcc04fab0baa13e8e17fa63182338ebce404430c8c192a45ce58cf5db9b048fd5389ac7b2e62b3164c19a4b48a7b4b0ff1fc0f2
7
+ data.tar.gz: 19b7ba8cb1264bce42ddc1c51898aa93d43c94c9549b3c6fbd06e98deede47316e760c8d1f9fd51fa5494ec746861a3e580e37a68bf7de7cabef28f33885ad93
@@ -1,3 +1,8 @@
1
+ # 1.3.2
2
+ - When retrying requests, the request is actually resent instead
3
+ of just reparsing the response
4
+ - [#12] Raise an error if the last API request retry is rate limited
5
+
1
6
  # 1.3
2
7
  - [#10] Support fire_webhooks parameter in client
3
8
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nationbuilder-rb
2
2
 
3
- [![Build Status](https://travis-ci.org/3dna/nationbuilder-rb.svg?branch=master)](https://travis-ci.org/3dna/nationbuilder-rb)
3
+ [![Build Status](https://travis-ci.org/nationbuilder/nationbuilder-rb.svg?branch=master)](https://travis-ci.org/nationbuilder/nationbuilder-rb)
4
4
 
5
5
  A Ruby client for the NationBuilder API.
6
6
 
@@ -15,7 +15,7 @@ $ gem install nationbuilder-rb
15
15
  Or, add this to your gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'nationbuilder-rb', :require => 'nationbuilder'
18
+ gem 'nationbuilder-rb', require: 'nationbuilder'
19
19
  ```
20
20
 
21
21
  ## Creating a client
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -75,21 +75,30 @@ class NationBuilder::Client
75
75
  end
76
76
 
77
77
  def perform_request_with_retries(method, url, request_args)
78
- raw_response = HTTPClient.send(method, url, request_args)
78
+ raw_response = nil
79
79
  parsed_response = nil
80
+ exception_to_reraise = nil
80
81
 
81
82
  (@retries + 1).times do |i|
82
83
  begin
84
+ raw_response = HTTPClient.send(method, url, request_args)
83
85
  parsed_response = parse_response_body(raw_response)
84
- rescue NationBuilder::RateLimitedError
86
+ rescue NationBuilder::RateLimitedError => e
87
+ exception_to_reraise = e
85
88
  Kernel.sleep(RETRY_DELAY * 2**i)
86
89
  rescue => e
87
90
  raise e
88
91
  else
92
+ exception_to_reraise = nil
89
93
  break
90
94
  end
91
95
  end
92
96
 
97
+ # If the retry cycle ended with an error, reraise it
98
+ if exception_to_reraise
99
+ raise exception_to_reraise
100
+ end
101
+
93
102
  set_response(raw_response)
94
103
  parsed_response
95
104
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: nationbuilder-rb 1.3.1 ruby lib
5
+ # stub: nationbuilder-rb 1.3.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "nationbuilder-rb"
9
- s.version = "1.3.1"
9
+ s.version = "1.3.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["David Huie"]
14
- s.date = "2015-04-06"
14
+ s.date = "2015-04-09"
15
15
  s.description = "A Ruby client to the NationBuilder API"
16
16
  s.email = "david@nationbuilder.com"
17
17
  s.executables = ["nbdoc"]
@@ -56,7 +56,7 @@ Gem::Specification.new do |s|
56
56
  ]
57
57
  s.homepage = "http://github.com/nationbuilder/nationbuilder-rb"
58
58
  s.licenses = ["MIT"]
59
- s.rubygems_version = "2.2.2"
59
+ s.rubygems_version = "2.4.6"
60
60
  s.summary = "A Ruby client to the NationBuilder API"
61
61
 
62
62
  if s.respond_to? :specification_version then
@@ -139,11 +139,8 @@ describe NationBuilder::Client do
139
139
  end
140
140
 
141
141
  describe '#perform_request_with_retries' do
142
- before do
143
- expect(HTTPClient).to receive(:send)
144
- end
145
-
146
142
  it 'should raise non-rate limiting execeptions' do
143
+ expect(HTTPClient).to receive(:send)
147
144
  expect(client).to receive(:parse_response_body) { raise StandardError.new('boom') }
148
145
  expect do
149
146
  client.perform_request_with_retries(nil, nil, nil)
@@ -151,16 +148,37 @@ describe NationBuilder::Client do
151
148
  end
152
149
 
153
150
  it 'should return a response if the rate limit is eventually dropped' do
154
- expect(Kernel).to receive(:sleep).twice
151
+ expect(HTTPClient).to receive(:send).twice
152
+ expect(Kernel).to receive(:sleep)
153
+
155
154
  allow(client).to receive(:parse_response_body) do
156
- @count ||= 0
157
- if @count != 2
155
+ unless @count
156
+ @count ||= 0
157
+ else
158
+ @count += 1
159
+ end
160
+
161
+ if @count < 1
158
162
  raise NationBuilder::RateLimitedError.new
159
163
  end
160
164
  end
165
+
161
166
  expect do
162
167
  client.perform_request_with_retries(nil, nil, nil)
163
168
  end.to_not raise_error
164
169
  end
170
+
171
+ it 'on the last retry, it should reraise the rate limiting exception ' do
172
+ expect(HTTPClient).to receive(:send).twice
173
+ expect(Kernel).to receive(:sleep).twice
174
+
175
+ allow(client).to receive(:parse_response_body) do
176
+ raise NationBuilder::RateLimitedError.new
177
+ end
178
+
179
+ expect do
180
+ client.perform_request_with_retries(nil, nil, nil)
181
+ end.to raise_error(NationBuilder::RateLimitedError)
182
+ end
165
183
  end
166
184
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nationbuilder-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Huie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.2.2
159
+ rubygems_version: 2.4.6
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: A Ruby client to the NationBuilder API