gds-api-adapters 10.1.0 → 10.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/test_helpers/content_api.rb +29 -21
- data/lib/gds_api/version.rb +1 -1
- metadata +4 -4
@@ -250,30 +250,37 @@ module GdsApi
|
|
250
250
|
end
|
251
251
|
|
252
252
|
def artefact_for_slug_with_a_child_tag(tag_type, slug, child_tag_id)
|
253
|
+
artefact_for_slug_with_a_child_tags(tag_type, slug, [child_tag_id])
|
254
|
+
end
|
255
|
+
|
256
|
+
def artefact_for_slug_with_a_child_tags(tag_type, slug, child_tag_ids)
|
253
257
|
artefact = artefact_for_slug(slug)
|
254
258
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
259
|
+
child_tag_ids.each do |child_tag_id|
|
260
|
+
# for each "part" of the path, we want to reduce across the
|
261
|
+
# list and build up a tree of nested tags.
|
262
|
+
# This will turn "thing1/thing2" into:
|
263
|
+
# Tag{ thing2, parent: Tag{ thing1 } }
|
264
|
+
|
265
|
+
tag_tree = nil
|
266
|
+
child_tag_id.split('/').inject(nil) do |parent_tag, child_tag|
|
267
|
+
child_tag = [parent_tag, child_tag].join('/') if parent_tag
|
268
|
+
next_level_tag = tag_for_slug(child_tag, tag_type)
|
269
|
+
if tag_tree
|
270
|
+
# Because tags are nested within one another, this makes
|
271
|
+
# the current part the top, and the rest we've seen the
|
272
|
+
# ancestors
|
273
|
+
tag_tree = next_level_tag.merge("parent" => tag_tree)
|
274
|
+
else
|
275
|
+
tag_tree = next_level_tag
|
276
|
+
end
|
277
|
+
|
278
|
+
# This becomes the parent tag in the next iteration of the block
|
279
|
+
child_tag
|
271
280
|
end
|
272
|
-
|
273
|
-
# This becomes the parent tag in the next iteration of the block
|
274
|
-
child_tag
|
281
|
+
artefact["tags"] << tag_tree
|
275
282
|
end
|
276
|
-
|
283
|
+
|
277
284
|
artefact
|
278
285
|
end
|
279
286
|
|
@@ -315,7 +322,8 @@ module GdsApi
|
|
315
322
|
|
316
323
|
{
|
317
324
|
"id" => "#{CONTENT_API_ENDPOINT}/tags/#{CGI.escape(pluralized_tag_type)}/#{CGI.escape(tag[:slug])}.json",
|
318
|
-
"
|
325
|
+
"slug" => tag[:slug],
|
326
|
+
"web_url" => "http://www.test.gov.uk/browse/#{tag[:slug]}",
|
319
327
|
"title" => tag[:title] || titleize_slug(tag[:slug].split("/").last),
|
320
328
|
"details" => {
|
321
329
|
"type" => tag[:type],
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.
|
4
|
+
version: 10.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -370,7 +370,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
370
370
|
version: '0'
|
371
371
|
segments:
|
372
372
|
- 0
|
373
|
-
hash:
|
373
|
+
hash: 1657316963344805388
|
374
374
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
375
375
|
none: false
|
376
376
|
requirements:
|
@@ -379,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
379
|
version: '0'
|
380
380
|
segments:
|
381
381
|
- 0
|
382
|
-
hash:
|
382
|
+
hash: 1657316963344805388
|
383
383
|
requirements: []
|
384
384
|
rubyforge_project:
|
385
385
|
rubygems_version: 1.8.23
|