spotlight-dor-resources 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 +4 -4
- data/app/models/spotlight/resources/dor_resource.rb +3 -0
- data/lib/spotlight/dor/indexer.rb +15 -72
- data/lib/spotlight/dor/resources/version.rb +1 -1
- data/spec/lib/spotlight/dor/indexer_spec.rb +142 -285
- data/spec/models/spotlight/resources/purl_spec.rb +7 -0
- data/spotlight-dor-resources.gemspec +2 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 534c3d40d1d186aca706291383b277b9cb0e0cf5
|
4
|
+
data.tar.gz: 53c135866d04b314fea7bfb3bf9928552bd1ee85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b938262cb1da8a5fc3fc1e6c683ec34d502306bd3b0ccbf917d19141907203226af358649bad002e00ade0539a83793756e6e7a6f7bfd0c9fc093ed7f2b8a468
|
7
|
+
data.tar.gz: d377966f349fc1e1d627985e095729a7a76cbb1d24eb4afbd003c5375be501da5e50c72f93391e6136dddb8ac274aa657ceda00b98e3b69dae5f87c7b293cbb6
|
@@ -26,11 +26,16 @@ module Spotlight::Dor
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
+
# Functionality grouped when code was moved to the StanfordMods gem
|
29
30
|
concerning :StanfordMods do
|
30
31
|
included do
|
31
32
|
before_index :add_author_no_collector
|
33
|
+
before_index :add_box
|
32
34
|
before_index :add_collector
|
35
|
+
before_index :add_folder
|
33
36
|
before_index :add_genre
|
37
|
+
before_index :add_location
|
38
|
+
before_index :add_series
|
34
39
|
end
|
35
40
|
|
36
41
|
# add author_no_collector_ssim solr field containing the person authors, excluding collectors
|
@@ -39,92 +44,30 @@ module Spotlight::Dor
|
|
39
44
|
insert_field solr_doc, 'author_no_collector', sdb.smods_rec.non_collector_person_authors, :symbol # _ssim field
|
40
45
|
end
|
41
46
|
|
47
|
+
def add_box(sdb, solr_doc)
|
48
|
+
solr_doc['box_ssi'] = sdb.smods_rec.box
|
49
|
+
end
|
50
|
+
|
42
51
|
# add collector_ssim solr field containing the collector per MODS names (via stanford-mods gem)
|
43
52
|
def add_collector(sdb, solr_doc)
|
44
53
|
insert_field solr_doc, 'collector', sdb.smods_rec.collectors_w_dates, :symbol # _ssim field
|
45
54
|
end
|
46
55
|
|
56
|
+
def add_folder(sdb, solr_doc)
|
57
|
+
solr_doc['folder_ssi'] = sdb.smods_rec.folder
|
58
|
+
end
|
59
|
+
|
47
60
|
# add plain MODS <genre> element data, not the SearchWorks genre values
|
48
61
|
def add_genre(sdb, solr_doc)
|
49
62
|
insert_field solr_doc, 'genre', sdb.smods_rec.genre.content, :symbol # this is a _ssim field
|
50
63
|
end
|
51
|
-
end
|
52
64
|
|
53
|
-
concerning :PhysicalLocation do
|
54
|
-
included do
|
55
|
-
before_index :add_box
|
56
|
-
before_index :add_folder
|
57
|
-
before_index :add_location
|
58
|
-
before_index :add_series
|
59
|
-
end
|
60
|
-
|
61
|
-
# add the box number to solr_doc as box_ssi field (note: single valued!)
|
62
|
-
# data in location/physicalLocation or in relatedItem/location/physicalLocation
|
63
|
-
# TODO: push this up to stanford-mods gem? or should it be hierarchical series/box/folder?
|
64
|
-
def add_box(sdb, solr_doc)
|
65
|
-
# see spec for data from actual collections
|
66
|
-
# _location.physicalLocation should find top level and relatedItem
|
67
|
-
box_num = sdb.smods_rec._location.physicalLocation.map do |node|
|
68
|
-
val = node.text
|
69
|
-
# note that this will also find Flatbox or Flat-box
|
70
|
-
match_data = val.match(/Box ?:? ?([^,|(Folder)]+)/i)
|
71
|
-
match_data[1].strip if match_data.present?
|
72
|
-
end.compact
|
73
|
-
|
74
|
-
solr_doc['box_ssi'] = box_num.first
|
75
|
-
end
|
76
|
-
|
77
|
-
# add the folder number to solr_doc as folder_ssi field (note: single valued!)
|
78
|
-
# data in location/physicalLocation or in relatedItem/location/physicalLocation
|
79
|
-
# TODO: push this up to stanford-mods gem? or should it be hierarchical series/box/folder?
|
80
|
-
def add_folder(sdb, solr_doc)
|
81
|
-
# see spec for data from actual collections
|
82
|
-
# _location.physicalLocation should find top level and relatedItem
|
83
|
-
folder_num = sdb.smods_rec._location.physicalLocation.map do |node|
|
84
|
-
val = node.text
|
85
|
-
|
86
|
-
match_data = if val =~ /\|/
|
87
|
-
# we assume the data is pipe-delimited, and may contain commas within values
|
88
|
-
val.match(/Folder ?:? ?([^|]+)/)
|
89
|
-
else
|
90
|
-
# the data should be comma-delimited, and may not contain commas within values
|
91
|
-
val.match(/Folder ?:? ?([^,]+)/)
|
92
|
-
end
|
93
|
-
|
94
|
-
match_data[1].strip if match_data.present?
|
95
|
-
end.compact
|
96
|
-
|
97
|
-
solr_doc['folder_ssi'] = folder_num.first
|
98
|
-
end
|
99
|
-
|
100
|
-
# add the physicalLocation as location_ssi field (note: single valued!)
|
101
|
-
# but only if it has series, box or folder data
|
102
|
-
# data in location/physicalLocation or in relatedItem/location/physicalLocation
|
103
|
-
# TODO: push this up to stanford-mods gem? or should it be hierarchical series/box/folder?
|
104
65
|
def add_location(sdb, solr_doc)
|
105
|
-
|
106
|
-
# _location.physicalLocation should find top level and relatedItem
|
107
|
-
loc = sdb.smods_rec._location.physicalLocation.map do |node|
|
108
|
-
node.text if node.text.match(/.*(Series)|(Accession)|(Folder)|(Box).*/i)
|
109
|
-
end.compact
|
110
|
-
|
111
|
-
solr_doc['location_ssi'] = loc.first
|
66
|
+
solr_doc['location_ssi'] = sdb.smods_rec.location
|
112
67
|
end
|
113
68
|
|
114
|
-
# add the series/accession 'number' to solr_doc as series_ssi field (note: single valued!)
|
115
|
-
# data in location/physicalLocation or in relatedItem/location/physicalLocation
|
116
|
-
# TODO: push this up to stanford-mods gem? or should it be hierarchical series/box/folder?
|
117
69
|
def add_series(sdb, solr_doc)
|
118
|
-
|
119
|
-
# _location.physicalLocation should find top level and relatedItem
|
120
|
-
series_num = sdb.smods_rec._location.physicalLocation.map do |node|
|
121
|
-
val = node.text
|
122
|
-
# feigenbaum uses 'Accession'
|
123
|
-
match_data = val.match(/(?:(?:Series)|(?:Accession)):? ([^,|]+)/i)
|
124
|
-
match_data[1].strip if match_data.present?
|
125
|
-
end.compact
|
126
|
-
|
127
|
-
solr_doc['series_ssi'] = series_num.first
|
70
|
+
solr_doc['series_ssi'] = sdb.smods_rec.series
|
128
71
|
end
|
129
72
|
end
|
130
73
|
|
@@ -7,37 +7,6 @@ describe Spotlight::Dor::Indexer do
|
|
7
7
|
let(:r) { Harvestdor::Indexer::Resource.new(double, fake_druid) }
|
8
8
|
let(:sdb) { GDor::Indexer::SolrDocBuilder.new(r, Logger.new(StringIO.new)) }
|
9
9
|
let(:solr_doc) { {} }
|
10
|
-
let(:mods_loc_phys_loc) do
|
11
|
-
Nokogiri::XML <<-EOF
|
12
|
-
<mods xmlns="#{Mods::MODS_NS}">
|
13
|
-
<location>
|
14
|
-
<physicalLocation>#{example}</physicalLocation>
|
15
|
-
</location>
|
16
|
-
</mods>
|
17
|
-
EOF
|
18
|
-
end
|
19
|
-
let(:mods_rel_item_loc_phys_loc) do
|
20
|
-
Nokogiri::XML <<-EOF
|
21
|
-
<mods xmlns="#{Mods::MODS_NS}">
|
22
|
-
<relatedItem>
|
23
|
-
<location>
|
24
|
-
<physicalLocation>#{example}</physicalLocation>
|
25
|
-
</location>
|
26
|
-
</relatedItem>
|
27
|
-
</mods>
|
28
|
-
EOF
|
29
|
-
end
|
30
|
-
|
31
|
-
let(:mods_loc_multiple_phys_loc) do
|
32
|
-
Nokogiri::XML <<-EOF
|
33
|
-
<mods xmlns="#{Mods::MODS_NS}">
|
34
|
-
<location>
|
35
|
-
<physicalLocation>Irrelevant Data</physicalLocation>
|
36
|
-
<physicalLocation>#{example}</physicalLocation>
|
37
|
-
</location>
|
38
|
-
</mods>
|
39
|
-
EOF
|
40
|
-
end
|
41
10
|
|
42
11
|
before do
|
43
12
|
# reduce log noise
|
@@ -185,6 +154,41 @@ describe Spotlight::Dor::Indexer do
|
|
185
154
|
end
|
186
155
|
end
|
187
156
|
|
157
|
+
describe '#add_box' do
|
158
|
+
before do
|
159
|
+
allow(r).to receive(:mods).and_return(mods)
|
160
|
+
subject.send(:add_box, sdb, solr_doc)
|
161
|
+
end
|
162
|
+
context 'with a record without a box' do
|
163
|
+
let(:mods) do
|
164
|
+
Nokogiri::XML <<-EOF
|
165
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
166
|
+
</mods>
|
167
|
+
EOF
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'is blank' do
|
171
|
+
expect(solr_doc['box_ssi']).to be_blank
|
172
|
+
end
|
173
|
+
end
|
174
|
+
context 'with a record with a box' do
|
175
|
+
let(:mods) do
|
176
|
+
# e.g. from https://purl.stanford.edu/vw282gv1740
|
177
|
+
Nokogiri::XML <<-EOF
|
178
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
179
|
+
<location>
|
180
|
+
<physicalLocation>Series 1, Box 10, Folder 8</physicalLocation>
|
181
|
+
</location>
|
182
|
+
</mods>
|
183
|
+
EOF
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'extracts the box' do
|
187
|
+
expect(solr_doc['box_ssi']).to eq('10')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end # add_box
|
191
|
+
|
188
192
|
describe '#add_collector' do
|
189
193
|
before do
|
190
194
|
allow(r).to receive(:mods).and_return(mods)
|
@@ -212,6 +216,41 @@ describe Spotlight::Dor::Indexer do
|
|
212
216
|
end
|
213
217
|
end
|
214
218
|
|
219
|
+
describe '#add_folder' do
|
220
|
+
before do
|
221
|
+
allow(r).to receive(:mods).and_return(mods)
|
222
|
+
subject.send(:add_folder, sdb, solr_doc)
|
223
|
+
end
|
224
|
+
context 'with a record without a folder' do
|
225
|
+
let(:mods) do
|
226
|
+
Nokogiri::XML <<-EOF
|
227
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
228
|
+
</mods>
|
229
|
+
EOF
|
230
|
+
end
|
231
|
+
|
232
|
+
it 'is blank' do
|
233
|
+
expect(solr_doc['folder_ssi']).to be_blank
|
234
|
+
end
|
235
|
+
end
|
236
|
+
context 'with a record with a folder' do
|
237
|
+
let(:mods) do
|
238
|
+
# e.g. from https://purl.stanford.edu/vw282gv1740
|
239
|
+
Nokogiri::XML <<-EOF
|
240
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
241
|
+
<location>
|
242
|
+
<physicalLocation>Series 1, Box 10, Folder 8</physicalLocation>
|
243
|
+
</location>
|
244
|
+
</mods>
|
245
|
+
EOF
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'extracts the folder' do
|
249
|
+
expect(solr_doc['folder_ssi']).to eq('8')
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end # add_folder
|
253
|
+
|
215
254
|
describe '#add_genre' do
|
216
255
|
before do
|
217
256
|
allow(r).to receive(:mods).and_return(mods)
|
@@ -246,276 +285,94 @@ describe Spotlight::Dor::Indexer do
|
|
246
285
|
end
|
247
286
|
end
|
248
287
|
end
|
249
|
-
end
|
250
288
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
'
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
'SC0340, Accession 1986-052': '1986-052',
|
263
|
-
'SC0340, Accession 2005-101, Box 18': '2005-101',
|
264
|
-
'Call Number: SC0340, Accession 2005-101, Box: 42A, Folder: 24': '2005-101',
|
265
|
-
'Call Number: SC0340, Accession: 1986-052, Box: 42A, Folder: 59': '1986-052',
|
266
|
-
'SC0340': nil,
|
267
|
-
'SC0340, 1986-052, Box 18': nil,
|
268
|
-
'Stanford University. Libraries. Department of Special Collections and University Archives': nil,
|
269
|
-
# shpc (actually in <relatedItem><location><physicalLocation>)
|
270
|
-
'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan': 'Biographical Photographs',
|
271
|
-
'Series General Photographs | Box 42 | Folder Administration building--Outer Quad': 'General Photographs',
|
272
|
-
# menuez
|
273
|
-
'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6': '1',
|
274
|
-
'Series 1, Box 10, Folder 8': '1',
|
275
|
-
# fuller
|
276
|
-
'Collection: M1090 , Series: 4 , Box: 5 , Folder: 10': '4',
|
277
|
-
# hummel (actually in <relatedItem><location><physicalLocation>)
|
278
|
-
'Box 42 | Folder 3': nil,
|
279
|
-
'Flat-box 228 | Volume 1': nil
|
280
|
-
}.each do |example, expected|
|
281
|
-
describe "for example '#{example}'" do
|
282
|
-
let(:example) { example }
|
283
|
-
context 'in /location/physicalLocation' do
|
284
|
-
before do
|
285
|
-
allow(r).to receive(:mods).and_return(mods_loc_phys_loc)
|
286
|
-
subject.send(:add_series, sdb, solr_doc)
|
287
|
-
end
|
288
|
-
it "has the expected series name '#{expected}'" do
|
289
|
-
expect(solr_doc['series_ssi']).to eq expected
|
290
|
-
end
|
291
|
-
end
|
292
|
-
context 'in /relatedItem/location/physicalLocation' do
|
293
|
-
before do
|
294
|
-
allow(r).to receive(:mods).and_return(mods_rel_item_loc_phys_loc)
|
295
|
-
subject.send(:add_series, sdb, solr_doc)
|
296
|
-
end
|
297
|
-
it "has the expected series name '#{expected}'" do
|
298
|
-
expect(solr_doc['series_ssi']).to eq expected
|
299
|
-
end
|
300
|
-
end
|
301
|
-
context 'with multiple physicalLocation elements' do
|
302
|
-
before do
|
303
|
-
allow(r).to receive(:mods).and_return(mods_loc_multiple_phys_loc)
|
304
|
-
subject.send(:add_series, sdb, solr_doc)
|
305
|
-
end
|
306
|
-
it "has the expected series name '#{expected}'" do
|
307
|
-
expect(solr_doc['series_ssi']).to eq expected
|
308
|
-
end
|
289
|
+
describe '#add_location' do
|
290
|
+
before do
|
291
|
+
allow(r).to receive(:mods).and_return(mods)
|
292
|
+
subject.send(:add_location, sdb, solr_doc)
|
293
|
+
end
|
294
|
+
context 'with a record without a location' do
|
295
|
+
let(:mods) do
|
296
|
+
Nokogiri::XML <<-EOF
|
297
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
298
|
+
</mods>
|
299
|
+
EOF
|
309
300
|
end
|
310
|
-
end # for example
|
311
|
-
end # each
|
312
|
-
end # add_series
|
313
301
|
|
314
|
-
|
315
|
-
|
316
|
-
{
|
317
|
-
# feigenbaum
|
318
|
-
'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 1': '1',
|
319
|
-
'Call Number: SC0340, Accession 2005-101, Box: 39, Folder: 9': '39',
|
320
|
-
'Call Number: SC0340, Accession: 1986-052, Box 3 Folder 38': '3',
|
321
|
-
'Call Number: SC0340, Accession: 2005-101, Box : 50, Folder: 31': '50',
|
322
|
-
'Call Number: SC0340, Accession: 1986-052, Box: 5, Folder: 1': '5',
|
323
|
-
'SC0340, 1986-052, Box 18': '18',
|
324
|
-
'SC0340, Accession 2005-101, Box 18': '18',
|
325
|
-
'Call Number: SC0340, Accession 2005-101, Box: 42A, Folder: 24': '42A',
|
326
|
-
'Call Number: SC0340, Accession: 1986-052, Box: 42A, Folder: 59': '42A',
|
327
|
-
'Call Number: SC0340, Accession 2005-101': nil,
|
328
|
-
'Call Number: SC0340, Accession: 1986-052': nil,
|
329
|
-
'SC0340': nil,
|
330
|
-
'SC0340, Accession 1986-052': nil,
|
331
|
-
'Stanford University. Libraries. Department of Special Collections and University Archives': nil,
|
332
|
-
# shpc (actually in <relatedItem><location><physicalLocation>)
|
333
|
-
'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan': '42',
|
334
|
-
'Series General Photographs | Box 42 | Folder Administration building--Outer Quad': '42',
|
335
|
-
# menuez
|
336
|
-
'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6': '32',
|
337
|
-
'Series 1, Box 10, Folder 8': '10',
|
338
|
-
# fuller
|
339
|
-
'Collection: M1090 , Series: 1 , Box: 5 , Folder: 42': '5',
|
340
|
-
# hummel (actually in <relatedItem><location><physicalLocation>)
|
341
|
-
'Box 42 | Folder 3': '42',
|
342
|
-
'Flat-box 228 | Volume 1': '228'
|
343
|
-
}.each do |example, expected|
|
344
|
-
describe "for example '#{example}'" do
|
345
|
-
let(:example) { example }
|
346
|
-
context 'in /location/physicalLocation' do
|
347
|
-
before do
|
348
|
-
allow(r).to receive(:mods).and_return(mods_loc_phys_loc)
|
349
|
-
subject.send(:add_box, sdb, solr_doc)
|
350
|
-
end
|
351
|
-
it "has the expected box label '#{expected}'" do
|
352
|
-
expect(solr_doc['box_ssi']).to eq expected
|
353
|
-
end
|
302
|
+
it 'is blank' do
|
303
|
+
expect(solr_doc['location_ssi']).to be_blank
|
354
304
|
end
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
305
|
+
end
|
306
|
+
context 'with a record with a location' do
|
307
|
+
let(:mods) do
|
308
|
+
# e.g. from https://purl.stanford.edu/vw282gv1740
|
309
|
+
Nokogiri::XML <<-EOF
|
310
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
311
|
+
<location>
|
312
|
+
<physicalLocation>Series 1, Box 10, Folder 8</physicalLocation>
|
313
|
+
</location>
|
314
|
+
</mods>
|
315
|
+
EOF
|
363
316
|
end
|
364
317
|
|
365
|
-
|
366
|
-
|
367
|
-
allow(r).to receive(:mods).and_return(mods_loc_multiple_phys_loc)
|
368
|
-
subject.send(:add_box, sdb, solr_doc)
|
369
|
-
end
|
370
|
-
it "has the expected box label '#{expected}'" do
|
371
|
-
expect(solr_doc['box_ssi']).to eq expected
|
372
|
-
end
|
373
|
-
end
|
374
|
-
end # for example
|
375
|
-
end # each
|
376
|
-
end # add_box
|
377
|
-
|
378
|
-
describe '#add_folder' do
|
379
|
-
# example string as key, expected folder name as value
|
380
|
-
{
|
381
|
-
# feigenbaum
|
382
|
-
'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 42': '42',
|
383
|
-
'Call Number: SC0340, Accession 2005-101, Box: 2, Folder: 42': '42',
|
384
|
-
'Call Number: SC0340, Accession: 1986-052, Box 3 Folder 42': '42',
|
385
|
-
'Call Number: SC0340, Accession: 2005-101, Box : 4, Folder: 42': '42',
|
386
|
-
'Call Number: SC0340, Accession: 1986-052, Box: 5, Folder: 42': '42',
|
387
|
-
'Call Number: SC0340, Accession 2005-101, Box: 4A, Folder: 42': '42',
|
388
|
-
'Call Number: SC0340, Accession: 1986-052, Box: 5A, Folder: 42': '42',
|
389
|
-
'Call Number: SC0340, Accession 2005-101': nil,
|
390
|
-
'Call Number: SC0340, Accession: 1986-052': nil,
|
391
|
-
'SC0340': nil,
|
392
|
-
'SC0340, 1986-052, Box 18': nil,
|
393
|
-
'SC0340, Accession 2005-101': nil,
|
394
|
-
'SC0340, Accession 2005-101, Box 18': nil,
|
395
|
-
'Stanford University. Libraries. Department of Special Collections and University Archives': nil,
|
396
|
-
# menuez
|
397
|
-
'MSS Photo 451, Series 1, Box 32, Folder 42, Sleeve 32-11-2, Frame B32-F11-S2-6': '42',
|
398
|
-
'Series 1, Box 10, Folder 42': '42',
|
399
|
-
# fuller
|
400
|
-
'Collection: M1090 , Series: 4 , Box: 5 , Folder: 42': '42',
|
401
|
-
# hummel (actually in <relatedItem><location><physicalLocation>)
|
402
|
-
'Box 1 | Folder 42': '42',
|
403
|
-
'Flat-box 228 | Volume 1': nil,
|
404
|
-
# shpc (actually in <relatedItem><location><physicalLocation>)
|
405
|
-
'Series Biographical Photographs | Box 1 | Folder Abbot, Nathan': 'Abbot, Nathan',
|
406
|
-
'Series General Photographs | Box 1 | Folder Administration building--Outer Quad': 'Administration building--Outer Quad',
|
407
|
-
# hypothetical
|
408
|
-
'Folder: 42, Sheet: 15': '42'
|
409
|
-
}.each do |example, expected|
|
410
|
-
describe "for example '#{example}'" do
|
411
|
-
let(:example) { example }
|
412
|
-
context 'in /location/physicalLocation' do
|
413
|
-
before do
|
414
|
-
allow(r).to receive(:mods).and_return(mods_loc_phys_loc)
|
415
|
-
subject.send(:add_folder, sdb, solr_doc)
|
416
|
-
end
|
417
|
-
it "has the expected folder label '#{expected}'" do
|
418
|
-
expect(solr_doc['folder_ssi']).to eq expected
|
419
|
-
end
|
420
|
-
end
|
421
|
-
context 'in /relatedItem/location/physicalLocation' do
|
422
|
-
before do
|
423
|
-
allow(r).to receive(:mods).and_return(mods_rel_item_loc_phys_loc)
|
424
|
-
subject.send(:add_folder, sdb, solr_doc)
|
425
|
-
end
|
426
|
-
it "has the expected folder label '#{expected}'" do
|
427
|
-
expect(solr_doc['folder_ssi']).to eq expected
|
428
|
-
end
|
318
|
+
it 'extracts the location' do
|
319
|
+
expect(solr_doc['location_ssi']).to eq('Series 1, Box 10, Folder 8')
|
429
320
|
end
|
321
|
+
end
|
322
|
+
end # add_location
|
430
323
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
324
|
+
describe '#add_series' do
|
325
|
+
before do
|
326
|
+
allow(r).to receive(:mods).and_return(mods)
|
327
|
+
subject.send(:add_series, sdb, solr_doc)
|
328
|
+
end
|
329
|
+
context 'with a record without a series' do
|
330
|
+
let(:mods) do
|
331
|
+
Nokogiri::XML <<-EOF
|
332
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
333
|
+
</mods>
|
334
|
+
EOF
|
439
335
|
end
|
440
|
-
end # for example
|
441
|
-
end # each
|
442
|
-
end # add_folder
|
443
336
|
|
444
|
-
|
445
|
-
|
446
|
-
# example string as key, expected box name as value
|
447
|
-
{
|
448
|
-
# feigenbaum
|
449
|
-
'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 1': 'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 1',
|
450
|
-
'Call Number: SC0340, Accession 2005-101': 'Call Number: SC0340, Accession 2005-101',
|
451
|
-
'SC0340, 1986-052, Box 18': 'SC0340, 1986-052, Box 18',
|
452
|
-
'SC0340, Accession 2005-101, Box 18': 'SC0340, Accession 2005-101, Box 18',
|
453
|
-
'SC0340': nil,
|
454
|
-
'SC0340, Accession 1986-052': 'SC0340, Accession 1986-052',
|
455
|
-
'Stanford University. Libraries. Department of Special Collections and University Archives': nil,
|
456
|
-
# shpc (actually in <relatedItem><location><physicalLocation>)
|
457
|
-
'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan': 'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan',
|
458
|
-
'Series General Photographs | Box 42 | Folder Administration building--Outer Quad': 'Series General Photographs | Box 42 | Folder Administration building--Outer Quad',
|
459
|
-
# menuez
|
460
|
-
'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6': 'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6',
|
461
|
-
'Series 1, Box 10, Folder 8': 'Series 1, Box 10, Folder 8',
|
462
|
-
# fuller
|
463
|
-
'Collection: M1090 , Series: 1 , Box: 5 , Folder: 42': 'Collection: M1090 , Series: 1 , Box: 5 , Folder: 42',
|
464
|
-
# hummel (actually in <relatedItem><location><physicalLocation>)
|
465
|
-
'Box 42 | Folder 3': 'Box 42 | Folder 3',
|
466
|
-
'Flat-box 228 | Volume 1': 'Flat-box 228 | Volume 1'
|
467
|
-
}.each do |example, expected|
|
468
|
-
describe "for example '#{example}'" do
|
469
|
-
let(:example) { example }
|
470
|
-
context 'in /location/physicalLocation' do
|
471
|
-
before do
|
472
|
-
allow(r).to receive(:mods).and_return(mods_loc_phys_loc)
|
473
|
-
subject.send(:add_location, sdb, solr_doc)
|
474
|
-
end
|
475
|
-
it "has the expected location '#{expected}'" do
|
476
|
-
expect(solr_doc['location_ssi']).to eq expected
|
477
|
-
end
|
478
|
-
end
|
479
|
-
context 'in /relatedItem/location/physicalLocation' do
|
480
|
-
before do
|
481
|
-
allow(r).to receive(:mods).and_return(mods_rel_item_loc_phys_loc)
|
482
|
-
subject.send(:add_location, sdb, solr_doc)
|
483
|
-
end
|
484
|
-
it "has the expected location '#{expected}'" do
|
485
|
-
expect(solr_doc['location_ssi']).to eq expected
|
486
|
-
end
|
337
|
+
it 'is blank' do
|
338
|
+
expect(solr_doc['series_ssi']).to be_blank
|
487
339
|
end
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
340
|
+
end
|
341
|
+
context 'with a record with a series' do
|
342
|
+
let(:mods) do
|
343
|
+
# e.g. from https://purl.stanford.edu/vw282gv1740
|
344
|
+
Nokogiri::XML <<-EOF
|
345
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
346
|
+
<location>
|
347
|
+
<physicalLocation>Series 1, Box 10, Folder 8</physicalLocation>
|
348
|
+
</location>
|
349
|
+
</mods>
|
350
|
+
EOF
|
496
351
|
end
|
497
|
-
end # for example
|
498
|
-
end # each
|
499
|
-
end # add_location
|
500
|
-
# rubocop:enable Metrics/LineLength
|
501
352
|
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
end
|
509
|
-
let(:mods_note_preferred_citation) do
|
510
|
-
Nokogiri::XML <<-EOF
|
511
|
-
<mods xmlns="#{Mods::MODS_NS}">
|
512
|
-
<note type="preferred citation">#{example}</note>
|
513
|
-
</mods>
|
514
|
-
EOF
|
515
|
-
end
|
353
|
+
it 'extracts the series' do
|
354
|
+
expect(solr_doc['series_ssi']).to eq('1')
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end # add_series
|
358
|
+
end # context StanfordMods concern
|
516
359
|
|
517
360
|
# rubocop:disable Metrics/LineLength
|
518
361
|
describe '#add_folder_name' do
|
362
|
+
let(:mods_note_plain) do
|
363
|
+
Nokogiri::XML <<-EOF
|
364
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
365
|
+
<note>#{example}</note>
|
366
|
+
</mods>
|
367
|
+
EOF
|
368
|
+
end
|
369
|
+
let(:mods_note_preferred_citation) do
|
370
|
+
Nokogiri::XML <<-EOF
|
371
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
372
|
+
<note type="preferred citation">#{example}</note>
|
373
|
+
</mods>
|
374
|
+
EOF
|
375
|
+
end
|
519
376
|
# example string as key, expected folder name as value
|
520
377
|
# all from feigenbaum (or based on feigenbaum), as that is only coll with this data
|
521
378
|
{
|
@@ -107,6 +107,13 @@ describe Spotlight::Resources::Purl do
|
|
107
107
|
expect(Spotlight::Dor::Resources.indexer).to receive(:solr_document).and_raise(RuntimeError.new)
|
108
108
|
expect { subject.to_solr.to_a }.not_to raise_error
|
109
109
|
end
|
110
|
+
|
111
|
+
it 'log and raises other types of errors errors' do
|
112
|
+
allow(subject.resource).to receive(:items).and_return([])
|
113
|
+
expect(Spotlight::Dor::Resources.indexer).to receive(:solr_document).and_raise(StandardError.new)
|
114
|
+
expect(subject.send(:logger)).to receive(:error).with(/Error processing xf680rd3068/)
|
115
|
+
expect { subject.to_solr.to_a }.to raise_error StandardError
|
116
|
+
end
|
110
117
|
end
|
111
118
|
|
112
119
|
context 'with a single item' do
|
@@ -22,10 +22,11 @@ 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
|
26
25
|
spec.add_dependency 'gdor-indexer'
|
27
26
|
# newer versions of harvestdor-indexer have performance improvements for collections
|
28
27
|
spec.add_dependency 'harvestdor-indexer', '~> 2.3'
|
28
|
+
# stanford-mods 1.2.1 includes additional name fields and a bug fix
|
29
|
+
spec.add_dependency 'stanford-mods', '>= 1.2.1'
|
29
30
|
spec.add_dependency 'rails'
|
30
31
|
spec.add_dependency 'blacklight-spotlight', '~> 0.6'
|
31
32
|
spec.add_dependency 'parallel'
|
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.3.
|
4
|
+
version: 0.3.1
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -39,47 +39,47 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: gdor-indexer
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: harvestdor-indexer
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.3'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: stanford-mods
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.2.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.2.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|