nationbuilder-rb 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/nationbuilder.rb +2 -13
- data/lib/nationbuilder/client.rb +4 -4
- data/lib/nationbuilder/url.rb +17 -0
- data/nationbuilder-rb.gemspec +6 -5
- metadata +23 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ae7bf9f70facdbbf4ad1b53d11ec128c86c4b50
|
4
|
+
data.tar.gz: aa071088a5b4cdc59f3abe118d2835c63ce54448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d30f0f59acd3b906ae11dd4307f0cb0a63ea355f84ad7e619adabdcec43705e7a49099c92c94b328eaf98aa002b3a2c3768f97bd3a04cbe2176b22c398063601
|
7
|
+
data.tar.gz: 32112121fec3e5e1ec3e413fd1332f8b28869a621b317ed3af03fef0bfbc2e60349c5f562a562384b855fb74228ae00a5da45b15b32d4365cf11926bf8ba9751
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/nationbuilder.rb
CHANGED
@@ -3,22 +3,11 @@ require 'json'
|
|
3
3
|
require 'set'
|
4
4
|
require 'uri'
|
5
5
|
|
6
|
-
module NationBuilder
|
7
|
-
|
8
|
-
URL_TEMPLATE = 'https://:nation_name.nationbuilder.com'
|
9
|
-
|
10
|
-
def self.generate_url(base_url, extension, parameters)
|
11
|
-
url = URI.join(base_url, '/api/v1' + extension).to_s
|
12
|
-
parameters.each do |name, value|
|
13
|
-
url.gsub!(name.inspect, value.to_s)
|
14
|
-
end
|
15
|
-
url
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
6
|
+
module NationBuilder; end
|
19
7
|
|
20
8
|
require 'nationbuilder/client'
|
21
9
|
require 'nationbuilder/endpoint'
|
22
10
|
require 'nationbuilder/method'
|
23
11
|
require 'nationbuilder/parameter'
|
12
|
+
require 'nationbuilder/url'
|
24
13
|
require 'nationbuilder/spec_parser'
|
data/lib/nationbuilder/client.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
class NationBuilder::Client
|
2
2
|
|
3
|
-
def initialize(nation_name, api_key)
|
3
|
+
def initialize(nation_name, api_key, base_url = 'https://:nation_name.nationbuilder.com')
|
4
4
|
@nation_name = nation_name
|
5
5
|
@api_key = api_key
|
6
|
+
@base_url = base_url
|
6
7
|
@name_to_endpoint = {}
|
7
8
|
parsed_endpoints.each do |endpoint|
|
8
9
|
@name_to_endpoint[endpoint.name] = endpoint
|
@@ -27,8 +28,7 @@ class NationBuilder::Client
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def base_url
|
30
|
-
@base_url
|
31
|
-
NationBuilder::URL_TEMPLATE.gsub(':nation_name', @nation_name)
|
31
|
+
@base_url.gsub(':nation_name', @nation_name)
|
32
32
|
end
|
33
33
|
|
34
34
|
def call(endpoint_name, method_name, args={})
|
@@ -37,7 +37,7 @@ class NationBuilder::Client
|
|
37
37
|
nonmethod_args = method.nonmethod_args(args)
|
38
38
|
method_args = method.method_args(args)
|
39
39
|
method.validate_args(method_args)
|
40
|
-
url = NationBuilder.generate_url(
|
40
|
+
url = NationBuilder::URL.new(base_url).generate_url(method.uri, method_args)
|
41
41
|
|
42
42
|
request_args = {
|
43
43
|
header: {
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module NationBuilder
|
2
|
+
|
3
|
+
class URL
|
4
|
+
|
5
|
+
def initialize(url_template)
|
6
|
+
@url_template = url_template
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate_url(extension, parameters)
|
10
|
+
url = URI.join(@url_template, '/api/v1' + extension).to_s
|
11
|
+
parameters.each { |name, value| url.gsub!(name.inspect, value.to_s) }
|
12
|
+
url
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/nationbuilder-rb.gemspec
CHANGED
@@ -2,15 +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 0.
|
5
|
+
# stub: nationbuilder-rb 0.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nationbuilder-rb"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["David Huie"]
|
13
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-12-09"
|
14
15
|
s.description = "A Ruby client to the NationBuilder API"
|
15
16
|
s.email = "david@nationbuilder.com"
|
16
17
|
s.executables = ["nbdoc"]
|
@@ -38,6 +39,7 @@ Gem::Specification.new do |s|
|
|
38
39
|
"lib/nationbuilder/method.rb",
|
39
40
|
"lib/nationbuilder/parameter.rb",
|
40
41
|
"lib/nationbuilder/spec_parser.rb",
|
42
|
+
"lib/nationbuilder/url.rb",
|
41
43
|
"nationbuilder-rb.gemspec",
|
42
44
|
"spec/fixtures/delete.yml",
|
43
45
|
"spec/fixtures/parametered_get.yml",
|
@@ -47,8 +49,7 @@ Gem::Specification.new do |s|
|
|
47
49
|
]
|
48
50
|
s.homepage = "http://github.com/3dna/nationbuilder-rb"
|
49
51
|
s.licenses = ["MIT"]
|
50
|
-
s.
|
51
|
-
s.rubygems_version = "2.1.11"
|
52
|
+
s.rubygems_version = "2.2.2"
|
52
53
|
s.summary = "A Ruby client to the NationBuilder API"
|
53
54
|
|
54
55
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nationbuilder-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Huie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jeweler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.0.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 2.8.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.8.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.8.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.8.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 2.9.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 2.9.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 1.18.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.18.0
|
97
97
|
description: A Ruby client to the NationBuilder API
|
@@ -103,11 +103,11 @@ extra_rdoc_files:
|
|
103
103
|
- LICENSE.txt
|
104
104
|
- README.md
|
105
105
|
files:
|
106
|
-
- .document
|
107
|
-
- .rspec
|
108
|
-
- .ruby-gemset
|
109
|
-
- .ruby-version
|
110
|
-
- .travis.yml
|
106
|
+
- ".document"
|
107
|
+
- ".rspec"
|
108
|
+
- ".ruby-gemset"
|
109
|
+
- ".ruby-version"
|
110
|
+
- ".travis.yml"
|
111
111
|
- Gemfile
|
112
112
|
- Gemfile.lock
|
113
113
|
- LICENSE.txt
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/nationbuilder/method.rb
|
123
123
|
- lib/nationbuilder/parameter.rb
|
124
124
|
- lib/nationbuilder/spec_parser.rb
|
125
|
+
- lib/nationbuilder/url.rb
|
125
126
|
- nationbuilder-rb.gemspec
|
126
127
|
- spec/fixtures/delete.yml
|
127
128
|
- spec/fixtures/parametered_get.yml
|
@@ -138,17 +139,17 @@ require_paths:
|
|
138
139
|
- lib
|
139
140
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
141
|
requirements:
|
141
|
-
- -
|
142
|
+
- - ">="
|
142
143
|
- !ruby/object:Gem::Version
|
143
144
|
version: '0'
|
144
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
146
|
requirements:
|
146
|
-
- -
|
147
|
+
- - ">="
|
147
148
|
- !ruby/object:Gem::Version
|
148
149
|
version: '0'
|
149
150
|
requirements: []
|
150
151
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.2.2
|
152
153
|
signing_key:
|
153
154
|
specification_version: 4
|
154
155
|
summary: A Ruby client to the NationBuilder API
|