gds-api-adapters 33.2.2 → 34.0.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: 09728e5e73d9ba143473d323123098d6fcb48035
4
- data.tar.gz: 548f93cdb9e13682e054ab7f1580855f03529660
3
+ metadata.gz: c31508a987b6157626ddc9dd154b5458db554ea2
4
+ data.tar.gz: 43b17d83043656ccdd24b88fcb6d07c74d9c19cf
5
5
  SHA512:
6
- metadata.gz: bc35f6e20c4772f0e3e38fb25eeed2da4a307b8f3724ed177ec3437602ff8333df182044e0ef9e112cbf43dc927eb0c751a5e5087d909b7b71c8205cda357543
7
- data.tar.gz: ac5f1ef28b8068f0c9d0ebd9dfcad328b455f8918ff67d79d9d61b77b6406b3a2f728186043230da39e7619fc05abdcde20f13191aa7028b7261e9a76ff552ef
6
+ metadata.gz: 68f4709932906aca95ba97ea7343bbc9896953be06c57871e7ab9e93c3ce45f4b3f73bb093a14844d6cd37e44c0030457cbf1d1013b978f26eb0467b19febc66
7
+ data.tar.gz: 634deb28aee00f3ca3050ab8cea2b41eabd31bead3207ecd9ba98a8306dea9edd1dc7a260de634a511932f1b099600f3ce7d7bfc3718230a42077f72ceda032e
@@ -4,9 +4,7 @@ require 'rack/utils'
4
4
  module GdsApi
5
5
  class Rummager < Base
6
6
 
7
- # Unified search
8
- #
9
- # Perform a search
7
+ # Perform a search.
10
8
  #
11
9
  # @param query [Hash] A valid search query. See Rummager documentation for options.
12
10
  #
@@ -16,7 +14,7 @@ module GdsApi
16
14
  get_json!(request_url)
17
15
  end
18
16
 
19
- # Advanced search
17
+ # Advanced search.
20
18
  #
21
19
  # @deprecated Only in use by Whitehall. Use the `unified_search` method.
22
20
  def advanced_search(args)
@@ -25,9 +23,12 @@ module GdsApi
25
23
  get_json!(request_path)
26
24
  end
27
25
 
28
- # Add a document
26
+ # Add a document to the search index.
29
27
  #
30
- # Adds a document to the index
28
+ # @param type [String] The rummager/elasticsearch document type.
29
+ # @param id [String] The rummager/elasticsearch id. Typically the same as the `link` field, but this is not strictly enforced.
30
+ # @param document [Hash] The document to add. Must match the rummager schema matchin the `type` parameter and contain a `link` field.
31
+ # @return [GdsApi::Response] A status code of 202 indicates the document has been successfully queued.
31
32
  #
32
33
  # @see https://github.com/alphagov/rummager/blob/master/docs/documents.md
33
34
  def add_document(type, id, document)
@@ -40,9 +41,11 @@ module GdsApi
40
41
  )
41
42
  end
42
43
 
43
- # Deletes a content-document from the index. Content documents are pages
44
- # on GOV.UK returned by search index. They don't include best bets and other
45
- # "meta" documents that are stored in Rummager.
44
+ # Delete a content-document from the index by base path.
45
+ #
46
+ # Content documents are pages on GOV.UK that have a base path and are
47
+ # returned in searches. This excludes best bets, recommended-links,
48
+ # and contacts, which may be deleted with `delete_document`.
46
49
  #
47
50
  # @param base_path Base path of the page on GOV.UK.
48
51
  # @see https://github.com/alphagov/rummager/blob/master/docs/content-api.md
@@ -51,8 +54,11 @@ module GdsApi
51
54
  delete_json!(request_url)
52
55
  end
53
56
 
54
- # Retrieves a content-document from the index. Content documents are pages
55
- # on GOV.UK returned by search index.
57
+ # Retrieve a content-document from the index.
58
+ #
59
+ # Content documents are pages on GOV.UK that have a base path and are
60
+ # returned in searches. This excludes best bets, recommended-links,
61
+ # and contacts.
56
62
  #
57
63
  # @param base_path [String] Base path of the page on GOV.UK.
58
64
  # @see https://github.com/alphagov/rummager/blob/master/docs/content-api.md
@@ -61,13 +67,12 @@ module GdsApi
61
67
  get_json!(request_url)
62
68
  end
63
69
 
64
- # delete_document(type, id) (DEPRECATED)
70
+ # Delete a non-content document from the search index.
65
71
  #
