blacklight_iiif_search 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +3 -1
  3. data/app/controllers/concerns/blacklight_iiif_search/controller.rb +7 -3
  4. data/app/models/blacklight_iiif_search/iiif_search.rb +2 -0
  5. data/app/models/blacklight_iiif_search/iiif_search_annotation.rb +4 -0
  6. data/app/models/blacklight_iiif_search/iiif_search_response.rb +2 -0
  7. data/app/models/blacklight_iiif_search/iiif_suggest_response.rb +2 -0
  8. data/app/models/blacklight_iiif_search/iiif_suggest_search.rb +4 -0
  9. data/app/models/concerns/blacklight_iiif_search/annotation_behavior.rb +2 -0
  10. data/app/models/concerns/blacklight_iiif_search/ignored.rb +2 -0
  11. data/app/models/concerns/blacklight_iiif_search/search_behavior.rb +2 -0
  12. data/lib/blacklight_iiif_search.rb +2 -0
  13. data/lib/blacklight_iiif_search/engine.rb +2 -0
  14. data/lib/blacklight_iiif_search/routes.rb +2 -0
  15. data/lib/blacklight_iiif_search/version.rb +3 -1
  16. data/lib/generators/blacklight_iiif_search/controller_generator.rb +4 -2
  17. data/lib/generators/blacklight_iiif_search/install_generator.rb +3 -2
  18. data/lib/generators/blacklight_iiif_search/model_generator.rb +2 -0
  19. data/lib/generators/blacklight_iiif_search/routes_generator.rb +12 -10
  20. data/lib/generators/blacklight_iiif_search/solr_generator.rb +24 -22
  21. data/lib/generators/blacklight_iiif_search/templates/iiif_search_builder.rb +2 -0
  22. data/lib/railties/blacklight_iiif_search.rake +2 -0
  23. data/spec/controllers/catalog_controller_spec.rb +13 -11
  24. data/spec/fixtures/sample_solr_documents.yml +116 -116
  25. data/spec/iiif_search_shared.rb +4 -2
  26. data/spec/models/blacklight_iiif_search/iiif_search_annotation_spec.rb +10 -8
  27. data/spec/models/blacklight_iiif_search/iiif_search_response_spec.rb +23 -19
  28. data/spec/models/blacklight_iiif_search/iiif_search_spec.rb +2 -0
  29. data/spec/models/blacklight_iiif_search/iiif_suggest_response_spec.rb +14 -12
  30. data/spec/models/blacklight_iiif_search/iiif_suggest_search_spec.rb +8 -6
  31. data/spec/models/concerns/blacklight_iiif_search/annotation_behavior_spec.rb +5 -6
  32. data/spec/models/concerns/blacklight_iiif_search/ignored_spec.rb +2 -0
  33. data/spec/models/concerns/blacklight_iiif_search/search_behavior_spec.rb +5 -3
  34. data/spec/spec_helper.rb +2 -0
  35. data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -0
  36. metadata +16 -44
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # shared variables that can be used across specs
2
4
  # https://relishapp.com/rspec/rspec-core/docs/example-groups/shared-context
3
5
  RSpec.shared_context 'iiif_search_shared' do
@@ -14,8 +16,8 @@ RSpec.shared_context 'iiif_search_shared' do
14
16
  let(:suggest_search_params) do
15
17
  { q: suggest_query_term, solr_document_id: parent_id, date: 'foo' }
16
18
  end
17
- let(:parent_document) { controller.fetch(parent_id)[1] }
18
- let(:page_document) { controller.fetch(page_id)[1] }
19
+ let(:parent_document) { controller.search_service.fetch(parent_id)[1] }
20
+ let(:page_document) { controller.search_service.fetch(page_id)[1] }
19
21
  let(:repository) { Blacklight::Solr::Repository.new(blacklight_config) }
20
22
 
21
23
  let(:iiif_search) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::IiifSearchAnnotation do
3
5
  include_context 'iiif_search_shared'
@@ -13,24 +15,24 @@ RSpec.describe BlacklightIiifSearch::IiifSearchAnnotation do
13
15
  end
14
16
 
15
17
  describe '#as_hash' do
16
- subject { iiif_search_annotation.as_hash }
18
+ subject(:anno_as_hash) { iiif_search_annotation.as_hash }
17
19
  it 'returns the correct object' do
18
- expect(subject.class).to eq(IIIF::Presentation::Annotation)
20
+ expect(anno_as_hash.class).to eq(IIIF::Presentation::Annotation)
19
21
  end
