gds-api-adapters 49.7.0 → 49.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/rummager.rb +28 -4
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 565cb9c62f97ab192f2ae1cd2e206508bd3c9d1b
|
4
|
+
data.tar.gz: 712159c4958e3440fe33344983e6e1d1a75a15d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2dd889e19663d642c85c98091ec65ed91f90d1d29b7c7ffbd4eb97a6bb34db6ddd71aa622920c1ec999420c210436c8ef385b98d58265365ca870f44049dd64
|
7
|
+
data.tar.gz: ddbf675bf7758dbaf05c3a42f33856f16e225882c85d028a82068029454aade5ae221cd806f3b6a89157202d097cb5d1c189687c1ba7a307f3b3a23b695d9e59
|
data/lib/gds_api/rummager.rb
CHANGED
@@ -8,12 +8,36 @@ module GdsApi
|
|
8
8
|
#
|
9
9
|
# @param args [Hash] A valid search query. See Rummager documentation for options.
|
10
10
|
#
|
11
|
-
# @see https://github.com/alphagov/rummager/blob/master/
|
11
|
+
# @see https://github.com/alphagov/rummager/blob/master/doc/search-api.md
|
12
12
|
def search(args, additional_headers = {})
|
13
13
|
request_url = "#{base_url}/search.json?#{Rack::Utils.build_nested_query(args)}"
|
14
14
|
get_json(request_url, additional_headers)
|
15
15
|
end
|
16
16
|
|
17
|
+
# Perform a search, returning the results as an enumerator.
|
18
|
+
#
|
19
|
+
# The enumerator abstracts away rummager's pagination and fetches new pages when
|
20
|
+
# necessary.
|
21
|
+
#
|
22
|
+
# @param args [Hash] A valid search query. See Rummager documentation for options.
|
23
|
+
# @param page_size [Integer] Number of results in each page.
|
24
|
+
#
|
25
|
+
# @see https://github.com/alphagov/rummager/blob/master/doc/search-api.md
|
26
|
+
def search_enum(args, page_size: 100, additional_headers: {})
|
27
|
+
Enumerator.new do |yielder|
|
28
|
+
(0..Float::INFINITY).step(page_size).each do |index|
|
29
|
+
search_params = args.merge(start: index.to_i, count: page_size)
|
30
|
+
results = search(search_params, additional_headers).to_h.fetch('results', [])
|
31
|
+
results.each do |result|
|
32
|
+
yielder << result
|
33
|
+
end
|
34
|
+
if results.count < page_size
|
35
|
+
break
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
17
41
|
# Advanced search.
|
18
42
|
#
|
19
43
|
# @deprecated Only in use by Whitehall. Use the `#search` method.
|
@@ -30,7 +54,7 @@ module GdsApi
|
|
30
54
|
# @param document [Hash] The document to add. Must match the rummager schema matchin the `type` parameter and contain a `link` field.
|
31
55
|
# @return [GdsApi::Response] A status code of 202 indicates the document has been successfully queued.
|
32
56
|
#
|
33
|
-
# @see https://github.com/alphagov/rummager/blob/master/
|
57
|
+
# @see https://github.com/alphagov/rummager/blob/master/doc/documents.md
|
34
58
|
def add_document(type, id, document)
|
35
59
|
post_json(
|
36
60
|
documents_url,
|
@@ -48,7 +72,7 @@ module GdsApi
|
|
48
72
|
# and contacts, which may be deleted with `delete_document`.
|
49
73
|
#
|
50
74
|
# @param base_path Base path of the page on GOV.UK.
|
51
|
-
# @see https://github.com/alphagov/rummager/blob/master/
|
75
|
+
# @see https://github.com/alphagov/rummager/blob/master/doc/content-api.md
|
52
76
|
def delete_content(base_path)
|
53
77
|
request_url = "#{base_url}/content?link=#{base_path}"
|
54
78
|
delete_json(request_url)
|
@@ -66,7 +90,7 @@ module GdsApi
|
|
66
90
|
# and contacts.
|
67
91
|
#
|
68
92
|
# @param base_path [String] Base path of the page on GOV.UK.
|
69
|
-
# @see https://github.com/alphagov/rummager/blob/master/
|
93
|
+
# @see https://github.com/alphagov/rummager/blob/master/doc/content-api.md
|
70
94
|
def get_content(base_path)
|
71
95
|
request_url = "#{base_url}/content?link=#{base_path}"
|
72
96
|
get_json(request_url)
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 49.
|
4
|
+
version: 49.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|