stanford-mods 2.5.0 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -212,6 +212,7 @@ describe "Date methods (searchworks.rb)" do
212
212
  expect(smods_rec.send(:pub_date)).to eq('8--')
213
213
  end
214
214
  end # pub_date
215
+
215
216
  context "pub_dates (protected)" do
216
217
  it "puts dateIssued values before dateCreated values" do
217
218
  m = "<mods #{ns_decl}><originInfo>
@@ -97,6 +97,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
97
97
  </mods>"
98
98
  @smods_rec.from_str(m)
99
99
  end
100
+
100
101
  it "main author (for author_1xx_search)" do
101
102
  expect(@smods_rec).to receive(:main_author_w_date) # in stanford-mods.rb
102
103
  @smods_rec.sw_main_author
@@ -128,6 +128,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
128
128
  </mods>"
129
129
  @smods_rec.from_str m
130
130
  end
131
+
131
132
  it "uses a ', ' as the separator by default" do
132
133
  expect(@smods_rec.sw_subject_names).to eq ['first, second']
133
134
  end
@@ -192,6 +193,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
192
193
  </mods>"
193
194
  @smods_rec.from_str m
194
195
  end
196
+
195
197
  it "uses a ' ' as the separator by default" do
196
198
  expect(@smods_rec.sw_subject_titles).to eq ['first second']
197
199
  end
@@ -276,6 +278,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
276
278
  expect(@smods_rec.sw_geographic_search).to eq([])
277
279
  end
278
280
  end
281
+
279
282
  context "hierarchicalGeographic subelement" do
280
283
  it "should have a separate value for each hierarchicalGeographic element" do
281
284
  m = "<mods #{@ns_decl}>
@@ -305,6 +308,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
305
308
  </subject></mods>"
306
309
  @smods_rec.from_str m
307
310
  end
311
+
308
312
  it "uses a space as the separator by default" do
309
313
  expect(@smods_rec.sw_geographic_search).to eq ['Canada British Columbia Vancouver']
310
314
  end
@@ -313,6 +317,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
313
317
  end
314
318
  end
315
319
  end # hierarchicalGeographic
320
+
316
321
  context "geographicCode subelement" do
317
322
  before(:all) do
318
323
  m = "<mods #{@ns_decl}>
@@ -324,6 +329,7 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
324
329
  @smods_rec.from_str m
325
330
  @geo_search_from_codes = @smods_rec.sw_geographic_search
326
331
  end
332
+
327
333
  it "should not add untranslated values" do
328
334
  expect(@geo_search_from_codes).not_to include('n-us-md')
329
335
  expect(@geo_search_from_codes).not_to include('e-er')
@@ -44,9 +44,6 @@ describe "Subject fields (searchworks.rb)" do
44
44
  it "should contain subject <topic> subelement data" do
45
45
  expect(@smods_rec.topic_search).to include(@topic)
46
46
  end
47
- it "should contain top level <genre> element data" do
48
- expect(@smods_rec.topic_search).to include(@genre)
49
- end
50
47
  it "should not contain other subject element data" do
51
48
  expect(@smods_rec.topic_search).not_to include(@cart_coord)
52
49
  expect(@smods_rec.topic_search).not_to include(@s_genre)
@@ -64,12 +61,6 @@ describe "Subject fields (searchworks.rb)" do
64
61
  @smods_rec.from_str(m)
65
62
  expect(@smods_rec.topic_search).to eq([@topic])
66
63
  end
67
- it "should not be nil if there are only <genre> elements (no subject/topic elements)" do
68
- m = "<mods #{@ns_decl}><genre>#{@genre}</genre></mods>"
69
- @smods_rec = Stanford::Mods::Record.new
70
- @smods_rec.from_str(m)
71
- expect(@smods_rec.topic_search).to eq([@genre])
72
- end
73
64
  context "topic subelement" do
74
65
  it "should have a separate value for each topic element" do
75
66
  m = "<mods #{@ns_decl}>
@@ -249,6 +240,7 @@ describe "Subject fields (searchworks.rb)" do
249
240
  expect(@smods_rec.subject_other_subvy_search).to be_nil
250
241
  end
251
242
  end
243
+
252
244
  context "genre subelement" do
253
245
  it "should have a separate value for each genre element" do