20
22
  it 'has a text resource' do
21
- expect(subject.resource.class).to eq(IIIF::Presentation::Resource)
23
+ expect(anno_as_hash.resource.class).to eq(IIIF::Presentation::Resource)
22
24
  end
23
25
  it 'has an "on" property' do
24
- expect(subject['on']).not_to be_blank
26
+ expect(anno_as_hash['on']).not_to be_blank
25
27
  end
26
28
  end
27
29
 
28
30
  describe '#text_resource_for_annotation' do
29
- subject { iiif_search_annotation.text_resource_for_annotation }
31
+ subject(:text_resource) { iiif_search_annotation.text_resource_for_annotation }
30
32
  it 'returns the correct object' do
31
- expect(subject.class).to eq(IIIF::Presentation::Resource)
32
- expect(subject['chars']).to include(query_term)
33
- expect(subject['chars']).not_to include('<em>')
33
+ expect(text_resource.class).to eq(IIIF::Presentation::Resource)
34
+ expect(text_resource['chars']).to include(query_term)
35
+ expect(text_resource['chars']).not_to include('<em>')
34
36
  end
35
37
  end
36
38
  end
@@ -1,10 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::IiifSearchResponse do
3
5
  include_context 'iiif_search_shared'
4
6
 
5
- let(:solr_response) do
6
- controller.search_results(iiif_search.solr_params).first
7
+ let(:iiif_search_service) do
8
+ controller.search_service_class.new(config: blacklight_config,
9
+ user_params: iiif_search.solr_params)
7
10
  end
11
+ let(:solr_response) { iiif_search_service.search_results.first }
8
12
  let(:iiif_search_response) do
9
13
  described_class.new(solr_response, parent_document, controller)
10
14
  end
@@ -16,40 +20,40 @@ RSpec.describe BlacklightIiifSearch::IiifSearchResponse do
16
20
  end
17
21
 
18
22
  describe '#annotation_list' do
19
- subject { iiif_search_response.annotation_list }
23
+ subject(:iiif_anno_list) { iiif_search_response.annotation_list }
20
24
 
21
25
  it 'returns an OrderedHash' do
22
- expect(subject.class).to eq(IIIF::OrderedHash)
26
+ expect(iiif_anno_list.class).to eq(IIIF::OrderedHash)
23
27
  end
24
28
 
25
29
  it 'has the correct content' do
26
- expect(subject['@id']).not_to be_falsey
27
- expect(subject['@type']).to eq('sc:AnnotationList')
28
- expect(subject['resources']).not_to be_blank
29
- expect(subject['within']).not_to be_blank
30
- expect(subject['hits']).not_to be_blank
30
+ expect(iiif_anno_list['@id']).not_to be_falsey
31
+ expect(iiif_anno_list['@type']).to eq('sc:AnnotationList')
32
+ expect(iiif_anno_list['resources']).not_to be_blank
33
+ expect(iiif_anno_list['within']).not_to be_blank
34
+ expect(iiif_anno_list['hits']).not_to be_blank
31
35
  end
32
36
 
33
37
  let(:hit) { subject['hits'].first }
34
38
  it 'has properly formatted search:Hit' do
35
39
  expect(hit[:@type]).to eq('search:Hit')
36
- expect(hit[:annotations].first).to eq(subject['resources'].first['@id'])
40
+ expect(hit[:annotations].first).to eq(iiif_anno_list['resources'].first['@id'])
37
41
  end
38
42
  end
39
43
 
40
44
  describe '#resources' do
41
- subject { iiif_search_response.resources }
45
+ subject(:response_resources) { iiif_search_response.resources }
42
46
  it 'returns an array of IiifSearchAnnotation objects' do
43
- expect(subject.length).to eq(2)
44
- expect(subject.first.class).to eq(IIIF::Presentation::Annotation)
47
+ expect(response_resources.length).to eq(2)
48
+ expect(response_resources.first.class).to eq(IIIF::Presentation::Annotation)
45
49
  end
46
50
  end
47
51
 
48
52
  describe '#clean_params' do
49
- subject { iiif_search_response.clean_params }
53
+ subject(:response_params) { iiif_search_response.clean_params }
50
54
  it 'returns an array of acceptable parameters' do
51
- expect(subject).to include('q')
52
- expect(subject).not_to include('date')
55
+ expect(response_params).to include('q')
56
+ expect(response_params).not_to include('date')
53
57
  end
54
58
  end
55
59
 
