nationbuilder-rb 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -45
- data/README.md +9 -0
- data/Rakefile +0 -14
- data/lib/nationbuilder.rb +1 -0
- data/lib/nationbuilder/client.rb +2 -1
- data/lib/nationbuilder/version.rb +5 -0
- data/nationbuilder-rb.gemspec +7 -11
- data/spec/lib/nationbuilder/client_spec.rb +23 -5
- metadata +7 -7
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5dbf155a35ce3dc4e6e6a589a2e21ee3cc72c8a
|
4
|
+
data.tar.gz: fa021eae289bd54ce766f9830c8209d9945fbf86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c52251b51f1f8e525d18bfd7bf3875a480a525a32176441c6770bbe300ac5e532aa5d84aecb0cdacb2dde1f6aca278482f74a99c797b8877183e985e9d7f7df
|
7
|
+
data.tar.gz: 5391541f46bc04bad1e0e7eab1332094b52c917f3d2b7c4d30a4bca22aca0591b8c770e9266c52fa03e3445e92e9c2c48a7165a9ccb3189ec292dcb9a4e0de33
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,54 +2,13 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
addressable (2.3.7)
|
5
|
-
builder (3.2.2)
|
6
5
|
crack (0.4.2)
|
7
6
|
safe_yaml (~> 1.0.0)
|
8
|
-
descendants_tracker (0.0.4)
|
9
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
10
7
|
diff-lcs (1.2.5)
|
11
8
|
docile (1.1.5)
|
12
|
-
faraday (0.9.1)
|
13
|
-
multipart-post (>= 1.2, < 3)
|
14
|
-
git (1.2.9.1)
|
15
|
-
github_api (0.12.3)
|
16
|
-
addressable (~> 2.3)
|
17
|
-
descendants_tracker (~> 0.0.4)
|
18
|
-
faraday (~> 0.8, < 0.10)
|
19
|
-
hashie (>= 3.3)
|
20
|
-
multi_json (>= 1.7.5, < 2.0)
|
21
|
-
nokogiri (~> 1.6.3)
|
22
|
-
oauth2
|
23
|
-
hashie (3.4.0)
|
24
|
-
highline (1.6.21)
|
25
9
|
httpclient (2.7.0.1)
|
26
|
-
jeweler (2.0.1)
|
27
|
-
builder
|
28
|
-
bundler (>= 1.0)
|
29
|
-
git (>= 1.2.5)
|
30
|
-
github_api
|
31
|
-
highline (>= 1.6.15)
|
32
|
-
nokogiri (>= 1.5.10)
|
33
|
-
rake
|
34
|
-
rdoc
|
35
|
-
json (1.8.2)
|
36
|
-
jwt (1.2.1)
|
37
|
-
mini_portile2 (2.0.0)
|
38
10
|
multi_json (1.10.1)
|
39
|
-
|
40
|
-
multipart-post (2.0.0)
|
41
|
-
nokogiri (1.6.7.2)
|
42
|
-
mini_portile2 (~> 2.0.0.rc2)
|
43
|
-
oauth2 (1.0.0)
|
44
|
-
faraday (>= 0.8, < 0.10)
|
45
|
-
jwt (~> 1.0)
|
46
|
-
multi_json (~> 1.3)
|
47
|
-
multi_xml (~> 0.5)
|
48
|
-
rack (~> 1.2)
|
49
|
-
rack (1.6.4)
|
50
|
-
rake (10.4.2)
|
51
|
-
rdoc (4.2.0)
|
52
|
-
json (~> 1.4)
|
11
|
+
rake (10.5.0)
|
53
12
|
rspec (3.2.0)
|
54
13
|
rspec-core (~> 3.2.0)
|
55
14
|
rspec-expectations (~> 3.2.0)
|
@@ -69,7 +28,6 @@ GEM
|
|
69
28
|
multi_json (~> 1.0)
|
70
29
|
simplecov-html (~> 0.8.0)
|
71
30
|
simplecov-html (0.8.0)
|
72
|
-
thread_safe (0.3.4)
|
73
31
|
vcr (2.9.3)
|
74
32
|
webmock (1.20.4)
|
75
33
|
addressable (>= 2.3.6)
|
@@ -80,11 +38,11 @@ PLATFORMS
|
|
80
38
|
|
81
39
|
DEPENDENCIES
|
82
40
|
httpclient (~> 2.7)
|
83
|
-
|
41
|
+
rake (~> 10.4)
|
84
42
|
rspec (~> 3.2)
|
85
43
|
simplecov (~> 0.8)
|
86
44
|
vcr (~> 2.9)
|
87
45
|
webmock (~> 1.18)
|
88
46
|
|
89
47
|
BUNDLED WITH
|
90
|
-
1.
|
48
|
+
1.13.6
|
data/README.md
CHANGED
@@ -123,6 +123,15 @@ Endpoint: basic_pages
|
|
123
123
|
...
|
124
124
|
```
|
125
125
|
|
126
|
+
## Modifying the underlying HTTPClient
|
127
|
+
|
128
|
+
The `NationBuilder::Client` object can use a provided [HTTPClient](http://www.rubydoc.info/gems/httpclient/frames) object if you need some customizations, such as to enable logging, change TLS settings, or add a proxy. For example to force a proxy for all traffic:
|
129
|
+
|
130
|
+
```Ruby
|
131
|
+
httpclient = HTTPClient.new('http://myproxy:8080')
|
132
|
+
client = NationBuilder::Client.new(nation_builder_slug, nation_builder_auth_token, retries: 8, http_client: httpclient)
|
133
|
+
```
|
134
|
+
|
126
135
|
## Development
|
127
136
|
|
128
137
|
To update the API specification that powers this client, first make
|
data/Rakefile
CHANGED
@@ -1,19 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require 'jeweler'
|
4
|
-
|
5
|
-
Jeweler::Tasks.new do |gem|
|
6
|
-
gem.name = 'nationbuilder-rb'
|
7
|
-
gem.homepage = 'http://github.com/nationbuilder/nationbuilder-rb'
|
8
|
-
gem.license = 'MIT'
|
9
|
-
gem.summary = 'A Ruby client to the NationBuilder API'
|
10
|
-
gem.description = 'A Ruby client to the NationBuilder API'
|
11
|
-
gem.email = 'schmitt@nationbuilder.com'
|
12
|
-
gem.authors = ['David Huie', 'Alexandre Schmitt']
|
13
|
-
end
|
14
|
-
|
15
|
-
Jeweler::RubygemsDotOrgTasks.new
|
16
|
-
|
17
3
|
require 'rspec/core'
|
18
4
|
require 'rspec/core/rake_task'
|
19
5
|
|
data/lib/nationbuilder.rb
CHANGED
data/lib/nationbuilder/client.rb
CHANGED
@@ -6,6 +6,7 @@ class NationBuilder::Client
|
|
6
6
|
@name_to_endpoint = {}
|
7
7
|
@base_url = opts[:base_url] || 'https://:nation_name.nationbuilder.com'
|
8
8
|
@retries = opts[:retries] || 8
|
9
|
+
@http_client = opts[:http_client] || HTTPClient.new
|
9
10
|
|
10
11
|
if @retries < 0
|
11
12
|
raise 'Retries must be at least zero'
|
@@ -81,7 +82,7 @@ class NationBuilder::Client
|
|
81
82
|
|
82
83
|
(@retries + 1).times do |i|
|
83
84
|
begin
|
84
|
-
raw_response =
|
85
|
+
raw_response = @http_client.send(method, url, request_args)
|
85
86
|
parsed_response = parse_response_body(raw_response)
|
86
87
|
rescue NationBuilder::RateLimitedError => e
|
87
88
|
exception_to_reraise = e
|
data/nationbuilder-rb.gemspec
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: nationbuilder-rb 1.4.2 ruby lib
|
1
|
+
require './lib/nationbuilder/version'
|
6
2
|
|
7
3
|
Gem::Specification.new do |s|
|
8
4
|
s.name = "nationbuilder-rb"
|
9
|
-
s.version =
|
5
|
+
s.version = NationBuilder::VERSION
|
10
6
|
|
11
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
8
|
s.require_paths = ["lib"]
|
13
9
|
s.authors = ["David Huie", "Alexandre Schmitt"]
|
14
|
-
s.date = "2016-
|
10
|
+
s.date = "2016-12-06"
|
15
11
|
s.description = "A Ruby client to the NationBuilder API"
|
16
12
|
s.email = "schmitt@nationbuilder.com"
|
17
13
|
s.executables = ["nbdoc"]
|
@@ -31,7 +27,6 @@ Gem::Specification.new do |s|
|
|
31
27
|
"LICENSE.txt",
|
32
28
|
"README.md",
|
33
29
|
"Rakefile",
|
34
|
-
"VERSION",
|
35
30
|
"bin/nbdoc",
|
36
31
|
"lib/api_spec/.ruby-gemset",
|
37
32
|
"lib/api_spec/.ruby-version",
|
@@ -73,6 +68,7 @@ Gem::Specification.new do |s|
|
|
73
68
|
"lib/nationbuilder/parameter.rb",
|
74
69
|
"lib/nationbuilder/spec_parser.rb",
|
75
70
|
"lib/nationbuilder/url.rb",
|
71
|
+
"lib/nationbuilder/version.rb",
|
76
72
|
"nationbuilder-rb.gemspec",
|
77
73
|
"spec/fixtures/delete.yml",
|
78
74
|
"spec/fixtures/paginated_get_page2.yml",
|
@@ -95,14 +91,14 @@ Gem::Specification.new do |s|
|
|
95
91
|
|
96
92
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
97
93
|
s.add_runtime_dependency(%q<httpclient>, ["~> 2.7"])
|
98
|
-
s.add_development_dependency(%q<
|
94
|
+
s.add_development_dependency(%q<rake>, ["~> 10.4"])
|
99
95
|
s.add_development_dependency(%q<rspec>, ["~> 3.2"])
|
100
96
|
s.add_development_dependency(%q<simplecov>, ["~> 0.8"])
|
101
97
|
s.add_development_dependency(%q<vcr>, ["~> 2.9"])
|
102
98
|
s.add_development_dependency(%q<webmock>, ["~> 1.18"])
|
103
99
|
else
|
104
100
|
s.add_dependency(%q<httpclient>, ["~> 2.7"])
|
105
|
-
s.add_dependency(%q<
|
101
|
+
s.add_dependency(%q<rake>, ["~> 10.4"])
|
106
102
|
s.add_dependency(%q<rspec>, ["~> 3.2"])
|
107
103
|
s.add_dependency(%q<simplecov>, ["~> 0.8"])
|
108
104
|
s.add_dependency(%q<vcr>, ["~> 2.9"])
|
@@ -110,7 +106,7 @@ Gem::Specification.new do |s|
|
|
110
106
|
end
|
111
107
|
else
|
112
108
|
s.add_dependency(%q<httpclient>, ["~> 2.7"])
|
113
|
-
s.add_dependency(%q<
|
109
|
+
s.add_dependency(%q<rake>, ["~> 10.4"])
|
114
110
|
s.add_dependency(%q<rspec>, ["~> 3.2"])
|
115
111
|
s.add_dependency(%q<simplecov>, ["~> 0.8"])
|
116
112
|
s.add_dependency(%q<vcr>, ["~> 2.9"])
|
@@ -9,6 +9,18 @@ describe NationBuilder::Client do
|
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
12
|
+
describe '#initialize' do
|
13
|
+
describe 'with a provided httpclient' do
|
14
|
+
let(:httpclient) { double('HTTPClient') }
|
15
|
+
|
16
|
+
subject { described_class.new('slug', 'token', http_client: httpclient) }
|
17
|
+
|
18
|
+
it 'uses the provided client instead of a new one' do
|
19
|
+
expect(subject.instance_variable_get(:@http_client)).to be(httpclient)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
12
24
|
describe '#endpoints' do
|
13
25
|
|
14
26
|
it 'should contain all defined endpoints' do
|
@@ -144,16 +156,22 @@ describe NationBuilder::Client do
|
|
144
156
|
end
|
145
157
|
|
146
158
|
describe '#perform_request_with_retries' do
|
147
|
-
|
148
|
-
|
159
|
+
let(:httpclient) { double('HTTPClient') }
|
160
|
+
|
161
|
+
before do
|
162
|
+
allow(HTTPClient).to receive(:new).and_return(httpclient)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should reraise non-rate limiting execeptions' do
|
166
|
+
expect(httpclient).to receive(:send)
|
149
167
|
expect(client).to receive(:parse_response_body) { raise StandardError.new('boom') }
|
150
168
|
expect do
|
151
169
|
client.perform_request_with_retries(nil, nil, nil)
|
152
|
-
end.to raise_error
|
170
|
+
end.to raise_error(StandardError)
|
153
171
|
end
|
154
172
|
|
155
173
|
it 'should return a response if the rate limit is eventually dropped' do
|
156
|
-
expect(
|
174
|
+
expect(httpclient).to receive(:send).twice
|
157
175
|
expect(Kernel).to receive(:sleep)
|
158
176
|
|
159
177
|
allow(client).to receive(:parse_response_body) do
|
@@ -174,7 +192,7 @@ describe NationBuilder::Client do
|
|
174
192
|
end
|
175
193
|
|
176
194
|
it 'on the last retry, it should reraise the rate limiting exception ' do
|
177
|
-
expect(
|
195
|
+
expect(httpclient).to receive(:send).twice
|
178
196
|
expect(Kernel).to receive(:sleep).twice
|
179
197
|
|
180
198
|
allow(client).to receive(:parse_response_body) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nationbuilder-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Huie
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
@@ -26,19 +26,19 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '2.7'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '10.4'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '10.4'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +115,6 @@ files:
|
|
115
115
|
- LICENSE.txt
|
116
116
|
- README.md
|
117
117
|
- Rakefile
|
118
|
-
- VERSION
|
119
118
|
- bin/nbdoc
|
120
119
|
- lib/api_spec/.ruby-gemset
|
121
120
|
- lib/api_spec/.ruby-version
|
@@ -157,6 +156,7 @@ files:
|
|
157
156
|
- lib/nationbuilder/parameter.rb
|
158
157
|
- lib/nationbuilder/spec_parser.rb
|
159
158
|
- lib/nationbuilder/url.rb
|
159
|
+
- lib/nationbuilder/version.rb
|
160
160
|
- nationbuilder-rb.gemspec
|
161
161
|
- spec/fixtures/delete.yml
|
162
162
|
- spec/fixtures/paginated_get_page2.yml
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.5.2
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: A Ruby client to the NationBuilder API
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.4.3
|