stanford-mods 2.6.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/lib/stanford-mods/{geo_spatial.rb → concerns/geo_spatial.rb} +3 -5
- data/lib/stanford-mods/concerns/name.rb +57 -0
- data/lib/stanford-mods/concerns/origin_info.rb +113 -0
- data/lib/stanford-mods/{physical_location.rb → concerns/physical_location.rb} +2 -2
- data/lib/stanford-mods/concerns/searchworks.rb +125 -0
- data/lib/stanford-mods/concerns/searchworks_subjects.rb +126 -0
- data/lib/stanford-mods/concerns/title.rb +87 -0
- data/lib/stanford-mods/coordinate.rb +24 -3
- data/lib/stanford-mods/date_parsing.rb +32 -289
- data/lib/stanford-mods/imprint.rb +170 -322
- data/lib/stanford-mods/record.rb +20 -0
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods/{searchworks_languages.rb → vocabularies/searchworks_languages.rb} +0 -0
- data/lib/stanford-mods.rb +12 -11
- data/spec/fixtures/searchworks_imprint_data.rb +38 -39
- data/spec/fixtures/searchworks_pub_date_data.rb +7 -7
- data/spec/fixtures/spotlight_pub_date_data.rb +7 -7
- data/spec/geo_spatial_spec.rb +1 -6
- data/spec/imprint_spec.rb +263 -207
- data/spec/lib/stanford-mods/coordinate_spec.rb +3 -5
- data/spec/name_spec.rb +26 -230
- data/spec/origin_info_spec.rb +34 -300
- data/spec/searchworks_basic_spec.rb +1 -3
- data/spec/searchworks_pub_dates_spec.rb +0 -215
- data/spec/searchworks_spec.rb +0 -21
- data/spec/searchworks_subject_raw_spec.rb +106 -105
- data/spec/searchworks_subject_spec.rb +19 -55
- data/spec/searchworks_title_spec.rb +5 -5
- data/stanford-mods.gemspec +1 -1
- metadata +19 -15
- data/lib/marc_countries.rb +0 -387
- data/lib/stanford-mods/geo_utils.rb +0 -28
- data/lib/stanford-mods/name.rb +0 -80
- data/lib/stanford-mods/origin_info.rb +0 -489
- data/lib/stanford-mods/searchworks.rb +0 -333
- data/lib/stanford-mods/searchworks_subjects.rb +0 -196
- data/spec/date_parsing_spec.rb +0 -905
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
describe "Searchworks mixin for Stanford::Mods::Record" do
|
3
3
|
before(:all) do
|
4
|
-
@smods_rec = Stanford::Mods::Record.new
|
5
4
|
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
6
5
|
end
|
7
6
|
|
@@ -18,7 +17,10 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
18
17
|
@temporal = 'temporal'
|
19
18
|
@s_title = 'title in subject'
|
20
19
|
@topic = 'topic'
|
21
|
-
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:m) do
|
23
|
+
"<mods #{@ns_decl}>
|
22
24
|
<genre>#{@genre}</genre>
|
23
25
|
<subject><cartographics><coordinates>#{@cart_coord}</coordinates></cartographics></subject>
|
24
26
|
<subject><genre>#{@s_genre}</genre></subject>
|
@@ -31,26 +33,30 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
31
33
|
<subject><titleInfo><title>#{@s_title}</title></titleInfo></subject>
|
32
34
|
<subject><topic>#{@topic}</topic></subject>
|
33
35
|
</mods>"
|
36
|
+
end
|
37
|
+
|
38
|
+
before do
|
39
|
+
@smods_rec = Stanford::Mods::Record.new
|
34
40
|
@smods_rec.from_str m
|
35
|
-
@sw_geographic_search = @smods_rec.sw_geographic_search
|
36
|
-
@sw_subject_titles = @smods_rec.sw_subject_titles
|
37
|
-
@sw_subject_names = @smods_rec.sw_subject_names
|
38
41
|
end
|
39
42
|
|
40
|
-
context "
|
43
|
+
context "subject_names" do
|
44
|
+
subject(:subject_names) do
|
45
|
+
@smods_rec.send(:subject_names)
|
46
|
+
end
|
41
47
|
it "should contain <subject><name><namePart> values" do
|
42
|
-
expect(
|
48
|
+
expect(subject_names).to include(@s_name)
|
43
49
|
end
|
44
50
|
it "should not contain non-name subject subelements" do
|
45
|
-
expect(
|
46
|
-
expect(
|
47
|
-
expect(
|
48
|
-
expect(
|
49
|
-
expect(
|
50
|
-
expect(
|
51
|
-
expect(
|
52
|
-
expect(
|
53
|
-
expect(
|
51
|
+
expect(subject_names).not_to include(@cart_coord)
|
52
|
+
expect(subject_names).not_to include(@s_genre)
|
53
|
+
expect(subject_names).not_to include(@geo)
|
54
|
+
expect(subject_names).not_to include(@geo_code)
|
55
|
+
expect(subject_names).not_to include(@hier_geo_country)
|
56
|
+
expect(subject_names).not_to include(@occupation)
|
57
|
+
expect(subject_names).not_to include(@temporal)
|
58
|
+
expect(subject_names).not_to include(@topic)
|
59
|
+
expect(subject_names).not_to include(@s_title)
|
54
60
|
end
|
55
61
|
it "should not contain subject/name/role" do
|
56
62
|
m = "<mods #{@ns_decl}>
|
@@ -63,7 +69,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
63
69
|
</role>
|
64
70
|
</name></subject></mods>"
|
65
71
|
@smods_rec.from_str m
|
66
|
-
expect(@smods_rec.
|
72
|
+
expect(@smods_rec.send(:subject_names).find { |sn| sn =~ /cre/ }).to be_nil
|
67
73
|
end
|
68
74
|
it "should not contain subject/name/affiliation" do
|
69
75
|
m = "<mods #{@ns_decl}>
|
@@ -73,7 +79,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
73
79
|
<affiliation>Chemistry Dept., American University</affiliation>
|
74
80
|
</name></subject></mods>"
|
75
81
|
@smods_rec.from_str m
|
76
|
-
expect(@smods_rec.
|
82
|
+
expect(@smods_rec.send(:subject_names).find { |sn| sn =~ /Chemistry/ }).to be_nil
|
77
83
|
end
|
78
84
|
it "should not contain subject/name/description" do
|
79
85
|
m = "<mods #{@ns_decl}>
|
@@ -82,7 +88,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
82
88
|
<description>American artist, 20th c.</description>
|
83
89
|
</name></subject></mods>"
|
84
90
|
@smods_rec.from_str m
|
85
|
-
expect(@smods_rec.
|
91
|
+
expect(@smods_rec.send(:subject_names).find { |sn| sn =~ /artist/ }).to be_nil
|
86
92
|
end
|
87
93
|
it "should not include top level name element" do
|
88
94
|
m = "<mods #{@ns_decl}>
|
@@ -91,7 +97,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
91
97
|
<description>American artist, 20th c.</description>
|
92
98
|
</name></mods>"
|
93
99
|
@smods_rec.from_str m
|
94
|
-
expect(@smods_rec.
|
100
|
+
expect(@smods_rec.send(:subject_names)).to eq([])
|
95
101
|
end
|
96
102
|
it "should have one value for each name element" do
|
97
103
|
m = "<mods #{@ns_decl}>
|
@@ -104,59 +110,57 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
104
110
|
</subject>
|
105
111
|
</mods>"
|
106
112
|
@smods_rec.from_str m
|
107
|
-
expect(@smods_rec.
|
113
|
+
expect(@smods_rec.send(:subject_names)).to eq(['first', 'second', 'third'])
|
108
114
|
end
|
109
115
|
it "should be an empty Array if there are no values in the mods" do
|
110
116
|
m = "<mods #{@ns_decl}><note>notit</note></mods>"
|
111
117
|
@smods_rec.from_str m
|
112
|
-
expect(@smods_rec.
|
118
|
+
expect(@smods_rec.send(:subject_names)).to eq([])
|
113
119
|
end
|
114
120
|
it "should be an empty Array if there are empty values in the mods" do
|
115
121
|
m = "<mods #{@ns_decl}><subject><name><namePart/></name></subject><note>notit</note></mods>"
|
116
122
|
@smods_rec.from_str m
|
117
|
-
expect(@smods_rec.
|
123
|
+
expect(@smods_rec.send(:subject_names)).to eq([])
|
118
124
|
end
|
119
125
|
context "combining subelements" do
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
@smods_rec.from_str m
|
126
|
+
let(:m) do
|
127
|
+
"<mods #{@ns_decl}>
|
128
|
+
<subject>
|
129
|
+
<name>
|
130
|
+
<namePart>first</namePart>
|
131
|
+
<namePart>second</namePart>
|
132
|
+
</name>
|
133
|
+
</subject>
|
134
|
+
</mods>"
|
130
135
|
end
|
131
136
|
|
132
137
|
it "uses a ', ' as the separator by default" do
|
133
|
-
expect(@smods_rec.
|
134
|
-
end
|
135
|
-
it "honors any string value passed in for the separator" do
|
136
|
-
expect(@smods_rec.sw_subject_names(' --')).to eq(['first --second'])
|
138
|
+
expect(@smods_rec.send(:subject_names)).to eq ['first, second']
|
137
139
|
end
|
138
140
|
end
|
139
|
-
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "subject_titles" do
|
144
|
+
subject(:subject_titles) { @smods_rec.send(:subject_titles) }
|
140
145
|
|
141
|
-
context "sw_subject_titles" do
|
142
146
|
it "should contain <subject><titleInfo> subelement values" do
|
143
|
-
expect(
|
147
|
+
expect(subject_titles).to include(@s_title)
|
144
148
|
end
|
145
149
|
it "should not contain non-name subject subelements" do
|
146
|
-
expect(
|
147
|
-
expect(
|
148
|
-
expect(
|
149
|
-
expect(
|
150
|
-
expect(
|
151
|
-
expect(
|
152
|
-
expect(
|
153
|
-
expect(
|
154
|
-
expect(
|
150
|
+
expect(subject_titles).not_to include(@cart_coord)
|
151
|
+
expect(subject_titles).not_to include(@s_genre)
|
152
|
+
expect(subject_titles).not_to include(@geo)
|
153
|
+
expect(subject_titles).not_to include(@geo_code)
|
154
|
+
expect(subject_titles).not_to include(@hier_geo_country)
|
155
|
+
expect(subject_titles).not_to include(@s_name)
|
156
|
+
expect(subject_titles).not_to include(@occupation)
|
157
|
+
expect(subject_titles).not_to include(@temporal)
|
158
|
+
expect(subject_titles).not_to include(@topic)
|
155
159
|
end
|
156
160
|
it "should not include top level titleInfo element" do
|
157
161
|
m = "<mods #{@ns_decl}><titleInfo><title>Oklahoma</title></titleInfo></mods>"
|
158
162
|
@smods_rec.from_str m
|
159
|
-
expect(@smods_rec.
|
163
|
+
expect(@smods_rec.send(:subject_titles)).to eq([])
|
160
164
|
end
|
161
165
|
it "should have one value for each titleInfo element" do
|
162
166
|
m = "<mods #{@ns_decl}>
|
@@ -169,37 +173,34 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
169
173
|
</subject>
|
170
174
|
</mods>"
|
171
175
|
@smods_rec.from_str m
|
172
|
-
expect(@smods_rec.
|
176
|
+
expect(@smods_rec.send(:subject_titles)).to eq(['first', 'second', 'third'])
|
173
177
|
end
|
174
178
|
it "should be an empty Array if there are no values in the mods" do
|
175
179
|
m = "<mods #{@ns_decl}><note>notit</note></mods>"
|
176
180
|
@smods_rec.from_str m
|
177
|
-
expect(@smods_rec.
|
181
|
+
expect(@smods_rec.send(:subject_titles)).to eq([])
|
178
182
|
end
|
179
183
|
it "should be an empty Array if there are empty values in the mods" do
|
180
184
|
m = "<mods #{@ns_decl}><subject><titleInfo><title/></titleInfo></subject><note>notit</note></mods>"
|
181
185
|
@smods_rec.from_str m
|
182
|
-
expect(@smods_rec.
|
186
|
+
expect(@smods_rec.send(:subject_titles)).to eq([])
|
183
187
|
end
|
184
188
|
context "combining subelements" do
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
@smods_rec.from_str m
|
189
|
+
let(:m) do
|
190
|
+
"<mods #{@ns_decl}>
|
191
|
+
<subject>
|
192
|
+
<titleInfo>
|
193
|
+
<title>first</title>
|
194
|
+
<subTitle>second</subTitle>
|
195
|
+
</titleInfo>
|
196
|
+
</subject>
|
197
|
+
</mods>"
|
195
198
|
end
|
196
199
|
|
197
200
|
it "uses a ' ' as the separator by default" do
|
198
|
-
expect(@smods_rec.
|
199
|
-
end
|
200
|
-
it "honors any string value passed in for the separator" do
|
201
|
-
expect(@smods_rec.sw_subject_titles(' --')).to eq(['first --second'])
|
201
|
+
expect(@smods_rec.send(:subject_titles)).to eq ['first second']
|
202
202
|
end
|
203
|
+
|
203
204
|
it "includes all subelements in the order of occurrence" do
|
204
205
|
m = "<mods #{@ns_decl}>
|
205
206
|
<subject>
|
@@ -213,52 +214,54 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
213
214
|
</subject>
|
214
215
|
</mods>"
|
215
216
|
@smods_rec.from_str m
|
216
|
-
expect(@smods_rec.
|
217
|
+
expect(@smods_rec.send(:subject_titles)).to eq(['1 2 3 4 5'])
|
217
218
|
end
|
218
219
|
end
|
219
|
-
end #
|
220
|
+
end # subject_titles
|
220
221
|
|
221
222
|
context "sw_geographic_search" do
|
223
|
+
subject(:geographic_search) { @smods_rec.geographic_search }
|
224
|
+
|
222
225
|
it "should contain subject <geographic> subelement data" do
|
223
|
-
expect(
|
226
|
+
expect(geographic_search).to include(@geo)
|
224
227
|
end
|
225
228
|
it "should contain subject <hierarchicalGeographic> subelement data" do
|
226
|
-
expect(
|
229
|
+
expect(geographic_search).to include(@hier_geo_country)
|
227
230
|
end
|
228
231
|
it "should contain translation of <geographicCode> subelement data with translated authorities" do
|
229
232
|
m = "<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>"
|
230
233
|
@smods_rec.from_str m
|
231
|
-
expect(@smods_rec.
|
234
|
+
expect(@smods_rec.geographic_search).to include('Estonia')
|
232
235
|
end
|
233
236
|
it "should not contain other subject element data" do
|
234
|
-
expect(
|
235
|
-
expect(
|
236
|
-
expect(
|
237
|
-
expect(
|
238
|
-
expect(
|
239
|
-
expect(
|
240
|
-
expect(
|
241
|
-
expect(
|
237
|
+
expect(geographic_search).not_to include(@genre)
|
238
|
+
expect(geographic_search).not_to include(@cart_coord)
|
239
|
+
expect(geographic_search).not_to include(@s_genre)
|
240
|
+
expect(geographic_search).not_to include(@s_name)
|
241
|
+
expect(geographic_search).not_to include(@occupation)
|
242
|
+
expect(geographic_search).not_to include(@temporal)
|
243
|
+
expect(geographic_search).not_to include(@topic)
|
244
|
+
expect(geographic_search).not_to include(@s_title)
|
242
245
|
end
|
243
246
|
it "should be [] if there are no values in the MODS" do
|
244
247
|
m = "<mods #{@ns_decl}><note>notit</note></mods>"
|
245
248
|
@smods_rec.from_str m
|
246
|
-
expect(@smods_rec.
|
249
|
+
expect(@smods_rec.geographic_search).to eq([])
|
247
250
|
end
|
248
251
|
it "should not be empty Array if there are only subject/geographic elements" do
|
249
252
|
m = "<mods #{@ns_decl}><subject><geographic>#{@geo}</geographic></subject></mods>"
|
250
253
|
@smods_rec.from_str m
|
251
|
-
expect(@smods_rec.
|
254
|
+
expect(@smods_rec.geographic_search).to eq([@geo])
|
252
255
|
end
|
253
256
|
it "should not be empty Array if there are only subject/hierarchicalGeographic" do
|
254
257
|
m = "<mods #{@ns_decl}><subject><hierarchicalGeographic><country>#{@hier_geo_country}</country></hierarchicalGeographic></subject></mods>"
|
255
258
|
@smods_rec.from_str m
|
256
|
-
expect(@smods_rec.
|
259
|
+
expect(@smods_rec.geographic_search).to eq([@hier_geo_country])
|
257
260
|
end
|
258
261
|
it "should not be empty Array if there are only subject/geographicCode elements" do
|
259
262
|
m = "<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>"
|
260
263
|
@smods_rec.from_str m
|
261
|
-
expect(@smods_rec.
|
264
|
+
expect(@smods_rec.geographic_search).to eq(['Estonia'])
|
262
265
|
end
|
263
266
|
context "geographic subelement" do
|
264
267
|
it "should have a separate value for each geographic element" do
|
@@ -270,12 +273,12 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
270
273
|
<subject><geographic>Washington (D.C.)</geographic></subject>
|
271
274
|
</mods>"
|
272
275
|
@smods_rec.from_str m
|
273
|
-
expect(@smods_rec.
|
276
|
+
expect(@smods_rec.geographic_search).to eq(['Mississippi', 'Tippah County', 'Washington (D.C.)'])
|
274
277
|
end
|
275
278
|
it "should be empty Array if there are only empty values in the MODS" do
|
276
279
|
m = "<mods #{@ns_decl}><subject><geographic/></subject><note>notit</note></mods>"
|
277
280
|
@smods_rec.from_str m
|
278
|
-
expect(@smods_rec.
|
281
|
+
expect(@smods_rec.geographic_search).to eq([])
|
279
282
|
end
|
280
283
|
end
|
281
284
|
|
@@ -289,16 +292,16 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
289
292
|
<subject><hierarchicalGeographic><area>third</area></hierarchicalGeographic></subject>
|
290
293
|
</mods>"
|
291
294
|
@smods_rec.from_str m
|
292
|
-
expect(@smods_rec.
|
295
|
+
expect(@smods_rec.geographic_search).to eq(['first', 'second', 'third'])
|
293
296
|
end
|
294
297
|
it "should be empty Array if there are only empty values in the MODS" do
|
295
298
|
m = "<mods #{@ns_decl}><subject><hierarchicalGeographic/></subject><note>notit</note></mods>"
|
296
299
|
@smods_rec.from_str m
|
297
|
-
expect(@smods_rec.
|
300
|
+
expect(@smods_rec.geographic_search).to eq([])
|
298
301
|
end
|
299
302
|
context "combining subelements" do
|
300
|
-
|
301
|
-
|
303
|
+
let(:m) do
|
304
|
+
"<mods #{@ns_decl}>
|
302
305
|
<subject>
|
303
306
|
<hierarchicalGeographic>
|
304
307
|
<country>Canada</country>
|
@@ -306,28 +309,26 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
306
309
|
<city>Vancouver</city>
|
307
310
|
</hierarchicalGeographic>
|
308
311
|
</subject></mods>"
|
309
|
-
@smods_rec.from_str m
|
310
312
|
end
|
311
313
|
|
312
314
|
it "uses a space as the separator by default" do
|
313
|
-
expect(@smods_rec.
|
314
|
-
end
|
315
|
-
it "honors any string value passed in for the separator" do
|
316
|
-
expect(@smods_rec.sw_geographic_search(' --')).to eq(['Canada --British Columbia --Vancouver'])
|
315
|
+
expect(@smods_rec.geographic_search).to eq ['Canada British Columbia Vancouver']
|
317
316
|
end
|
318
317
|
end
|
319
318
|
end # hierarchicalGeographic
|
320
319
|
|
321
320
|
context "geographicCode subelement" do
|
322
|
-
|
323
|
-
|
321
|
+
let(:m) do
|
322
|
+
"<mods #{@ns_decl}>
|
324
323
|
<subject><geographicCode authority='marcgac'>n-us-md</geographicCode></subject>
|
325
324
|
<subject><geographicCode authority='marcgac'>e-er</geographicCode></subject>
|
326
325
|
<subject><geographicCode authority='marccountry'>mg</geographicCode></subject>
|
327
326
|
<subject><geographicCode authority='iso3166'>us</geographicCode></subject>
|
328
327
|
</mods>"
|
329
|
-
|
330
|
-
|
328
|
+
end
|
329
|
+
|
330
|
+
before do
|
331
|
+
@geo_search_from_codes = @smods_rec.geographic_search
|
331
332
|
end
|
332
333
|
|
333
334
|
it "should not add untranslated values" do
|
@@ -354,12 +355,12 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
354
355
|
<subject><geographicCode authority='marcgac'>n-us-md</geographicCode></subject>
|
355
356
|
</mods>"
|
356
357
|
@smods_rec.from_str m
|
357
|
-
expect(@smods_rec.
|
358
|
+
expect(@smods_rec.geographic_search).to eq(['Estonia', 'Madagascar', 'Maryland'])
|
358
359
|
end
|
359
360
|
it "should be empty Array if there are only empty values in the MODS" do
|
360
361
|
m = "<mods #{@ns_decl}><subject><geographicCode/></subject><note>notit</note></mods>"
|
361
362
|
@smods_rec.from_str m
|
362
|
-
expect(@smods_rec.
|
363
|
+
expect(@smods_rec.geographic_search).to eq([])
|
363
364
|
end
|
364
365
|
it "should add the translated value if it wasn't present already" do
|
365
366
|
m = "<mods #{@ns_decl}>
|
@@ -367,8 +368,8 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
367
368
|
<subject><geographicCode authority='marcgac'>e-er</geographicCode></subject>
|
368
369
|
</mods>"
|
369
370
|
@smods_rec.from_str m
|
370
|
-
expect(@smods_rec.
|
371
|
-
expect(@smods_rec.
|
371
|
+
expect(@smods_rec.geographic_search.size).to eq(2)
|
372
|
+
expect(@smods_rec.geographic_search).to include('Estonia')
|
372
373
|
end
|
373
374
|
it "should not add the translated value if it was already present" do
|
374
375
|
m = "<mods #{@ns_decl}>
|
@@ -376,8 +377,8 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
376
377
|
<subject><geographicCode authority='marcgac'>e-er</geographicCode></subject>
|
377
378
|
</mods>"
|
378
379
|
@smods_rec.from_str m
|
379
|
-
expect(@smods_rec.
|
380
|
-
expect(@smods_rec.
|
380
|
+
expect(@smods_rec.geographic_search.size).to eq(1)
|
381
|
+
expect(@smods_rec.geographic_search).to eq(['Estonia'])
|
381
382
|
end
|
382
383
|
end
|
383
384
|
end # sw_geographic_search
|
@@ -26,11 +26,14 @@ describe "Subject fields (searchworks.rb)" do
|
|
26
26
|
<subject><titleInfo><title>#{@s_title}</title></titleInfo></subject>
|
27
27
|
<subject><topic>#{@topic}</topic></subject>
|
28
28
|
</mods>"
|
29
|
+
m_no_subject = "<mods #{@ns_decl}><note>notit</note></mods>"
|
30
|
+
@ng_mods_no_subject = Nokogiri::XML(m_no_subject)
|
31
|
+
end
|
32
|
+
|
33
|
+
before(:each) do
|
29
34
|
@smods_rec = Stanford::Mods::Record.new
|
30
35
|
@smods_rec.from_str(@subject_mods)
|
31
36
|
@ng_mods = Nokogiri::XML(@subject_mods)
|
32
|
-
m_no_subject = "<mods #{@ns_decl}><note>notit</note></mods>"
|
33
|
-
@ng_mods_no_subject = Nokogiri::XML(m_no_subject)
|
34
37
|
end
|
35
38
|
|
36
39
|
context "search fields" do
|
@@ -39,7 +42,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
39
42
|
m = "<mods #{@ns_decl}></mods>"
|
40
43
|
@smods_rec = Stanford::Mods::Record.new
|
41
44
|
@smods_rec.from_str(m)
|
42
|
-
expect(@smods_rec.topic_search).to
|
45
|
+
expect(@smods_rec.topic_search).to eq []
|
43
46
|
end
|
44
47
|
it "should contain subject <topic> subelement data" do
|
45
48
|
expect(@smods_rec.topic_search).to include(@topic)
|
@@ -74,48 +77,21 @@ describe "Subject fields (searchworks.rb)" do
|
|
74
77
|
@smods_rec.from_str(m)
|
75
78
|
expect(@smods_rec.topic_search).to eq(['first', 'second', 'third'])
|
76
79
|
end
|
77
|
-
it "should be
|
80
|
+
it "should be empty if there are only empty values in the MODS" do
|
78
81
|
m = "<mods #{@ns_decl}><subject><topic/></subject><note>notit</note></mods>"
|
79
82
|
@smods_rec = Stanford::Mods::Record.new
|
80
83
|
@smods_rec.from_str(m)
|
81
|
-
expect(@smods_rec.topic_search).to
|
84
|
+
expect(@smods_rec.topic_search).to eq []
|
82
85
|
end
|
83
86
|
end
|
84
87
|
end # topic_search
|
85
88
|
|
86
|
-
context "geographic_search" do
|
87
|
-
it "should call sw_geographic_search (from stanford-mods gem)" do
|
88
|
-
m = "<mods #{@ns_decl}><subject><geographic>#{@geo}</geographic></subject></mods>"
|
89
|
-
@smods_rec = Stanford::Mods::Record.new
|
90
|
-
@smods_rec.from_str(m)
|
91
|
-
expect(@smods_rec).to receive(:sw_geographic_search)
|
92
|
-
@smods_rec.geographic_search
|
93
|
-
end
|
94
|
-
it "should log an info message when it encounters a geographicCode encoding it doesn't translate" do
|
95
|
-
m = "<mods #{@ns_decl}><subject><geographicCode authority='iso3166'>ca</geographicCode></subject></mods>"
|
96
|
-
@smods_rec = Stanford::Mods::Record.new
|
97
|
-
@smods_rec.from_str(m)
|
98
|
-
expect(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>ca<\/geographicCode>/)
|
99
|
-
@smods_rec.geographic_search
|
100
|
-
end
|
101
|
-
end # geographic_search
|
102
|
-
|
103
89
|
context "subject_other_search" do
|
104
|
-
it "should call sw_subject_names (from stanford-mods gem)" do
|
105
|
-
smods_rec = Stanford::Mods::Record.new
|
106
|
-
smods_rec.from_str(@subject_mods)
|
107
|
-
expect(smods_rec).to receive(:sw_subject_names)
|
108
|
-
smods_rec.subject_other_search
|
109
|
-
end
|
110
|
-
it "should call sw_subject_titles (from stanford-mods gem)" do
|
111
|
-
expect(@smods_rec).to receive(:sw_subject_titles)
|
112
|
-
@smods_rec.subject_other_search
|
113
|
-
end
|
114
90
|
it "should be nil if there are no values in the MODS" do
|
115
91
|
m = "<mods #{@ns_decl}></mods>"
|
116
92
|
@smods_rec = Stanford::Mods::Record.new
|
117
93
|
@smods_rec.from_str(m)
|
118
|
-
expect(@smods_rec.subject_other_search).to
|
94
|
+
expect(@smods_rec.subject_other_search).to eq []
|
119
95
|
end
|
120
96
|
it "should contain subject <name> SUBelement data" do
|
121
97
|
expect(@smods_rec.subject_other_search).to include(@s_name)
|
@@ -173,7 +149,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
173
149
|
m = "<mods #{@ns_decl}><subject><occupation/></subject><note>notit</note></mods>"
|
174
150
|
@smods_rec = Stanford::Mods::Record.new
|
175
151
|
@smods_rec.from_str(m)
|
176
|
-
expect(@smods_rec.subject_other_search).to
|
152
|
+
expect(@smods_rec.subject_other_search).to eq []
|
177
153
|
end
|
178
154
|
end
|
179
155
|
end # subject_other_search
|
@@ -182,7 +158,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
182
158
|
it "should be nil if there are no values in the MODS" do
|
183
159
|
@smods_rec = Stanford::Mods::Record.new
|
184
160
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
185
|
-
expect(@smods_rec.subject_other_subvy_search).to
|
161
|
+
expect(@smods_rec.subject_other_subvy_search).to eq []
|
186
162
|
end
|
187
163
|
it "should contain subject <temporal> subelement data" do
|
188
164
|
expect(@smods_rec.subject_other_subvy_search).to include(@temporal)
|
@@ -226,18 +202,11 @@ describe "Subject fields (searchworks.rb)" do
|
|
226
202
|
@smods_rec.from_str(m)
|
227
203
|
expect(@smods_rec.subject_other_subvy_search).to eq(['1890-1910', '20th century', 'another'])
|
228
204
|
end
|
229
|
-
it "should log an info message when it encounters an encoding it doesn't translate" do
|
230
|
-
m = "<mods #{@ns_decl}><subject><temporal encoding='iso8601'>197505</temporal></subject></mods>"
|
231
|
-
@smods_rec = Stanford::Mods::Record.new
|
232
|
-
@smods_rec.from_str(m)
|
233
|
-
expect(@smods_rec.sw_logger).to receive(:info).with(/ has subject temporal element with untranslated encoding: <temporal encoding=.*>197505<\/temporal>/)
|
234
|
-
@smods_rec.subject_other_subvy_search
|
235
|
-
end
|
236
205
|
it "should be nil if there are only empty values in the MODS" do
|
237
206
|
m = "<mods #{@ns_decl}><subject><temporal/></subject><note>notit</note></mods>"
|
238
207
|
@smods_rec = Stanford::Mods::Record.new
|
239
208
|
@smods_rec.from_str(m)
|
240
|
-
expect(@smods_rec.subject_other_subvy_search).to
|
209
|
+
expect(@smods_rec.subject_other_subvy_search).to eq []
|
241
210
|
end
|
242
211
|
end
|
243
212
|
|
@@ -258,20 +227,16 @@ describe "Subject fields (searchworks.rb)" do
|
|
258
227
|
m = "<mods #{@ns_decl}><subject><genre/></subject><note>notit</note></mods>"
|
259
228
|
@smods_rec = Stanford::Mods::Record.new
|
260
229
|
@smods_rec.from_str(m)
|
261
|
-
expect(@smods_rec.subject_other_subvy_search).to
|
230
|
+
expect(@smods_rec.subject_other_subvy_search).to eq []
|
262
231
|
end
|
263
232
|
end
|
264
233
|
end # subject_other_subvy_search
|
265
234
|
|
266
235
|
context "subject_all_search" do
|
267
|
-
before :each do
|
268
|
-
allow(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
|
269
|
-
end
|
270
|
-
|
271
236
|
it "should be nil if there are no values in the MODS" do
|
272
237
|
@smods_rec = Stanford::Mods::Record.new
|
273
238
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
274
|
-
expect(@smods_rec.subject_all_search).to
|
239
|
+
expect(@smods_rec.subject_all_search).to eq []
|
275
240
|
end
|
276
241
|
it "should not contain cartographic sub element" do
|
277
242
|
expect(@smods_rec.subject_all_search).not_to include(@cart_coord)
|
@@ -283,7 +248,6 @@ describe "Subject fields (searchworks.rb)" do
|
|
283
248
|
@smods_rec = Stanford::Mods::Record.new
|
284
249
|
@smods_rec.from_str(@subject_mods)
|
285
250
|
## need to re-allow/expect :info message with newly assigned object
|
286
|
-
expect(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
|
287
251
|
expect(@smods_rec.subject_all_search).to include(@s_genre)
|
288
252
|
expect(@smods_rec.subject_all_search).to include(@geo)
|
289
253
|
expect(@smods_rec.subject_all_search).to include(@hier_geo_country)
|
@@ -327,7 +291,7 @@ describe "Subject fields (searchworks.rb)" do
|
|
327
291
|
it "should be nil if there are no values" do
|
328
292
|
@smods_rec = Stanford::Mods::Record.new
|
329
293
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
330
|
-
expect(@smods_rec.topic_facet).to
|
294
|
+
expect(@smods_rec.topic_facet).to eq []
|
331
295
|
end
|
332
296
|
end
|
333
297
|
|
@@ -351,10 +315,10 @@ describe "Subject fields (searchworks.rb)" do
|
|
351
315
|
expect(@smods_rec.geographic_facet).to include('backslash')
|
352
316
|
expect(@smods_rec.geographic_facet).to include('internal, punct;uation')
|
353
317
|
end
|
354
|
-
it "should be
|
318
|
+
it "should be empty if there are no values" do
|
355
319
|
@smods_rec = Stanford::Mods::Record.new
|
356
320
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
357
|
-
expect(@smods_rec.geographic_facet).to
|
321
|
+
expect(@smods_rec.geographic_facet).to eq []
|
358
322
|
end
|
359
323
|
end
|
360
324
|
|
@@ -373,10 +337,10 @@ describe "Subject fields (searchworks.rb)" do
|
|
373
337
|
expect(@smods_rec.era_facet).to include('backslash')
|
374
338
|
expect(@smods_rec.era_facet).to include('internal, punct;uation')
|
375
339
|
end
|
376
|
-
it "should be
|
340
|
+
it "should be empty if there are no values" do
|
377
341
|
@smods_rec = Stanford::Mods::Record.new
|
378
342
|
@smods_rec.from_str(@ng_mods_no_subject.to_s)
|
379
|
-
expect(@smods_rec.era_facet).to
|
343
|
+
expect(@smods_rec.era_facet).to eq []
|
380
344
|
end
|
381
345
|
end
|
382
346
|
end # facet fields
|
@@ -3,7 +3,7 @@ describe 'title fields (searchworks.rb)' do
|
|
3
3
|
before(:all) do
|
4
4
|
@smods_rec = Stanford::Mods::Record.new
|
5
5
|
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
6
|
-
m = "<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle
|
6
|
+
m = "<mods #{@ns_decl}><titleInfo><nonSort>The</nonSort><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle></titleInfo></mods>"
|
7
7
|
@smods_rec.from_str m
|
8
8
|
end
|
9
9
|
|
@@ -19,7 +19,7 @@ describe 'title fields (searchworks.rb)' do
|
|
19
19
|
|
20
20
|
context 'blank title node' do
|
21
21
|
it 'should deal with a second blank titleInfo node' do
|
22
|
-
m = "<mods #{@ns_decl}><titleInfo> </titleInfo><otherStuff>goes here</otherStuff><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle
|
22
|
+
m = "<mods #{@ns_decl}><titleInfo> </titleInfo><otherStuff>goes here</otherStuff><titleInfo><nonSort>The</nonSort><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle>></titleInfo></mods>"
|
23
23
|
smods_rec_blank_node = Stanford::Mods::Record.new
|
24
24
|
smods_rec_blank_node.from_str m
|
25
25
|
expect(smods_rec_blank_node.sw_short_title).to eq 'The Jerk'
|
@@ -113,7 +113,7 @@ describe 'title fields (searchworks.rb)' do
|
|
113
113
|
<subTitle>a history</subTitle>
|
114
114
|
</titleInfo></mods>"
|
115
115
|
@smods_rec.from_str(m)
|
116
|
-
expect(@smods_rec.sw_full_title).to eq 'The Olympics
|
116
|
+
expect(@smods_rec.sw_full_title).to eq 'The Olympics: a history.'
|
117
117
|
end #
|
118
118
|
# "end subtitle with period" - see above
|
119
119
|
it 'subtitle already ends with period' do
|
@@ -389,7 +389,7 @@ describe 'title fields (searchworks.rb)' do
|
|
389
389
|
<subTitle>a history</subTitle>
|
390
390
|
</titleInfo></mods>"
|
391
391
|
@smods_rec.from_str(m)
|
392
|
-
expect(@smods_rec.sw_title_display).to eq 'The Olympics
|
392
|
+
expect(@smods_rec.sw_title_display).to eq 'The Olympics: a history'
|
393
393
|
end #
|
394
394
|
# "end subtitle with period" - see above
|
395
395
|
it 'subtitle already ends with period' do
|
@@ -680,7 +680,7 @@ describe 'title fields (searchworks.rb)' do
|
|
680
680
|
end
|
681
681
|
it 'additional titles' do
|
682
682
|
expect(@mccarthy_smods_rec.sw_addl_titles).to eql []
|
683
|
-
expect(@insp_general_smods_rec.sw_addl_titles).to eql []
|
683
|
+
expect(@insp_general_smods_rec.sw_addl_titles).to eql ['Semiannual report to Congress (Online)']
|
684
684
|
expect(@cfb_smods_rec.sw_addl_titles).to eql []
|
685
685
|
expect(@all_smods_rec.sw_addl_titles).to eql []
|
686
686
|
end
|
data/stanford-mods.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.test_files = gem.files.grep(%r{^spec/})
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
|
19
|
-
gem.add_dependency 'mods', '~>
|
19
|
+
gem.add_dependency 'mods', '~> 3.0', '>= 3.0.1'
|
20
20
|
# active_support for .ordinalize, eg. 1 -> 1st, 2 -> 2nd for centuries
|
21
21
|
gem.add_dependency 'activesupport'
|
22
22
|
|