@@ -64,10 +68,10 @@ RSpec.describe BlacklightIiifSearch::IiifSearchResponse do
64
68
  end
65
69
 
66
70
  describe '#within' do
67
- subject { iiif_search_response.within }
71
+ subject(:response_within) { iiif_search_response.within }
68
72
  it 'returns a IIIF::Presentation::Layer object' do
69
- expect(subject.class).to eq(IIIF::Presentation::Layer)
70
- expect(subject['ignored']).to include('date')
73
+ expect(response_within.class).to eq(IIIF::Presentation::Layer)
74
+ expect(response_within['ignored']).to include('date')
71
75
  end
72
76
  end
73
77
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::IiifSearch do
3
5
  include_context 'iiif_search_shared'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::IiifSuggestResponse do
3
5
  include_context 'iiif_search_shared'
@@ -9,35 +11,35 @@ RSpec.describe BlacklightIiifSearch::IiifSuggestResponse do
9
11
  end
10
12
 
11
13
  describe '#term_list' do
12
- subject { iiif_suggest_response.term_list }
14
+ subject(:response_term_list) { iiif_suggest_response.term_list }
13
15
 
14
16
  it 'returns the correct class' do
15
- expect(subject.class).to eq(IIIF::OrderedHash)
17
+ expect(response_term_list.class).to eq(IIIF::OrderedHash)
16
18
  end
17
19
 
18
20
  it 'has the correct content' do
19
- expect(subject['@id']).not_to be_falsey
20
- expect(subject['@type']).to eq('search:TermList')
21
- expect(subject['terms']).not_to be_blank
21
+ expect(response_term_list['@id']).not_to be_falsey
22
+ expect(response_term_list['@type']).to eq('search:TermList')
23
+ expect(response_term_list['terms']).not_to be_blank
22
24
  end
23
25
  end
24
26
 
25
27
  describe '#terms' do
26
- subject { iiif_suggest_response.terms }
28
+ subject(:response_terms) { iiif_suggest_response.terms }
27
29
 
28
30
  it 'returns the expected data' do
