gds-api-adapters 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/content_api.rb +7 -3
- data/lib/gds_api/test_helpers/content_api.rb +5 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/content_api_test.rb +31 -0
- metadata +134 -187
data/lib/gds_api/content_api.rb
CHANGED
@@ -9,15 +9,19 @@ class GdsApi::ContentApi < GdsApi::Base
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def with_tag(tag)
|
12
|
-
get_json!("#{base_url}/with_tag.json?tag=#{tag}&include_children=1")
|
12
|
+
get_json!("#{base_url}/with_tag.json?tag=#{CGI.escape(tag)}&include_children=1")
|
13
13
|
end
|
14
14
|
|
15
15
|
def curated_list(tag)
|
16
|
-
get_json("#{base_url}/with_tag.json?tag=#{tag}&sort=curated")
|
16
|
+
get_json("#{base_url}/with_tag.json?tag=#{CGI.escape(tag)}&sort=curated")
|
17
17
|
end
|
18
18
|
|
19
19
|
def artefact(slug)
|
20
|
-
get_json("#{base_url}/#{slug}.json")
|
20
|
+
get_json("#{base_url}/#{CGI.escape(slug)}.json")
|
21
|
+
end
|
22
|
+
|
23
|
+
def artefact_with_snac_code(slug, snac)
|
24
|
+
get_json("#{base_url}/#{CGI.escape(slug)}.json?snac=#{CGI.escape(snac)}")
|
21
25
|
end
|
22
26
|
|
23
27
|
def local_authority(snac_code)
|
@@ -34,6 +34,11 @@ module GdsApi
|
|
34
34
|
stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
|
35
35
|
end
|
36
36
|
|
37
|
+
def content_api_has_an_artefact_with_snac_code(slug, snac, body = artefact_for_slug(slug))
|
38
|
+
url = "#{CONTENT_API_ENDPOINT}/#{slug}.json?snac=#{snac}"
|
39
|
+
stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
|
40
|
+
end
|
41
|
+
|
37
42
|
def content_api_does_not_have_an_artefact(slug)
|
38
43
|
body = {
|
39
44
|
"_response_info" => {
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_api_test.rb
CHANGED
@@ -33,6 +33,37 @@ describe GdsApi::ContentApi do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
describe "licence" do
|
37
|
+
it "should return an artefact with licence for a snac code" do
|
38
|
+
response = content_api_has_an_artefact_with_snac_code("licence-example", '1234', {
|
39
|
+
"title" => "Licence Example",
|
40
|
+
"slug" => "licence-example",
|
41
|
+
"details" => {
|
42
|
+
"licence" => {
|
43
|
+
"location_specific" => false,
|
44
|
+
"availability" => [ "England", "Wales" ],
|
45
|
+
"authorities" => [ ]
|
46
|
+
}
|
47
|
+
}
|
48
|
+
})
|
49
|
+
response = @api.artefact_with_snac_code('licence-example', '1234')
|
50
|
+
|
51
|
+
assert_equal "Licence Example", response["title"]
|
52
|
+
assert_equal [ "England", "Wales" ], response["details"]["licence"]["availability"]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should escape snac code when searching for licence" do
|
56
|
+
stub_request(:get, "#{@base_api_url}/licence-example.json?snac=snacks%21").
|
57
|
+
to_return(:status => 200,
|
58
|
+
:body => {"test" => "ing"}.to_json,
|
59
|
+
:headers => {})
|
60
|
+
|
61
|
+
@api.artefact_with_snac_code("licence-example","snacks!")
|
62
|
+
|
63
|
+
assert_requested :get, "#{@base_api_url}/licence-example.json?snac=snacks%21"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
36
67
|
describe "local authorities" do
|
37
68
|
it "should return nil if no local authority found" do
|
38
69
|
stub_request(:get, "#{@base_api_url}/local_authorities/does-not-exist.json").
|
metadata
CHANGED
@@ -1,292 +1,239 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.0
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 2.6.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- James Stewart
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-09-21 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: plek
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
31
27
|
name: null_logger
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
33
29
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version:
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
47
38
|
name: lrucache
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
40
|
none: false
|
50
|
-
requirements:
|
41
|
+
requirements:
|
51
42
|
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
43
|
+
- !ruby/object:Gem::Version
|
53
44
|
version: 0.1.1
|
54
45
|
type: :runtime
|
55
46
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.1
|
62
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
63
49
|
name: rdoc
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
51
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version:
|
52
|
+
requirements:
|
53
|
+
- - "="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "3.12"
|
70
56
|
type: :development
|
71
57
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
|
74
|
-
requirements:
|
75
|
-
- - '='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '3.12'
|
78
|
-
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
79
60
|
name: rake
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
62
|
none: false
|
82
|
-
requirements:
|
63
|
+
requirements:
|
83
64
|
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
65
|
+
- !ruby/object:Gem::Version
|
85
66
|
version: 0.9.2.2
|
86
67
|
type: :development
|
87
68
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 0.9.2.2
|
94
|
-
- !ruby/object:Gem::Dependency
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
95
71
|
name: webmock
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
73
|
none: false
|
98
|
-
requirements:
|
74
|
+
requirements:
|
99
75
|
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version:
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "1.8"
|
102
78
|
type: :development
|
103
79
|
prerelease: false
|
104
|
-
version_requirements:
|
105
|
-
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '1.8'
|
110
|
-
- !ruby/object:Gem::Dependency
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
111
82
|
name: mocha
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
113
84
|
none: false
|
114
|
-
requirements:
|
85
|
+
requirements:
|
115
86
|
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
87
|
+
- !ruby/object:Gem::Version
|
117
88
|
version: 0.12.4
|
118
89
|
type: :development
|
119
90
|
prerelease: false
|
120
|
-
version_requirements:
|
121
|
-
|
122
|
-
requirements:
|
123
|
-
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 0.12.4
|
126
|
-
- !ruby/object:Gem::Dependency
|
91
|
+
version_requirements: *id007
|
92
|
+
- !ruby/object:Gem::Dependency
|
127
93
|
name: minitest
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
129
95
|
none: false
|
130
|
-
requirements:
|
96
|
+
requirements:
|
131
97
|
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
98
|
+
- !ruby/object:Gem::Version
|
133
99
|
version: 3.4.0
|
134
100
|
type: :development
|
135
101
|
prerelease: false
|
136
|
-
version_requirements:
|
137
|
-
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 3.4.0
|
142
|
-
- !ruby/object:Gem::Dependency
|
102
|
+
version_requirements: *id008
|
103
|
+
- !ruby/object:Gem::Dependency
|
143
104
|
name: rack
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
145
106
|
none: false
|
146
|
-
requirements:
|
147
|
-
- -
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version:
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: "0"
|
150
111
|
type: :development
|
151
112
|
prerelease: false
|
152
|
-
version_requirements:
|
153
|
-
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
113
|
+
version_requirements: *id009
|
114
|
+
- !ruby/object:Gem::Dependency
|
159
115
|
name: simplecov
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
161
117
|
none: false
|
162
|
-
requirements:
|
118
|
+
requirements:
|
163
119
|
- - ~>
|
164
|
-
- !ruby/object:Gem::Version
|
120
|
+
- !ruby/object:Gem::Version
|
165
121
|
version: 0.5.4
|
166
122
|
type: :development
|
167
123
|
prerelease: false
|
168
|
-
version_requirements:
|
169
|
-
|
170
|
-
requirements:
|
171
|
-
- - ~>
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 0.5.4
|
174
|
-
- !ruby/object:Gem::Dependency
|
124
|
+
version_requirements: *id010
|
125
|
+
- !ruby/object:Gem::Dependency
|
175
126
|
name: simplecov-rcov
|
176
|
-
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
177
128
|
none: false
|
178
|
-
requirements:
|
179
|
-
- -
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version:
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: "0"
|
182
133
|
type: :development
|
183
134
|
prerelease: false
|
184
|
-
version_requirements:
|
185
|
-
|
186
|
-
requirements:
|
187
|
-
- - ! '>='
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '0'
|
190
|
-
- !ruby/object:Gem::Dependency
|
135
|
+
version_requirements: *id011
|
136
|
+
- !ruby/object:Gem::Dependency
|
191
137
|
name: gem_publisher
|
192
|
-
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
193
139
|
none: false
|
194
|
-
requirements:
|
140
|
+
requirements:
|
195
141
|
- - ~>
|
196
|
-
- !ruby/object:Gem::Version
|
142
|
+
- !ruby/object:Gem::Version
|
197
143
|
version: 1.1.1
|
198
144
|
type: :development
|
199
145
|
prerelease: false
|
200
|
-
version_requirements:
|
201
|
-
none: false
|
202
|
-
requirements:
|
203
|
-
- - ~>
|
204
|
-
- !ruby/object:Gem::Version
|
205
|
-
version: 1.1.1
|
146
|
+
version_requirements: *id012
|
206
147
|
description: A set of adapters providing easy access to the GDS gov.uk APIs
|
207
|
-
email:
|
148
|
+
email:
|
208
149
|
- jystewart@gmail.com
|
209
150
|
executables: []
|
151
|
+
|
210
152
|
extensions: []
|
153
|
+
|
211
154
|
extra_rdoc_files: []
|
212
|
-
|
213
|
-
|
214
|
-
- lib/gds_api/contactotron.rb
|
155
|
+
|
156
|
+
files:
|
215
157
|
- lib/gds_api/content_api.rb
|
216
|
-
- lib/gds_api/core-ext/openstruct.rb
|
217
|
-
- lib/gds_api/exceptions.rb
|
218
|
-
- lib/gds_api/helpers.rb
|
219
|
-
- lib/gds_api/imminence.rb
|
220
|
-
- lib/gds_api/json_client.rb
|
221
158
|
- lib/gds_api/licence_application.rb
|
222
|
-
- lib/gds_api/needotron.rb
|
223
|
-
- lib/gds_api/panopticon/registerer.rb
|
224
|
-
- lib/gds_api/panopticon.rb
|
225
|
-
- lib/gds_api/part_methods.rb
|
226
|
-
- lib/gds_api/publisher.rb
|
227
|
-
- lib/gds_api/response.rb
|
228
|
-
- lib/gds_api/rummager.rb
|
229
|
-
- lib/gds_api/test_helpers/contactotron.rb
|
230
159
|
- lib/gds_api/test_helpers/content_api.rb
|
231
|
-
- lib/gds_api/test_helpers/imminence.rb
|
232
|
-
- lib/gds_api/test_helpers/json_client_helper.rb
|
233
160
|
- lib/gds_api/test_helpers/licence_application.rb
|
234
|
-
- lib/gds_api/test_helpers/
|
161
|
+
- lib/gds_api/test_helpers/contactotron.rb
|
162
|
+
- lib/gds_api/test_helpers/json_client_helper.rb
|
235
163
|
- lib/gds_api/test_helpers/publisher.rb
|
164
|
+
- lib/gds_api/test_helpers/panopticon.rb
|
165
|
+
- lib/gds_api/test_helpers/imminence.rb
|
166
|
+
- lib/gds_api/part_methods.rb
|
167
|
+
- lib/gds_api/needotron.rb
|
168
|
+
- lib/gds_api/rummager.rb
|
236
169
|
- lib/gds_api/typhoeus_client.rb
|
170
|
+
- lib/gds_api/json_client.rb
|
171
|
+
- lib/gds_api/contactotron.rb
|
172
|
+
- lib/gds_api/response.rb
|
173
|
+
- lib/gds_api/panopticon/registerer.rb
|
174
|
+
- lib/gds_api/publisher.rb
|
175
|
+
- lib/gds_api/exceptions.rb
|
237
176
|
- lib/gds_api/version.rb
|
177
|
+
- lib/gds_api/helpers.rb
|
178
|
+
- lib/gds_api/base.rb
|
179
|
+
- lib/gds_api/panopticon.rb
|
180
|
+
- lib/gds_api/core-ext/openstruct.rb
|
181
|
+
- lib/gds_api/imminence.rb
|
238
182
|
- README.md
|
239
183
|
- Rakefile
|
240
|
-
- test/contactotron_api_test.rb
|
241
|
-
- test/content_api_test.rb
|
242
|
-
- test/gds_api_base_test.rb
|
243
184
|
- test/imminence_api_test.rb
|
244
|
-
- test/
|
185
|
+
- test/contactotron_api_test.rb
|
186
|
+
- test/rummager_test.rb
|
245
187
|
- test/licence_application_api_test.rb
|
246
|
-
- test/
|
247
|
-
- test/panopticon_registerer_test.rb
|
188
|
+
- test/json_client_test.rb
|
248
189
|
- test/publisher_api_test.rb
|
249
|
-
- test/
|
190
|
+
- test/panopticon_registerer_test.rb
|
191
|
+
- test/panopticon_api_test.rb
|
250
192
|
- test/test_helper.rb
|
193
|
+
- test/gds_api_base_test.rb
|
194
|
+
- test/content_api_test.rb
|
251
195
|
homepage: http://github.com/alphagov/gds-api-adapters
|
252
196
|
licenses: []
|
197
|
+
|
253
198
|
post_install_message:
|
254
199
|
rdoc_options: []
|
255
|
-
|
200
|
+
|
201
|
+
require_paths:
|
256
202
|
- lib
|
257
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
203
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
258
204
|
none: false
|
259
|
-
requirements:
|
260
|
-
- -
|
261
|
-
- !ruby/object:Gem::Version
|
262
|
-
|
263
|
-
segments:
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
hash: -727284254732097634
|
209
|
+
segments:
|
264
210
|
- 0
|
265
|
-
|
266
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
+
version: "0"
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
213
|
none: false
|
268
|
-
requirements:
|
269
|
-
- -
|
270
|
-
- !ruby/object:Gem::Version
|
271
|
-
|
272
|
-
segments:
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
hash: -727284254732097634
|
218
|
+
segments:
|
273
219
|
- 0
|
274
|
-
|
220
|
+
version: "0"
|
275
221
|
requirements: []
|
222
|
+
|
276
223
|
rubyforge_project:
|
277
224
|
rubygems_version: 1.8.24
|
278
225
|
signing_key:
|
279
226
|
specification_version: 3
|
280
227
|
summary: Adapters to work with GDS APIs
|
281
|
-
test_files:
|
282
|
-
- test/contactotron_api_test.rb
|
283
|
-
- test/content_api_test.rb
|
284
|
-
- test/gds_api_base_test.rb
|
228
|
+
test_files:
|
285
229
|
- test/imminence_api_test.rb
|
286
|
-
- test/
|
230
|
+
- test/contactotron_api_test.rb
|
231
|
+
- test/rummager_test.rb
|
287
232
|
- test/licence_application_api_test.rb
|
288
|
-
- test/
|
289
|
-
- test/panopticon_registerer_test.rb
|
233
|
+
- test/json_client_test.rb
|
290
234
|
- test/publisher_api_test.rb
|
291
|
-
- test/
|
235
|
+
- test/panopticon_registerer_test.rb
|
236
|
+
- test/panopticon_api_test.rb
|
292
237
|
- test/test_helper.rb
|
238
|
+
- test/gds_api_base_test.rb
|
239
|
+
- test/content_api_test.rb
|