spotlight-dor-resources 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spotlight/dor/indexer.rb +27 -11
- data/lib/spotlight/dor/resources/version.rb +1 -1
- data/spec/lib/spotlight/dor/indexer_spec.rb +77 -15
- data/spotlight-dor-resources.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 802c000f217f5bffac45eeb8cd3622426f952c2b
|
4
|
+
data.tar.gz: b14c29105325cb00da514397812df7a5c333e14e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f3834e96cdbb9edf59100b3bb782af5731d51151eaa7e55363ae617267fc1a937744eb84e9299e58c2192ef2fed1403c875b8740e25dc1ad8c9dbc5eb01f06d
|
7
|
+
data.tar.gz: 0f24b3fccaa36d56e215f1f8bd4582971e371f7194976691f545d449ae55b77fb457fc6b23851ce47a19e14777acfaa7a05e5024e83beaeb592c5eddd3905123
|
@@ -9,29 +9,45 @@ require 'faraday'
|
|
9
9
|
module Spotlight::Dor
|
10
10
|
# Base class to harvest from DOR via harvestdor gem
|
11
11
|
class Indexer < GDor::Indexer
|
12
|
-
|
13
|
-
|
14
|
-
solr_doc[:author_sort] &&= solr_doc[:author_sort].tr("\uFFFF", "\uFFFD")
|
12
|
+
def resource(druid)
|
13
|
+
Harvestdor::Indexer::Resource.new harvestdor, druid
|
15
14
|
end
|
16
15
|
|
17
|
-
# add fields from raw mods
|
18
|
-
before_index :add_genre
|
19
|
-
|
20
16
|
def solr_document(resource)
|
21
17
|
doc_hash = super
|
22
18
|
run_hook :before_index, resource, doc_hash
|
23
19
|
doc_hash
|
24
20
|
end
|
25
21
|
|
26
|
-
|
27
|
-
|
22
|
+
# tweak author_sort field from stanford-mods
|
23
|
+
before_index do |_sdb, solr_doc|
|
24
|
+
solr_doc[:author_sort] &&= solr_doc[:author_sort].tr("\uFFFF", "\uFFFD")
|
28
25
|
end
|
29
26
|
|
30
27
|
private
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
concerning :StanfordMods do
|
30
|
+
included do
|
31
|
+
before_index :add_author_no_collector
|
32
|
+
before_index :add_collector
|
33
|
+
before_index :add_genre
|
34
|
+
end
|
35
|
+
|
36
|
+
# add author_no_collector_ssim solr field containing the person authors, excluding collectors
|
37
|
+
# (via stanford-mods gem)
|
38
|
+
def add_author_no_collector(sdb, solr_doc)
|
39
|
+
insert_field solr_doc, 'author_no_collector', sdb.smods_rec.non_collector_person_authors, :symbol # _ssim field
|
40
|
+
end
|
41
|
+
|
42
|
+
# add collector_ssim solr field containing the collector per MODS names (via stanford-mods gem)
|
43
|
+
def add_collector(sdb, solr_doc)
|
44
|
+
insert_field solr_doc, 'collector', sdb.smods_rec.collectors_w_dates, :symbol # _ssim field
|
45
|
+
end
|
46
|
+
|
47
|
+
# add plain MODS <genre> element data, not the SearchWorks genre values
|
48
|
+
def add_genre(sdb, solr_doc)
|
49
|
+
insert_field solr_doc, 'genre', sdb.smods_rec.genre.content, :symbol # this is a _ssim field
|
50
|
+
end
|
35
51
|
end
|
36
52
|
|
37
53
|
concerning :PhysicalLocation do
|
@@ -151,37 +151,99 @@ describe Spotlight::Dor::Indexer do
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
154
|
+
context 'StanfordMods concern' do
|
155
|
+
describe '#add_author_no_collector' do
|
156
|
+
before do
|
157
|
+
allow(r).to receive(:mods).and_return(mods)
|
158
|
+
subject.send(:add_author_no_collector, sdb, solr_doc)
|
159
|
+
end
|
160
|
+
let(:name) { 'Macro Hamster' }
|
161
161
|
let(:mods) do
|
162
162
|
Nokogiri::XML <<-EOF
|
163
163
|
<mods xmlns="#{Mods::MODS_NS}">
|
164
|
+
<name type="personal">
|
165
|
+
<namePart>#{name}</namePart>
|
166
|
+
<role>
|
167
|
+
<roleTerm type="code" authority="marcrelator">cre</roleTerm>
|
168
|
+
</role>
|
169
|
+
</name>
|
170
|
+
<name type="personal">
|
171
|
+
<namePart>Ignored</namePart>
|
172
|
+
<role>
|
173
|
+
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
174
|
+
</role>
|
175
|
+
</name>
|
164
176
|
</mods>
|
165
177
|
EOF
|
166
178
|
end
|
167
|
-
|
168
|
-
|
169
|
-
|
179
|
+
it 'populates author_no_collector_ssim field in solr doc' do
|
180
|
+
expect(solr_doc['author_no_collector_ssim']).to eq [name]
|
181
|
+
end
|
182
|
+
it 'calls non_collector_person_authors on Stanford::Mods::Record object' do
|
183
|
+
expect(sdb.smods_rec).to receive(:non_collector_person_authors)
|
184
|
+
subject.send(:add_author_no_collector, sdb, solr_doc)
|
170
185
|
end
|
171
186
|
end
|
172
187
|
|
173
|
-
|
188
|
+
describe '#add_collector' do
|
189
|
+
before do
|
190
|
+
allow(r).to receive(:mods).and_return(mods)
|
191
|
+
subject.send(:add_collector, sdb, solr_doc)
|
192
|
+
end
|
193
|
+
let(:name) { 'Macro Hamster' }
|
174
194
|
let(:mods) do
|
175
|
-
# e.g. from https://purl.stanford.edu/vw282gv1740
|
176
195
|
Nokogiri::XML <<-EOF
|
177
196
|
<mods xmlns="#{Mods::MODS_NS}">
|
178
|
-
<
|
197
|
+
<name type="personal">
|
198
|
+
<namePart>#{name}</namePart>
|
199
|
+
<role>
|
200
|
+
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
201
|
+
</role>
|
202
|
+
</name>
|
179
203
|
</mods>
|
180
204
|
EOF
|
181
205
|
end
|
206
|
+
it 'populates collector_ssim field in solr doc' do
|
207
|
+
expect(solr_doc['collector_ssim']).to eq [name]
|
208
|
+
end
|
209
|
+
it 'calls collectors_w_dates on Stanford::Mods::Record object' do
|
210
|
+
expect(sdb.smods_rec).to receive(:collectors_w_dates)
|
211
|
+
subject.send(:add_collector, sdb, solr_doc)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe '#add_genre' do
|
216
|
+
before do
|
217
|
+
allow(r).to receive(:mods).and_return(mods)
|
218
|
+
subject.send(:add_genre, sdb, solr_doc)
|
219
|
+
end
|
182
220
|
|
183
|
-
|
184
|
-
|
221
|
+
context 'with a record without a genre' do
|
222
|
+
let(:mods) do
|
223
|
+
Nokogiri::XML <<-EOF
|
224
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
225
|
+
</mods>
|
226
|
+
EOF
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'is blank' do
|
230
|
+
expect(solr_doc['genre_ssim']).to be_blank
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context 'with a record with a genre' do
|
235
|
+
let(:mods) do
|
236
|
+
# e.g. from https://purl.stanford.edu/vw282gv1740
|
237
|
+
Nokogiri::XML <<-EOF
|
238
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
239
|
+
<genre authority="aat" valueURI="http://vocab.getty.edu/aat/300028579">manuscripts for publication</genre>
|
240
|
+
</mods>
|
241
|
+
EOF
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'extracts the genre' do
|
245
|
+
expect(solr_doc['genre_ssim']).to contain_exactly 'manuscripts for publication'
|
246
|
+
end
|
185
247
|
end
|
186
248
|
end
|
187
249
|
end
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency 'faraday'
|
24
24
|
spec.add_dependency 'solrizer'
|
25
|
+
spec.add_dependency 'stanford-mods', '>= 1.2.0' # includes new person facets
|
25
26
|
spec.add_dependency 'gdor-indexer'
|
26
27
|
# newer versions of harvestdor-indexer have performance improvements for collections
|
27
28
|
spec.add_dependency 'harvestdor-indexer', '~> 2.3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spotlight-dor-resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: stanford-mods
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: gdor-indexer
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|