254
246
  m = "<mods #{@ns_decl}>
@@ -275,14 +267,12 @@ describe "Subject fields (searchworks.rb)" do
275
267
  before :each do
276
268
  allow(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
277
269
  end
270
+
278
271
  it "should be nil if there are no values in the MODS" do
279
272
  @smods_rec = Stanford::Mods::Record.new
280
273
  @smods_rec.from_str(@ng_mods_no_subject.to_s)
281
274
  expect(@smods_rec.subject_all_search).to be_nil
282
275
  end
283
- it "should contain top level <genre> element data" do
284
- expect(@smods_rec.subject_all_search).to include(@genre)
285
- end
286
276
  it "should not contain cartographic sub element" do
287
277
  expect(@smods_rec.subject_all_search).not_to include(@cart_coord)
288
278
  end
@@ -27,6 +27,19 @@ describe 'title fields (searchworks.rb)' do
27
27
  end
28
28
  end
29
29
 
30
+ context 'when titleInfo contains a subTitle but no title' do
31
+ let(:record) do
32
+ m = "<mods #{@ns_decl}><titleInfo><subTitle>An overview from 1942-1950</subTitle></titleInfo></mods>"
33
+ rec = Stanford::Mods::Record.new
34
+ rec.from_str m
35
+ rec
36
+ end
37
+
38
+ it 'returns nil' do
39
+ expect(record.sw_full_title).to be_nil
40
+ end
41
+ end
42
+
30
43
  context 'missing title node' do
31
44
  it 'deals with missing titleInfo node' do
32
45
  m = "<mods #{@ns_decl}></mods>"
@@ -80,6 +93,7 @@ describe 'title fields (searchworks.rb)' do
80
93
  expect(@smods_rec.sw_full_title).to eq 'The Olympics!'
81
94
  end
82
95
  end # no subtitle
96
+
83
97
  context 'subtitle' do
84
98
  it 'end title with a colon' do
85
99
  m = "<mods #{@ns_decl}>
@@ -123,6 +137,7 @@ describe 'title fields (searchworks.rb)' do
123
137
  expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history?'
124
138
  end
125
139
  end # subtitle
140
+
126
141
  context 'partName' do
127
142
  context 'no partNumber' do
128
143
  it 'end partName with period' do
@@ -162,6 +177,7 @@ describe 'title fields (searchworks.rb)' do
162
177
  expect(@smods_rec.sw_full_title).to eq 'cfb. Appendix.'
163
178
  end
164
179
  end # no partNumber
180
+
165
181
  context 'partNumber' do
166
182
  it 'end partNumber with comma' do
167
183
  m = "<mods #{@ns_decl}>
@@ -205,6 +221,7 @@ describe 'title fields (searchworks.rb)' do
205
221
  end
206
222
  end
207
223
  end # partName
224
+
208
225
  context 'no partName, but partNumber' do
209
226
  it 'end partNumber with period' do
210
227
  m = "<mods #{@ns_decl}>
@@ -322,6 +339,7 @@ describe 'title fields (searchworks.rb)' do
322
339
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
323
340
  end
324
341
  end
342
+
325
343
  context 'no subtitle' do
326
344
  it 'end title with a period' do
327
345
  m = "<mods #{@ns_decl}>
@@ -351,6 +369,7 @@ describe 'title fields (searchworks.rb)' do
351
369
  expect(@smods_rec.sw_title_display).to eq 'The Olympics!'
352
370
  end
353
371
  end # no subtitle
372
+
354
373
  context 'subtitle' do
355
374
  it 'end title with a colon' do
356
375
  m = "<mods #{@ns_decl}>
@@ -394,6 +413,7 @@ describe 'title fields (searchworks.rb)' do
394
413
  expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history?'
395
414
  end
396
415
  end # subtitle
416
+
397
417
  context 'partName' do
398
418
  context 'no partNumber' do
399
419
  it 'end partName with period' do
@@ -433,6 +453,7 @@ describe 'title fields (searchworks.rb)' do
433
453
  expect(@smods_rec.sw_title_display).to eq 'cfb. Appendix'
434
454
  end
435
455
  end # no partNumber
456
+
436
457
  context 'partNumber' do
437
458
  it 'end partNumber with comma' do
438
459
  m = "<mods #{@ns_decl}>
@@ -476,6 +497,7 @@ describe 'title fields (searchworks.rb)' do
476
497
  end
477
498
  end
478
499
  end # partName
500
+
479
501
  context 'no partName, but partNumber' do
480
502
  it 'end partNumber with period' do
481
503
  m = "<mods #{@ns_decl}>
@@ -544,6 +566,7 @@ describe 'title fields (searchworks.rb)' do
544
566
  @smods_rec.from_str(m)
545
567
  @addl_titles = @smods_rec.sw_addl_titles
546
568
  end
569
+
547
570
  it 'should not include the main title' do
548
571
  expect(@addl_titles.size).to eq 2
549
572
  expect(@addl_titles).not_to include(@smods_rec.sw_full_title)
@@ -563,6 +586,18 @@ describe 'title fields (searchworks.rb)' do
563
586
  @smods_rec.from_str(m)
564
587
  expect(@smods_rec.sw_addl_titles).to eq ['Alternative', 'Joke]']
565
588
  end
589
+ it 'excludes weird cases where there is no short title' do
590
+ m = <<-EOXML
591
+ <mods #{@ns_decl}>
592
+ <titleInfo></titleInfo>
593
+ <titleInfo type="alternative">
594
+ <title>Sponsored projects report for the year ended</title>
595
+ </titleInfo>
596
+ </mods>
597
+ EOXML
598
+ @smods_rec.from_str(m)
599
+ expect(@smods_rec.sw_addl_titles).to be_empty
600
+ end
566
601
  end
567
602
 
568
603
  context 'sort title' do
@@ -630,6 +665,7 @@ describe 'title fields (searchworks.rb)' do
630
665
  </titleInfo></mods>"
631
666
  @all_smods_rec.from_str(all)
632
667
  end
668
+
633
669
  it 'short titles' do
634
670
  expect(@mccarthy_smods_rec.sw_short_title).to eql 'McCarthy, John'
635
671
  expect(@insp_general_smods_rec.sw_short_title).to eql 'Semiannual report to Congress'
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'coveralls'
2
- Coveralls.wear!
1
+ require 'simplecov'
2
+ SimpleCov.start
3
3
 
4
4
  require 'stanford-mods'
5
5
 
@@ -27,4 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.add_development_dependency "yard"
28
28
  # tests
29
29
  gem.add_development_dependency 'rspec'
30
+ gem.add_development_dependency 'rubocop', '~> 0.60'
31
+ gem.add_development_dependency 'rubocop-rspec'
32
+ gem.add_development_dependency 'simplecov'
30
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-05 00:00:00.000000000 Z
12
+ date: 2021-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -95,6 +95,48 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.60'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.60'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: simplecov
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
98
140
  description: Stanford specific wrangling of MODS metadata from DOR, the Stanford Digital
99
141
  Object Repository
100
142
  email:
@@ -107,12 +149,12 @@ extra_rdoc_files:
107
149
  - README.md
108
150
  files:
109
151
  - ".coveralls.yml"
152
+ - ".github/workflows/ruby.yml"
110
153
  - ".gitignore"
111
154
  - ".hound.yml"
112
155
  - ".rspec"
113
156
  - ".rubocop.yml"
114
157
  - ".rubocop_todo.yml"
115
- - ".travis.yml"
116
158
  - ".yardopts"
117
159
  - Gemfile
118
160
  - LICENSE
@@ -170,8 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
212
  - !ruby/object:Gem::Version
171
213
  version: '0'
172
214
  requirements: []
173
- rubyforge_project:
174
- rubygems_version: 2.6.11
215
+ rubygems_version: 3.1.4
175
216
  signing_key:
176
217
  specification_version: 4
177
218
  summary: Stanford specific wrangling of MODS metadata
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
- script: rake
3
- rvm:
4
- - 2.3.1
5
- - 2.2.3 # spotlight
6
- - 2.2.0
7
- # we used to use jruby for merged DOR + MARC records, but no more ...
8
- - jruby-head
9
- # we also test against ruby-head, which may be unstable.
10
- - ruby-head
11
- matrix:
12
- allow_failures:
13
- - rvm: jruby-head
14
- - rvm: ruby-head
15
- notifications: false
16
- sudo: false