gds-api-adapters 49.7.0 → 49.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b762aee9a8820eb15af6a93d1f6a76613db0e4c2
4
- data.tar.gz: 402b49ea6cb48c0210e5dfd9083dbef52d8b61ca
3
+ metadata.gz: 565cb9c62f97ab192f2ae1cd2e206508bd3c9d1b
4
+ data.tar.gz: 712159c4958e3440fe33344983e6e1d1a75a15d4
5
5
  SHA512:
6
- metadata.gz: d834d43099a1e1225f96e304b3472ba4721ec4a854d494e73b8809533ecff807748da8ddb5678ccbdf2af618de8f2af278533e7603743a8c052cd457ec6bc2bd
7
- data.tar.gz: f616e60ae73667a4551bd1afde5e2e7762116d908260e8040092d7a9eac261a841d686ffbd2358a2689774115f337ce3a32378173fded93214052309cf5d6671
6
+ metadata.gz: a2dd889e19663d642c85c98091ec65ed91f90d1d29b7c7ffbd4eb97a6bb34db6ddd71aa622920c1ec999420c210436c8ef385b98d58265365ca870f44049dd64
7
+ data.tar.gz: ddbf675bf7758dbaf05c3a42f33856f16e225882c85d028a82068029454aade5ae221cd806f3b6a89157202d097cb5d1c189687c1ba7a307f3b3a23b695d9e59
@@ -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/docs/search-api.md
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/docs/documents.md
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/docs/content-api.md
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/docs/content-api.md
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)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '49.7.0'.freeze
2
+ VERSION = '49.8.0'.freeze
3
3
  end
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.7.0
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-16 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek