nation_builder 0.0.1 → 0.0.3
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 +3 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +19 -9
- data/README.md +11 -4
- data/VERSION +1 -1
- data/lib/nation_builder/client.rb +25 -5
- data/lib/nation_builder/people.rb +18 -1
- data/nation_builder.gemspec +8 -2
- data/spec/client_spec.rb +5 -0
- data/spec/nation_builder_spec.rb +6 -3
- data/spec/people_spec.rb +5 -0
- data/spec/spec_helper.rb +35 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a690f247d652e6ed9c0e73f98f67b7798c26089e
|
4
|
+
data.tar.gz: 4ce029e2e0c9b06ec46421e0e5aaf2054979d77d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2804a14221e6ac4531845e88702679a85990ab99657f1b4a52fa82f1c1f3e76bda281fb673a03e7081825a0761c8a10b1320dd793963d00904fe49a64b1b5419
|
7
|
+
data.tar.gz: 1de559e31f2125e456b656b828b21edd6e08cc02a575cbf96e922e9ca03e8df1f30e3d83e978bddd97000c996ef5618a174d85c0fa889cf7cead387587680e63
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
3
|
+
# NationBuilder puts error messages in a different location.
|
4
|
+
gem 'oauth2', git: 'https://github.com/controlshift/oauth2.git'
|
4
5
|
|
5
6
|
group :development do
|
7
|
+
gem 'webmock'
|
6
8
|
gem 'pry'
|
7
9
|
gem 'pry-debugger'
|
8
10
|
gem "rspec"
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/controlshift/oauth2.git
|
3
|
+
revision: 7e60e15878e503f80c8708f5c2cca5d17664fc61
|
4
|
+
specs:
|
5
|
+
oauth2 (0.9.2)
|
6
|
+
faraday (~> 0.8)
|
7
|
+
jwt (~> 0.1.4)
|
8
|
+
multi_json (~> 1.0)
|
9
|
+
multi_xml (~> 0.5)
|
10
|
+
rack (~> 1.2)
|
11
|
+
|
1
12
|
GEM
|
2
13
|
remote: http://rubygems.org/
|
3
14
|
specs:
|
@@ -5,6 +16,8 @@ GEM
|
|
5
16
|
builder (3.2.2)
|
6
17
|
coderay (1.0.9)
|
7
18
|
columnize (0.3.6)
|
19
|
+
crack (0.4.1)
|
20
|
+
safe_yaml (~> 0.9.0)
|
8
21
|
debugger (1.6.1)
|
9
22
|
columnize (>= 0.3.1)
|
10
23
|
debugger-linecache (~> 1.2.0)
|
@@ -24,7 +37,6 @@ GEM
|
|
24
37
|
oauth2
|
25
38
|
hashie (2.0.5)
|
26
39
|
highline (1.6.19)
|
27
|
-
httpauth (0.2.0)
|
28
40
|
jeweler (1.8.7)
|
29
41
|
builder
|
30
42
|
bundler (~> 1.0)
|
@@ -42,13 +54,6 @@ GEM
|
|
42
54
|
multi_xml (0.5.5)
|
43
55
|
multipart-post (1.2.0)
|
44
56
|
nokogiri (1.5.10)
|
45
|
-
oauth2 (0.9.2)
|
46
|
-
faraday (~> 0.8)
|
47
|
-
httpauth (~> 0.2)
|
48
|
-
jwt (~> 0.1.4)
|
49
|
-
multi_json (~> 1.0)
|
50
|
-
multi_xml (~> 0.5)
|
51
|
-
rack (~> 1.2)
|
52
57
|
pry (0.9.12.2)
|
53
58
|
coderay (~> 1.0.5)
|
54
59
|
method_source (~> 0.8)
|
@@ -68,7 +73,11 @@ GEM
|
|
68
73
|
rspec-expectations (2.14.2)
|
69
74
|
diff-lcs (>= 1.1.3, < 2.0)
|
70
75
|
rspec-mocks (2.14.3)
|
76
|
+
safe_yaml (0.9.7)
|
71
77
|
slop (3.4.6)
|
78
|
+
webmock (1.13.0)
|
79
|
+
addressable (>= 2.2.7)
|
80
|
+
crack (>= 0.3.2)
|
72
81
|
|
73
82
|
PLATFORMS
|
74
83
|
ruby
|
@@ -76,7 +85,8 @@ PLATFORMS
|
|
76
85
|
DEPENDENCIES
|
77
86
|
bundler
|
78
87
|
jeweler (~> 1.8.7)
|
79
|
-
oauth2
|
88
|
+
oauth2!
|
80
89
|
pry
|
81
90
|
pry-debugger
|
82
91
|
rspec
|
92
|
+
webmock
|
data/README.md
CHANGED
@@ -4,17 +4,24 @@ A very simple ruby gem for interacting with NB people API.
|
|
4
4
|
|
5
5
|
http://nationbuilder.com/api_documentation
|
6
6
|
|
7
|
-
|
7
|
+
### Usage
|
8
8
|
|
9
9
|
```
|
10
10
|
require 'nation_builder'
|
11
11
|
client = NationBuilder.new(hostname: 'whatever.nationbuilder.com', client_id: 'id', client_secret: 'secret', username: 'you@nation.com', password: 'pass')
|
12
|
+
client.people.create('person' => {'first_name' => 'George', 'last_name' => 'Washington', 'email' => 'george@washington.com'})
|
13
|
+
client.people.match('email' => 'george@washington.com) # either a person hash or nil.
|
12
14
|
client.people.list # returns people in nation
|
13
|
-
|
14
15
|
```
|
15
16
|
|
16
|
-
|
17
|
+
### Contributing
|
18
|
+
|
19
|
+
The current gem is minimalist -- but we'd welcome pull requests with additional functionality!
|
20
|
+
|
21
|
+
[](https://travis-ci.org/controlshift/nation_builder)
|
22
|
+
|
23
|
+
### Copyright
|
17
24
|
|
18
|
-
Copyright (c) 2013
|
25
|
+
Copyright (c) 2013 ControlShift Ltd. See LICENSE.txt for
|
19
26
|
further details.
|
20
27
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -6,17 +6,37 @@ module NationBuilder
|
|
6
6
|
args.each do |key, value|
|
7
7
|
self.send("#{key}=".intern, value)
|
8
8
|
end
|
9
|
-
|
10
|
-
self.token = client.password.get_token(username, password)
|
9
|
+
self.token = setup_client
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
12
|
def people
|
15
13
|
NationBuilder::People.new(self)
|
16
14
|
end
|
17
15
|
|
18
|
-
def get(path)
|
19
|
-
self.token.get "
|
16
|
+
def get(path, opts={})
|
17
|
+
self.token.get "#{base_uri}#{path}", opts.merge(headers: headers)
|
18
|
+
end
|
19
|
+
|
20
|
+
def post(path, opts={})
|
21
|
+
self.token.post "#{base_uri}#{path}", opts.merge(headers: headers)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def setup_client
|
27
|
+
client = OAuth2::Client.new(client_id, client_secret, :site => "https://#{hostname}", authorize_url: "https://#{hostname}/oauth/authorize", token_url: "https://#{hostname}/oauth/token" )
|
28
|
+
client.password.get_token(username, password)
|
29
|
+
end
|
30
|
+
|
31
|
+
def headers
|
32
|
+
{
|
33
|
+
'Content-Type' => 'application/json',
|
34
|
+
'Accept' => 'application/json'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def base_uri
|
39
|
+
"https://#{hostname}/"
|
20
40
|
end
|
21
41
|
end
|
22
42
|
end
|
@@ -6,8 +6,25 @@ module NationBuilder
|
|
6
6
|
self.client = client
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def match(params)
|
10
|
+
begin
|
11
|
+
JSON.parse(client.get('/api/v1/people/match', params: params).response.env[:body])
|
12
|
+
rescue OAuth2::Error => e
|
13
|
+
if e.code == 'no_matches'
|
14
|
+
return nil
|
15
|
+
else
|
16
|
+
raise e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def list
|
10
22
|
JSON.parse(client.get('/api/v1/people').response.env[:body])
|
11
23
|
end
|
24
|
+
|
25
|
+
def create params
|
26
|
+
body = JSON.generate(params)
|
27
|
+
JSON.parse(client.post('/api/v1/people', body: body).response.env[:body])
|
28
|
+
end
|
12
29
|
end
|
13
30
|
end
|
data/nation_builder.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "nation_builder"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Woodhull", "Dan Schneiderman"]
|
12
|
-
s.date = "2013-09-
|
12
|
+
s.date = "2013-09-17"
|
13
13
|
s.description = "Ruby wrapper for NationBuilder API"
|
14
14
|
s.email = "nathan@controlshiftlabs.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
".rspec",
|
22
22
|
".ruby-gemset",
|
23
23
|
".ruby-version",
|
24
|
+
".travis.yml",
|
24
25
|
"Gemfile",
|
25
26
|
"Gemfile.lock",
|
26
27
|
"LICENSE.txt",
|
@@ -31,7 +32,9 @@ Gem::Specification.new do |s|
|
|
31
32
|
"lib/nation_builder/client.rb",
|
32
33
|
"lib/nation_builder/people.rb",
|
33
34
|
"nation_builder.gemspec",
|
35
|
+
"spec/client_spec.rb",
|
34
36
|
"spec/nation_builder_spec.rb",
|
37
|
+
"spec/people_spec.rb",
|
35
38
|
"spec/spec_helper.rb"
|
36
39
|
]
|
37
40
|
s.homepage = "http://github.com/controlshift/nation_builder"
|
@@ -45,6 +48,7 @@ Gem::Specification.new do |s|
|
|
45
48
|
|
46
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
50
|
s.add_runtime_dependency(%q<oauth2>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
48
52
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
49
53
|
s.add_development_dependency(%q<pry-debugger>, [">= 0"])
|
50
54
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
@@ -52,6 +56,7 @@ Gem::Specification.new do |s|
|
|
52
56
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
53
57
|
else
|
54
58
|
s.add_dependency(%q<oauth2>, [">= 0"])
|
59
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
55
60
|
s.add_dependency(%q<pry>, [">= 0"])
|
56
61
|
s.add_dependency(%q<pry-debugger>, [">= 0"])
|
57
62
|
s.add_dependency(%q<rspec>, [">= 0"])
|
@@ -60,6 +65,7 @@ Gem::Specification.new do |s|
|
|
60
65
|
end
|
61
66
|
else
|
62
67
|
s.add_dependency(%q<oauth2>, [">= 0"])
|
68
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
63
69
|
s.add_dependency(%q<pry>, [">= 0"])
|
64
70
|
s.add_dependency(%q<pry-debugger>, [">= 0"])
|
65
71
|
s.add_dependency(%q<rspec>, [">= 0"])
|
data/spec/client_spec.rb
ADDED
data/spec/nation_builder_spec.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
3
|
+
describe NationBuilder do
|
4
|
+
before(:each) do
|
5
|
+
NationBuilder::Client.any_instance.stub(:setup_client).and_return(true)
|
6
6
|
end
|
7
|
+
|
8
|
+
specify { subject.should respond_to :people }
|
9
|
+
specify { subject.new.should be_a(NationBuilder::Client)}
|
7
10
|
end
|
data/spec/people_spec.rb
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,45 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
4
|
require 'nation_builder'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
|
5
7
|
|
6
8
|
# Requires supporting files with custom matchers and macros, etc,
|
7
9
|
# in ./support/ and its subdirectories.
|
8
10
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
11
|
|
10
12
|
RSpec.configure do |config|
|
11
|
-
|
13
|
+
config.color_enabled = true
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.include WebMock::API
|
19
|
+
|
20
|
+
config.before(:each) do
|
21
|
+
WebMock.reset!
|
22
|
+
end
|
23
|
+
config.after(:each) do
|
24
|
+
WebMock.reset!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def stub_get(path)
|
29
|
+
stub_nation_builder_request(:get, path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def stub_post(path)
|
33
|
+
stub_nation_builder_request(:post, path)
|
34
|
+
end
|
35
|
+
|
36
|
+
def stub_nation_builder_request(method, path)
|
37
|
+
stub_request(method, "https://test.com" + path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def fixture_path
|
41
|
+
File.expand_path("../fixtures", __FILE__)
|
42
|
+
end
|
43
|
+
|
44
|
+
def fixture(file)
|
45
|
+
File.new(File.join(fixture_path, '/', file))
|
12
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nation_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Woodhull
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: webmock
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: pry
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +121,7 @@ files:
|
|
107
121
|
- .rspec
|
108
122
|
- .ruby-gemset
|
109
123
|
- .ruby-version
|
124
|
+
- .travis.yml
|
110
125
|
- Gemfile
|
111
126
|
- Gemfile.lock
|
112
127
|
- LICENSE.txt
|
@@ -117,7 +132,9 @@ files:
|
|
117
132
|
- lib/nation_builder/client.rb
|
118
133
|
- lib/nation_builder/people.rb
|
119
134
|
- nation_builder.gemspec
|
135
|
+
- spec/client_spec.rb
|
120
136
|
- spec/nation_builder_spec.rb
|
137
|
+
- spec/people_spec.rb
|
121
138
|
- spec/spec_helper.rb
|
122
139
|
homepage: http://github.com/controlshift/nation_builder
|
123
140
|
licenses:
|