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
data/spec/name_spec.rb
CHANGED
@@ -3,7 +3,7 @@ describe "name/author concepts" do
|
|
3
3
|
let(:mods_start) { "<mods xmlns=\"#{Mods::MODS_NS}\">" }
|
4
4
|
let(:mods_end) { "</mods>" }
|
5
5
|
|
6
|
-
context "
|
6
|
+
context "sw_main_author" do
|
7
7
|
let(:plain_no_role) { "<name><namePart>plain_no_role</namePart></name>" }
|
8
8
|
let(:plain_creator_code) { "<name>
|
9
9
|
<namePart>plain_creator_code</namePart>
|
@@ -60,77 +60,72 @@ describe "name/author concepts" do
|
|
60
60
|
context "marcrelator role Creator" do
|
61
61
|
it "finds role with roleTerm type text" do
|
62
62
|
smods_rec.from_str(mods_start + plain_creator_text + mods_end)
|
63
|
-
expect(smods_rec.
|
63
|
+
expect(smods_rec.sw_main_author).to eq('plain_creator_text')
|
64
64
|
end
|
65
65
|
it "finds role with roleTerm type code" do
|
66
66
|
smods_rec.from_str(mods_start + plain_creator_code + mods_end)
|
67
|
-
expect(smods_rec.
|
67
|
+
expect(smods_rec.sw_main_author).to eq('plain_creator_code')
|
68
68
|
end
|
69
69
|
it "skips names when role isn't marcrelator authority" do
|
70
70
|
smods_rec.from_str(mods_start + plain_creator_non_mr + mods_end)
|
71
|
-
expect(smods_rec.
|
71
|
+
expect(smods_rec.sw_main_author).to be_nil
|
72
72
|
end
|
73
73
|
it "skips names without roles in favor of marcrelator role of 'Creator'" do
|
74
74
|
smods_rec.from_str(mods_start + personal_no_role + plain_creator_text + other_no_role + mods_end)
|
75
|
-
expect(smods_rec.
|
75
|
+
expect(smods_rec.sw_main_author).to eq('plain_creator_text')
|
76
76
|
smods_rec.from_str(mods_start + corp_no_role + plain_creator_code + mods_end)
|
77
|
-
expect(smods_rec.
|
77
|
+
expect(smods_rec.sw_main_author).to eq('plain_creator_code')
|
78
78
|
end
|
79
79
|
it "does not care about name type" do
|
80
80
|
smods_rec.from_str(mods_start + personal_creator_code + corp_creator_text + mods_end)
|
81
|
-
expect(smods_rec.
|
81
|
+
expect(smods_rec.sw_main_author).to eq('personal_creator_code')
|
82
82
|
smods_rec.from_str(mods_start + personal_no_role + corp_creator_text + mods_end)
|
83
|
-
expect(smods_rec.
|
83
|
+
expect(smods_rec.sw_main_author).to eq('corp_creator_text')
|
84
84
|
end
|
85
85
|
end # marcrelator role Creator
|
86
86
|
|
87
87
|
context "marcrelator role Author" do
|
88
88
|
it "finds role with roleTerm type text" do
|
89
89
|
smods_rec.from_str(mods_start + plain_author_text + mods_end)
|
90
|
-
expect(smods_rec.
|
90
|
+
expect(smods_rec.sw_main_author).to eq('plain_author_text')
|
91
91
|
end
|
92
92
|
it "finds role with roleTerm type code" do
|
93
93
|
smods_rec.from_str(mods_start + plain_author_code + mods_end)
|
94
|
-
expect(smods_rec.
|
94
|
+
expect(smods_rec.sw_main_author).to eq('plain_author_code')
|
95
95
|
end
|
96
96
|
it "skips names when role isn't marcrelator authority" do
|
97
97
|
smods_rec.from_str(mods_start + plain_author_non_mr + mods_end)
|
98
|
-
expect(smods_rec.
|
98
|
+
expect(smods_rec.sw_main_author).to be_nil
|
99
99
|
end
|
100
100
|
it "skips names without roles in favor of marcrelator role of 'Author'" do
|
101
101
|
smods_rec.from_str(mods_start + personal_no_role + plain_author_text + other_no_role + mods_end)
|
102
|
-
expect(smods_rec.
|
102
|
+
expect(smods_rec.sw_main_author).to eq('plain_author_text')
|
103
103
|
smods_rec.from_str(mods_start + corp_no_role + personal_no_role + plain_author_code + mods_end)
|
104
|
-
expect(smods_rec.
|
104
|
+
expect(smods_rec.sw_main_author).to eq('plain_author_code')
|
105
105
|
end
|
106
106
|
it "doesn't care about name type" do
|
107
107
|
smods_rec.from_str(mods_start + personal_author_text + corp_author_code + mods_end)
|
108
|
-
expect(smods_rec.
|
108
|
+
expect(smods_rec.sw_main_author).to eq('personal_author_text')
|
109
109
|
smods_rec.from_str(mods_start + personal_no_role + corp_author_code + mods_end)
|
110
|
-
expect(smods_rec.
|
110
|
+
expect(smods_rec.sw_main_author).to eq('corp_author_code')
|
111
111
|
end
|
112
112
|
end # marcrelator role Author
|
113
113
|
|
114
|
-
it "is a String" do
|
115
|
-
smods_rec.from_str(mods_start + personal_author_text + corp_creator_text + mods_end)
|
116
|
-
expect(smods_rec.main_author_w_date).to be_an_instance_of(String)
|
117
|
-
end
|
118
|
-
|
119
114
|
it "takes first name with marcrelator role of 'Creator' or 'Author'" do
|
120
115
|
smods_rec.from_str(mods_start + personal_author_text + corp_creator_text + mods_end)
|
121
|
-
expect(smods_rec.
|
116
|
+
expect(smods_rec.sw_main_author).to eq('personal_author_text')
|
122
117
|
smods_rec.from_str(mods_start + corp_creator_text + personal_creator_code + mods_end)
|
123
|
-
expect(smods_rec.
|
118
|
+
expect(smods_rec.sw_main_author).to eq('corp_creator_text')
|
124
119
|
end
|
125
120
|
|
126
121
|
it "takes the first name without a role if there are no instances of marcrelator role 'Creator' or 'Actor'" do
|
127
122
|
smods_rec.from_str(mods_start + plain_author_non_mr + personal_other_role + personal_no_role + plain_no_role + mods_end)
|
128
|
-
expect(smods_rec.
|
123
|
+
expect(smods_rec.sw_main_author).to eq('personal_no_role')
|
129
124
|
end
|
130
125
|
|
131
126
|
it "nil if there is no name with marcrelator role of 'Creator' or 'Author' and no name without a role" do
|
132
127
|
smods_rec.from_str(mods_start + plain_author_non_mr + personal_other_role + mods_end)
|
133
|
-
expect(smods_rec.
|
128
|
+
expect(smods_rec.sw_main_author).to be_nil
|
134
129
|
end
|
135
130
|
|
136
131
|
it "uses the display name if it is present" do
|
@@ -148,7 +143,7 @@ describe "name/author concepts" do
|
|
148
143
|
</name>
|
149
144
|
</mods>"
|
150
145
|
smods_rec.from_str(m)
|
151
|
-
expect(smods_rec.
|
146
|
+
expect(smods_rec.sw_main_author).to eq('q')
|
152
147
|
end
|
153
148
|
it "includes dates, when available" do
|
154
149
|
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
@@ -158,7 +153,7 @@ describe "name/author concepts" do
|
|
158
153
|
</name>
|
159
154
|
</mods>"
|
160
155
|
smods_rec.from_str(m)
|
161
|
-
expect(smods_rec.
|
156
|
+
expect(smods_rec.sw_main_author).to eq('personal, 1984-')
|
162
157
|
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
163
158
|
<name>
|
164
159
|
<namePart>plain</namePart>
|
@@ -166,7 +161,7 @@ describe "name/author concepts" do
|
|
166
161
|
</name>
|
167
162
|
</mods>"
|
168
163
|
smods_rec.from_str(m)
|
169
|
-
expect(smods_rec.
|
164
|
+
expect(smods_rec.sw_main_author).to eq('plain, 1954-')
|
170
165
|
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
171
166
|
<name type='corporate'>
|
172
167
|
<namePart>corporate</namePart>
|
@@ -174,9 +169,9 @@ describe "name/author concepts" do
|
|
174
169
|
</name>
|
175
170
|
</mods>"
|
176
171
|
smods_rec.from_str(m)
|
177
|
-
expect(smods_rec.
|
172
|
+
expect(smods_rec.sw_main_author).to eq('corporate, 1990-')
|
178
173
|
end
|
179
|
-
end
|
174
|
+
end
|
180
175
|
|
181
176
|
context "additional_authors_w_dates" do
|
182
177
|
let(:addl_authors) do
|
@@ -209,14 +204,14 @@ describe "name/author concepts" do
|
|
209
204
|
</name>
|
210
205
|
</mods>"
|
211
206
|
smods_rec.from_str(m)
|
212
|
-
smods_rec.
|
207
|
+
smods_rec.sw_addl_authors
|
213
208
|
end
|
214
209
|
it "is an Array of Strings" do
|
215
210
|
expect(addl_authors).to be_an_instance_of(Array)
|
216
211
|
expect(addl_authors.first).to be_an_instance_of(String)
|
217
212
|
end
|
218
213
|
it "does not include main author" do
|
219
|
-
expect(addl_authors).not_to include(smods_rec.
|
214
|
+
expect(addl_authors).not_to include(smods_rec.sw_main_author)
|
220
215
|
end
|
221
216
|
it "includes personal authors that are not main author" do
|
222
217
|
expect(addl_authors).to include('Crusty The Clown, 1990-')
|
@@ -240,203 +235,4 @@ describe "name/author concepts" do
|
|
240
235
|
expect(addl_authors.find { |a| a =~ Regexp.new('lithographer') }).to be_nil
|
241
236
|
end
|
242
237
|
end # additional_authors_w_dates
|
243
|
-
|
244
|
-
context '#non_collector_person_authors' do
|
245
|
-
let(:name) { 'Hermione Grainger' }
|
246
|
-
let(:name2) { 'Ron Weasley' }
|
247
|
-
context 'has personal names that are not collectors' do
|
248
|
-
it 'only non-collector persons' do
|
249
|
-
name_snippet =
|
250
|
-
<<-EOF
|
251
|
-
<name type="personal">
|
252
|
-
<namePart>#{name}</namePart>
|
253
|
-
<role>
|
254
|
-
<roleTerm type="code" authority="marcrelator">cre</roleTerm>
|
255
|
-
</role>
|
256
|
-
</name>
|
257
|
-
<name type="personal">
|
258
|
-
<namePart>#{name2}</namePart>
|
259
|
-
<role>
|
260
|
-
<roleTerm type="code" authority="marcrelator">con</roleTerm>
|
261
|
-
</role>
|
262
|
-
</name>
|
263
|
-
EOF
|
264
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
265
|
-
expect(smods_rec.non_collector_person_authors).to include(name, name2)
|
266
|
-
end
|
267
|
-
it 'some collectors, some non-collectors' do
|
268
|
-
name_snippet =
|
269
|
-
<<-EOF
|
270
|
-
<name type="personal">
|
271
|
-
<namePart>#{name}</namePart>
|
272
|
-
<role>
|
273
|
-
<roleTerm type="code" authority="marcrelator">cre</roleTerm>
|
274
|
-
</role>
|
275
|
-
</name>
|
276
|
-
<name type="personal">
|
277
|
-
<namePart>#{name2}</namePart>
|
278
|
-
<role>
|
279
|
-
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
280
|
-
</role>
|
281
|
-
</name>
|
282
|
-
EOF
|
283
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
284
|
-
expect(smods_rec.non_collector_person_authors).to eq [name]
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
it 'nil if only collectors' do
|
289
|
-
name_snippet =
|
290
|
-
<<-EOF
|
291
|
-
<name type="personal">
|
292
|
-
<namePart>#{name}</namePart>
|
293
|
-
<role>
|
294
|
-
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
295
|
-
</role>
|
296
|
-
</name>
|
297
|
-
<name type="personal">
|
298
|
-
<namePart>Ron Weasley</namePart>
|
299
|
-
<role>
|
300
|
-
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
301
|
-
</role>
|
302
|
-
</name>
|
303
|
-
EOF
|
304
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
305
|
-
expect(smods_rec.non_collector_person_authors).to eq nil
|
306
|
-
end
|
307
|
-
it 'no role present' do
|
308
|
-
name_snippet =
|
309
|
-
<<-EOF
|
310
|
-
<name type="personal" usage="primary">
|
311
|
-
<namePart>#{name}</namePart>
|
312
|
-
</name>
|
313
|
-
EOF
|
314
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
315
|
-
expect(smods_rec.non_collector_person_authors).to eq nil
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
context '#collectors_w_dates' do
|
320
|
-
let(:collector_name) { 'Dr. Seuss' }
|
321
|
-
context 'valueURI for roleTerm' do
|
322
|
-
it 'roleTerm has value' do
|
323
|
-
name_snippet =
|
324
|
-
<<-EOF
|
325
|
-
<name type="personal">
|
326
|
-
<namePart>#{collector_name}</namePart>
|
327
|
-
<role>
|
328
|
-
<roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/col">Collector</roleTerm>
|
329
|
-
</role>
|
330
|
-
</name>
|
331
|
-
EOF
|
332
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
333
|
-
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
334
|
-
end
|
335
|
-
it 'empty roleTerm' do
|
336
|
-
name_snippet =
|
337
|
-
<<-EOF
|
338
|
-
<name type="personal">
|
339
|
-
<namePart>#{collector_name}</namePart>
|
340
|
-
<role>
|
341
|
-
<roleTerm authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/col" />
|
342
|
-
</role>
|
343
|
-
</name>
|
344
|
-
EOF
|
345
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
346
|
-
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
context 'no valueURI for roleTerm' do
|
351
|
-
it 'collector marc relator code' do
|
352
|
-
name_snippet =
|
353
|
-
<<-EOF
|
354
|
-
<name type="personal">
|
355
|
-
<namePart>#{collector_name}</namePart>
|
356
|
-
<role>
|
357
|
-
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
358
|
-
</role>
|
359
|
-
</name>
|
360
|
-
EOF
|
361
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
362
|
-
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
363
|
-
end
|
364
|
-
it 'collector marc relator text' do
|
365
|
-
name_snippet =
|
366
|
-
<<-EOF
|
367
|
-
<name type="personal">
|
368
|
-
<namePart>#{collector_name}</namePart>
|
369
|
-
<role>
|
370
|
-
<roleTerm type="text" authority="marcrelator">Collector</roleTerm>
|
371
|
-
</role>
|
372
|
-
</name>
|
373
|
-
EOF
|
374
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
375
|
-
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
it 'does not include non-collectors' do
|
380
|
-
name_snippet =
|
381
|
-
<<-EOF
|
382
|
-
<name type="personal">
|
383
|
-
<namePart>#{collector_name}</namePart>
|
384
|
-
<role>
|
385
|
-
<roleTerm type="text" authority="marcrelator">Collector</roleTerm>
|
386
|
-
</role>
|
387
|
-
</name>
|
388
|
-
<name type="personal">
|
389
|
-
<namePart>Freddy</namePart>
|
390
|
-
<role>
|
391
|
-
<roleTerm type='code' authority='marcrelator'>cre</roleTerm>
|
392
|
-
</role>
|
393
|
-
</name>
|
394
|
-
EOF
|
395
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
396
|
-
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
397
|
-
end
|
398
|
-
it 'multiple collectors' do
|
399
|
-
addl_name = 'Feigenbaum, Edward A.'
|
400
|
-
name_snippet =
|
401
|
-
<<-EOF
|
402
|
-
<name type="personal">
|
403
|
-
<namePart>#{collector_name}</namePart>
|
404
|
-
<role>
|
405
|
-
<roleTerm type="text" authority="marcrelator">Collector</roleTerm>
|
406
|
-
</role>
|
407
|
-
</name>
|
408
|
-
<name type="personal">
|
409
|
-
<namePart>#{addl_name}</namePart>
|
410
|
-
<role>
|
411
|
-
<roleTerm type='code' authority='marcrelator'>col</roleTerm>
|
412
|
-
</role>
|
413
|
-
</name>
|
414
|
-
EOF
|
415
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
416
|
-
expect(smods_rec.collectors_w_dates).to include(collector_name, addl_name)
|
417
|
-
end
|
418
|
-
it 'nil if no collectors' do
|
419
|
-
name_snippet =
|
420
|
-
<<-EOF
|
421
|
-
<name type="personal">
|
422
|
-
<namePart>Freddy</namePart>
|
423
|
-
<role>
|
424
|
-
<roleTerm type='code' authority='marcrelator'>cre</roleTerm>
|
425
|
-
</role>
|
426
|
-
</name>
|
427
|
-
EOF
|
428
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
429
|
-
expect(smods_rec.collectors_w_dates).to eq nil
|
430
|
-
end
|
431
|
-
it 'no role present' do
|
432
|
-
name_snippet =
|
433
|
-
<<-EOF
|
434
|
-
<name type="personal" usage="primary">
|
435
|
-
<namePart>Nobody</namePart>
|
436
|
-
</name>
|
437
|
-
EOF
|
438
|
-
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
439
|
-
expect(smods_rec.collectors_w_dates).to eq nil
|
440
|
-
end
|
441
|
-
end
|
442
238
|
end
|