29
- expect(subject.length).to eq(5)
30
- expect(subject.first[:url]).not_to be_falsey
31
- expect(subject.first[:match].match(/\A#{suggest_query_term}/)).to be_truthy
31
+ expect(response_terms.length).to eq(5)
32
+ expect(response_terms.first[:url]).not_to be_falsey
33
+ expect(response_terms.first[:match].match(/\A#{suggest_query_term}/)).to be_truthy
32
34
  end
33
35
  end
34
36
 
35
37
  describe '#iiif_search_url' do
36
- subject { iiif_suggest_response.iiif_search_url(suggest_query_term) }
38
+ subject(:response_urls) { iiif_suggest_response.iiif_search_url(suggest_query_term) }
37
39
 
38
40
  it 'returns a search url' do
39
- expect(subject).to include(parent_id)
40
- expect(subject).to include(suggest_query_term)
41
+ expect(response_urls).to include(parent_id)
42
+ expect(response_urls).to include(suggest_query_term)
41
43
  end
42
44
  end
43
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::IiifSuggestSearch do
3
5
  include_context 'iiif_search_shared'
@@ -9,26 +11,26 @@ RSpec.describe BlacklightIiifSearch::IiifSuggestSearch do
9
11
  end
10
12
 
11
13
  describe '#response' do
12
- subject { iiif_suggest_search.response }
14
+ subject(:suggest_response) { iiif_suggest_search.response }
13
15
 
14
16
  it 'returns the correct class' do
15
- expect(subject.class).to eq(IIIF::OrderedHash)
17
+ expect(suggest_response.class).to eq(IIIF::OrderedHash)
16
18
  end
17
19
 
18
20
  it 'returns the expected data' do
19
- expect(subject['terms'].length).to eq(5)
21
+ expect(suggest_response['terms'].length).to eq(5)
20
22
  end
21
23
  end
22
24
 
23
25
  describe '#suggest_results' do
24
- subject { iiif_suggest_search.suggest_results }
26
+ subject(:suggest_results) { iiif_suggest_search.suggest_results }
25
27
 
26
28
  it 'returns the correct class' do
27
- expect(subject.class).to eq(RSolr::HashWithResponse)
29
+ expect(suggest_results.class).to eq(RSolr::HashWithResponse)
28
30
  end
29
31
 
30
32
  it 'returns the expected data' do
31
- terms = subject['suggest'][blacklight_config.iiif_search[:suggester_name]][suggest_query_term]['suggestions']
33
+ terms = suggest_results['suggest'][blacklight_config.iiif_search[:suggester_name]][suggest_query_term]['suggestions']
32
34
  expect(terms.length).to eq(5)
33
35
  expect(terms.first['term'].match(/\A#{suggest_query_term}/)).to be_truthy
34
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::AnnotationBehavior do
3
5
  include_context 'iiif_search_shared'
@@ -9,23 +11,20 @@ RSpec.describe BlacklightIiifSearch::AnnotationBehavior do
9
11
  end
10
12
 
11
13
  describe '#annotation_id' do
12
- subject { iiif_search_annotation.annotation_id }
13
14
  it 'returns a properly formatted URL' do
14
- expect(subject).to include("#{parent_id}/canvas/#{page_id}/annotation/0")
15
+ expect(iiif_search_annotation.annotation_id).to include("#{parent_id}/canvas/#{page_id}/annotation/0")
15
16
  end
16
17
  end
17
18
 
18
19
  describe '#canvas_uri_for_annotation' do
19
- subject { iiif_search_annotation.canvas_uri_for_annotation }
20
20
  it 'returns a properly formatted URL' do
21
- expect(subject).to include("#{parent_id}/canvas/#{page_id}")
21
+ expect(iiif_search_annotation.canvas_uri_for_annotation).to include("#{parent_id}/canvas/#{page_id}")
22
22
  end
23
23
  end
24
24
 
25
25
  describe '#coordinates' do
26
- subject { iiif_search_annotation.coordinates }
27
26
  it 'returns a coordinate string' do
28
- expect(subject).to eq('#xywh=0,0,0,0')
27
+ expect(iiif_search_annotation.coordinates).to eq('#xywh=0,0,0,0')
29
28
  end
30
29
  end
31
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::Ignored do
3
5
  include_context 'iiif_search_shared'
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iiif_search_shared'
2
4
  RSpec.describe BlacklightIiifSearch::SearchBehavior do
3
5
  include_context 'iiif_search_shared'
4
6
 
5
7
  describe '#object_relation_solr_params' do
6
- subject { iiif_search.object_relation_solr_params }
8
+ subject(:relation_params) { iiif_search.object_relation_solr_params }
7
9
  it 'returns a hash with the correct content' do
8
- expect(subject.keys.first).to eq('is_page_of_s')
9
- expect(subject.values.first).to eq(parent_id)
10
+ expect(relation_params.keys.first).to eq('is_page_of_ssi')
11
+ expect(relation_params.values.first).to eq(parent_id)
10
12
  end
11
13
  end
12
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # testing environent:
2
4
  ENV['RAILS_ENV'] ||= 'test'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
 
3
5
  class TestAppGenerator < Rails::Generators::Base
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_iiif_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eben English
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-26 00:00:00.000000000 Z
11
+ date: 2020-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,34 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '5.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6'
22
+ version: '7'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.2'
29
+ version: '5.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6'
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: blacklight
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '6.0'
39
+ version: '7.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '6.0'
46
+ version: '7.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: iiif-presentation
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -90,16 +90,16 @@ dependencies:
90
90
  name: engine_cart
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ">="
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
95
+ version: '2.1'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ">="
100
+ - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0'
102
+ version: '2.1'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: byebug
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -115,47 +115,19 @@ dependencies:
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
- name: rubocop
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: 0.50.0
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: 0.50.0
131
- - !ruby/object:Gem::Dependency
132
- name: rubocop-rspec
118
+ name: bixby
133
119
  requirement: !ruby/object:Gem::Requirement
134
120
  requirements:
135
121
  - - "~>"
136
122
  - !ruby/object:Gem::Version
137
- version: 1.18.0
123
+ version: 1.0.0
138
124
  type: :development
139
125
  prerelease: false
140
126
  version_requirements: !ruby/object:Gem::Requirement
141
127
  requirements:
142
128
  - - "~>"
143
129
  - !ruby/object:Gem::Version
144
- version: 1.18.0
145
- - !ruby/object:Gem::Dependency
146
- name: bixby
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '0'
130
+ version: 1.0.0
159
131
  description: Blacklight IIIF Search plugin
160
132
  email:
161
133
  - eenglish@bpl.org
@@ -219,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
191
  version: '0'
220
192
  requirements: []
221
193
  rubyforge_project:
222
- rubygems_version: 2.6.14.3
194
+ rubygems_version: 2.7.6.2
223
195
  signing_key:
224
196
  specification_version: 4
225
197
  summary: Blacklight IIIF Search plugin