66
- # Delete any document from the search index. Unlike `delete_content!` this
67
- # needs a type, but can be used to delete non-content documents from the
68
- # index.
72
+ # For example, best bets, recommended links, or contacts.
69
73
  #
70
- # @deprecated Use `delete_content!`
74
+ # @param type [String] The rummager/elasticsearch document type.
75
+ # @param id [String] The rummager/elasticsearch id. Typically the same as the `link` field.
71
76
  def delete_document(type, id)
72
77
  delete_json!(
73
78
  "#{documents_url}/#{id}",
@@ -6,18 +6,31 @@ module GdsApi
6
6
  module Rummager
7
7
  RUMMAGER_ENDPOINT = Plek.current.find('rummager')
8
8
 
9
- def stub_any_rummager_post
10
- stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents})
9
+ def stub_any_rummager_post(index: nil)
10
+ if index
11
+ stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/#{index}/documents})
12
+ .to_return(status: [202, "Accepted"])
13
+ else
14
+ stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents})
15
+ .to_return(status: [202, "Accepted"])
16
+ end
11
17
  end
12
18
 
13
19
  def stub_any_rummager_post_with_queueing_enabled
20
+ warn "stub_any_rummager_post_with_queueing_enabled is deprecated: use stub_any_rummager_post instead"
21
+
14
22
  stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents}) \
15
23
  .to_return(status: [202, "Accepted"])
16
24
  end
17
25
 
18
- def assert_rummager_posted_item(attributes)
19
- url = RUMMAGER_ENDPOINT + "/documents"
20
- assert_requested(:post, url) do |req|
26
+ def assert_rummager_posted_item(attributes, index: nil, **options)
27
+ if index
28
+ url = RUMMAGER_ENDPOINT + "/#{index}/documents"
29
+ else
30
+ url = RUMMAGER_ENDPOINT + "/documents"
31
+ end
32
+
33
+ assert_requested(:post, url, **options) do |req|
21
34
  data = JSON.parse(req.body)
22
35
  attributes.to_a.all? do |key, value|
23
36
  data[key.to_s] == value
@@ -25,28 +38,44 @@ module GdsApi
25
38
  end
26
39
  end
27
40
 
28
- # @deprecated Rummager.delete_docment is deprecated, so is this stub! Use `stub_any_rummager_delete_content`
29
- def stub_any_rummager_delete
30
- warn "stub_any_rummager_delete is deprecated, instead use: stub_any_rummager_delete_content"
31
- stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/documents/.*})
41
+ def stub_any_rummager_delete(index: nil)
42
+ if index
43
+ stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/#{index}/documents/.*})
44
+ else
45
+ # use rummager's default index
46
+ stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/documents/.*})
47
+ end
32
48
  end
33
49
 
34
50
  def stub_any_rummager_delete_content
35
51
  stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/content.*})
36
52
  end
37
53
 
38
- # @deprecated Rummager.delete_docment is deprecated, so is this stub! Use `assert_rummager_deleted_content`
39
- def assert_rummager_deleted_item(id)
40
- warn "assert_rummager_deleted_item stub is deprecated, instead use: assert_rummager_deleted_content"
41
-
54
+ def assert_rummager_deleted_item(id, index: nil, **options)
42
55
  if id =~ %r{^/}
43
56
  raise ArgumentError, 'Rummager id must not start with a slash'
44
57
  end
45
- assert_requested(:delete, %r{#{RUMMAGER_ENDPOINT}/documents/#{id}})
58
+ if index
59
+ assert_requested(
60
+ :delete,
61
+ %r{#{RUMMAGER_ENDPOINT}/#{index}/documents/#{id}},
62
+ **options
63
+ )
64
+ else
65
+ assert_requested(
66
+ :delete,
67
+ %r{#{RUMMAGER_ENDPOINT}/documents/#{id}},
68
+ **options
69
+ )
70
+ end
46
71
  end
47
72
 
48
- def assert_rummager_deleted_content(base_path)
49
- assert_requested(:delete, %r{#{RUMMAGER_ENDPOINT}/content.*#{base_path}})
73
+ def assert_rummager_deleted_content(base_path, **options)
74
+ assert_requested(
75
+ :delete,
76
+ %r{#{RUMMAGER_ENDPOINT}/content.*#{base_path}},
77
+ **options
78
+ )
50
79
  end
51
80
 
52
81
  def rummager_has_services_and_info_data_for_organisation
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '33.2.2'
2
+ VERSION = '34.0.0'
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: 33.2.2
4
+ version: 34.0.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: 2016-08-22 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek