samvera-nesting_indexer 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d85b5e9c924b8da1ab4155a9144073696f0d8aba
4
- data.tar.gz: a49b5e3004e1b477d878343ce702a03ce02244e4
3
+ metadata.gz: eda0716fd21bf940a1579608723873ead488df6e
4
+ data.tar.gz: 6496a06843f6d404036595c82238662275d465d6
5
5
  SHA512:
6
- metadata.gz: 2769007dd241f6eddf9be40857685f87f7e55a18ac103acb9674242df470388cb45dbc2cf7aa06a5b57bb20a278ea31c254eb3d1c06a225e5de0c79c514b60e5
7
- data.tar.gz: bb3bbaface89adceb926133b867ccbe188ec026a1611e3db3c4180aacaddc91bc196a36805dc27c27a083c1776cc08b569107ea3412f4941497b59cf49bc2945
6
+ metadata.gz: 0d6e41b470b8e3655c8f01f5a2eb593f44b1bf7dd3739363502b65a51bd77c8b5e52e0f84a02b3adba21ea63891fa7368c0660880916016ff0d2ee96a6364bc0
7
+ data.tar.gz: 647c0d4d3b3e4b50ca0c69cb220b01745e5c77ccb1144c26853f1533a81b7b480fe74454e45b8ba101b2e7489d9606517f007beb3b4bfc86700f11db776b50c8
@@ -33,8 +33,9 @@ module Samvera
33
33
  end
34
34
 
35
35
  # @api public
36
+ # @param attributes [Hash]
36
37
  # @return Hash - the attributes written to the indexing layer
37
- def self.write_document_attributes_to_index_layer(attributes = {})
38
+ def self.write_document_attributes_to_index_layer(attributes:)
38
39
  raise NotImplementedError
39
40
  end
40
41
  end
@@ -40,14 +40,16 @@ module Samvera
40
40
  # @api public
41
41
  # This is not something that I envision using in the production environment;
42
42
  # It is hear to keep the Preservation system isolated and accessible only through interfaces.
43
+ # @param attributes [Hash]
43
44
  # @return Samvera::NestingIndexer::Documents::PreservationDocument
44
- def self.write_document_attributes_to_preservation_layer(attributes = {})
45
+ def self.write_document_attributes_to_preservation_layer(attributes)
45
46
  Preservation.write_document(attributes)
46
47
  end
47
48
 
48
49
  # @api public
50
+ # @param attributes [Hash]
49
51
  # @return Hash - the attributes written to the indexing layer
50
- def self.write_document_attributes_to_index_layer(attributes = {})
52
+ def self.write_document_attributes_to_index_layer(attributes:)
51
53
  Index.write_document(attributes)
52
54
  end
53
55
 
@@ -1,13 +1,18 @@
1
1
  if defined?(RSpec)
2
2
  RSpec.shared_examples 'a Samvera::NestingIndexer::Adapter' do
3
- let(:required_parameters_extractor) { ->(method) { method.parameters.select { |type, kwarg| type == :keyreq }.map(&:last) } }
3
+ let(:required_keyword_parameters) { ->(method) { method.parameters.select { |type, kwarg| type == :keyreq }.map(&:last) } }
4
+ let(:required_parameters) { ->(method) { method.parameters.select { |type, kwarg| type == :keyreq || type == :req }.map(&:last) } }
4
5
  let(:block_parameter_extracter) { ->(method) { method.parameters.select { |type, kwarg| type == :block }.map(&:last) } }
5
6
 
6
7
  describe '.find_preservation_document_by' do
7
8
  subject { described_class.method(:find_preservation_document_by) }
8
9
 
9
10
  it 'requires the :id keyword (and does not require any others)' do
10
- expect(required_parameters_extractor.call(subject)).to eq([:id])
11
+ expect(required_keyword_parameters.call(subject)).to eq([:id])
12
+ end
13
+
14
+ it 'does not require any other parameters (besides :id)' do
15
+ expect(required_parameters.call(subject)).to eq(required_keyword_parameters.call(subject))
11
16
  end
12
17
 
13
18
  it 'does not expect a block' do
@@ -18,7 +23,11 @@ if defined?(RSpec)
18
23
  subject { described_class.method(:find_index_document_by) }
19
24
 
20
25
  it 'requires the :id keyword (and does not require any others)' do
21
- expect(required_parameters_extractor.call(subject)).to eq([:id])
26
+ expect(required_keyword_parameters.call(subject)).to eq([:id])
27
+ end
28
+
29
+ it 'does not require any other parameters (besides :id)' do
30
+ expect(required_parameters.call(subject)).to eq(required_keyword_parameters.call(subject))
22
31
  end
23
32
 
24
33
  it 'does not expect a block' do
@@ -29,7 +38,11 @@ if defined?(RSpec)
29
38
  subject { described_class.method(:each_preservation_document) }
30
39
 
31
40
  it 'requires no keywords' do
32
- expect(required_parameters_extractor.call(subject)).to eq([])
41
+ expect(required_keyword_parameters.call(subject)).to eq([])
42
+ end
43
+
44
+ it 'does not require any parameters' do
45
+ expect(required_parameters.call(subject)).to eq(required_keyword_parameters.call(subject))
33
46
  end
34
47
 
35
48
  it 'expects a block' do
@@ -40,7 +53,11 @@ if defined?(RSpec)
40
53
  subject { described_class.method(:each_child_document_of) }
41
54
 
42
55
  it 'requires the :document keyword (and does not require any others)' do
43
- expect(required_parameters_extractor.call(subject)).to eq([:document])
56
+ expect(required_keyword_parameters.call(subject)).to eq([:document])
57
+ end
58
+
59
+ it 'does not require any other parameters (besides :document)' do
60
+ expect(required_parameters.call(subject)).to eq(required_keyword_parameters.call(subject))
44
61
  end
45
62
 
46
63
  it 'expects a block' do
@@ -48,6 +65,19 @@ if defined?(RSpec)
48
65
  end
49
66
  end
50
67
  describe '.write_document_attributes_to_index_layer' do
68
+ subject { described_class.method(:write_document_attributes_to_index_layer) }
69
+
70
+ it 'requires the :attributes keyword (and does not require any others)' do
71
+ expect(required_keyword_parameters.call(subject)).to eq([:attributes])
72
+ end
73
+
74
+ it 'does not require any other parameters (besides :attributes)' do
75
+ expect(required_parameters.call(subject)).to eq(required_keyword_parameters.call(subject))
76
+ end
77
+
78
+ it 'does not expect a block' do
79
+ expect(block_parameter_extracter.call(subject)).to be_empty
80
+ end
51
81
  end
52
82
  end
53
83
  end
@@ -72,7 +72,7 @@ module Samvera
72
72
  raise Exceptions::CycleDetectionError, id if index_document.maximum_nesting_depth <= 0
73
73
  preservation_document = adapter.find_preservation_document_by(id: index_document.id)
74
74
  parent_ids_and_path_and_ancestors = parent_ids_and_path_and_ancestors_for(preservation_document)
75
- adapter.write_document_attributes_to_index_layer(parent_ids_and_path_and_ancestors)
75
+ adapter.write_document_attributes_to_index_layer(attributes: parent_ids_and_path_and_ancestors)
76
76
  end
77
77
 
78
78
  def parent_ids_and_path_and_ancestors_for(preservation_document)
@@ -1,5 +1,5 @@
1
1
  module Samvera
2
2
  module NestingIndexer
3
- VERSION = "0.3.0".freeze
3
+ VERSION = "0.3.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samvera-nesting_indexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen