stanford-mods 2.4.1 → 2.6.2

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.
@@ -1,5 +1,6 @@
1
1
  # Language Values used by SearchWorks
2
2
  # From https://github.com/solrmarc/stanford-solr-marc/blob/master/stanford-sw/translation_maps/language_map.properties
3
+ # code 'ase' from iso639-3
3
4
  SEARCHWORKS_LANGUAGES = {
4
5
  'aaa' => 'Afar',
5
6
  'abk' => 'Abkhaz',
@@ -30,6 +31,7 @@ SEARCHWORKS_LANGUAGES = {
30
31
  'arp' => 'Arapaho',
31
32
  'art' => 'Artificial (Other)',
32
33
  'arw' => 'Arawak',
34
+ 'ase' => 'American Sign Language',
33
35
  'asm' => 'Assamese',
34
36
  'ast' => 'Bable',
35
37
  'ath' => 'Athapascan (Other)',
@@ -55,12 +55,11 @@ module Stanford
55
55
  end
56
56
 
57
57
  # Values are the contents of:
58
- # mods/genre
59
58
  # mods/subject/topic
60
59
  # @return [Array<String>] values for the topic_search Solr field for this document or nil if none
61
60
  def topic_search
62
61
  @topic_search ||= begin
63
- vals = term_values(:genre) || []
62
+ vals = []
64
63
  vals.concat(subject_topics) if subject_topics
65
64
  vals.empty? ? nil : vals
66
65
  end
@@ -110,12 +109,14 @@ module Stanford
110
109
  if codes && codes.size > xvals.size
111
110
  subject.geographicCode.each { |n|
112
111
  next unless n.authority != 'marcgac' && n.authority != 'marccountry'
112
+
113
113
  sw_logger.info("#{druid} has subject geographicCode element with untranslated encoding (#{n.authority}): #{n.to_xml}")
114
114
  }
115
115
  end
116
116
 
117
117
  # FIXME: stanford-mods should be returning [], not nil ...
118
118
  return nil if !result || result.empty?
119
+
119
120
  result
120
121
  end
121
122
  end
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "2.4.1".freeze
4
+ VERSION = '2.6.2'.freeze
5
5
  end
6
6
  end
@@ -394,12 +394,14 @@ describe "date parsing methods" do
394
394
  Stanford::Mods::DateParsing.date_str_for_display('1666')
395
395
  end
396
396
  end
397
+
397
398
  context '*sortable_year_string_from_date_str' do
398
399
  it 'calls instance method sortable_year_string_from_date_str' do
399
400
  expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:sortable_year_string_from_date_str)
400
401
  Stanford::Mods::DateParsing.sortable_year_string_from_date_str('1666')
401
402
  end
402
403
  end
404
+
403
405
  context '*year_int_from_date_str' do
404
406
  it 'calls instance method year_int_from_date_str' do
405
407
  expect_any_instance_of(Stanford::Mods::DateParsing).to receive(:year_int_from_date_str)
@@ -1293,7 +1293,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1293
1293
  <dateIssued>1500 CE</dateIssued>
1294
1294
  <issuance>monographic</issuance>' +
1295
1295
  mods_origin_info_end_str => 'Italy, 1500 CE'
1296
- },
1296
+ }
1297
1297
  # water
1298
1298
  # wilpf?
1299
1299
  # yotsuba
@@ -972,7 +972,7 @@ SEARCHWORKS_PUB_DATE_DATA = {
972
972
  mods_origin_info_start_str +
973
973
  '<dateIssued>1500 CE</dateIssued>' +
974
974
  mods_origin_info_end_str => [1500, '1500']
975
- },
975
+ }
976
976
  # water
977
977
  # wilpf?
978
978
  # yotsuba
@@ -9,6 +9,29 @@ describe Stanford::Mods::Imprint do
9
9
  let(:mods_origin_info_end_str) { '</originInfo></mods>' }
10
10
 
11
11
  describe 'date processing' do
12
+ describe '#publication_date_for_slider' do
13
+ {
14
+ '' => [],
15
+ '<dateIssued point="start">unparsable</dateIssued>' => [],
16
+ '<dateIssued>1957</dateIssued>' => [1957],
17
+ '<dateCreated>1957</dateCreated>' => [1957],
18
+ '<dateIssued>195u</dateIssued>' => (1950..1959).to_a,
19
+ '<dateCreated keyDate="yes">1964</dateCreated><dateIssued>195u</dateIssued>' => [1964],
20
+ '<dateIssued>1964</dateIssued><dateCreated>195u</dateCreated>' => [1964],
21
+ '<dateIssued point="start">195u</dateIssued><dateIssued point="end">1964</dateIssued>' => (1950..1964).to_a,
22
+ '<dateIssued>1964</dateIssued><dateIssued>195u</dateIssued>' => [1964] + (1950..1959).to_a,
23
+ '<dateCreated keyDate="yes" encoding="w3cdtf" point="start">1966</dateCreated><dateCreated encoding="w3cdtf" point="end">1967</dateCreated>' => [1966,1967]
24
+ }.each do |example, expected|
25
+ it 'works' do
26
+ smods_rec.from_str("#{mods_origin_info_start_str}
27
+ #{example}
28
+ #{mods_origin_info_end_str}")
29
+ imprint = stanford_mods_imprint(smods_rec)
30
+ expect(imprint.publication_date_for_slider).to eq expected
31
+ end
32
+ end
33
+ end
34
+
12
35
  describe 'bad dates' do
13
36
  it 'ignores bad date values' do
14
37
  smods_rec.from_str(mods_origin_info_start_str +
@@ -284,6 +284,7 @@ describe "name/author concepts" do
284
284
  expect(smods_rec.non_collector_person_authors).to eq [name]
285
285
  end
286
286
  end
287
+
287
288
  it 'nil if only collectors' do
288
289
  name_snippet =
289
290
  <<-EOF
@@ -345,6 +346,7 @@ describe "name/author concepts" do
345
346
  expect(smods_rec.collectors_w_dates).to eq [collector_name]
346
347
  end
347
348
  end
349
+
348
350
  context 'no valueURI for roleTerm' do
349
351
  it 'collector marc relator code' do
350
352
  name_snippet =
@@ -373,6 +375,7 @@ describe "name/author concepts" do
373
375
  expect(smods_rec.collectors_w_dates).to eq [collector_name]
374
376
  end
375
377
  end
378
+
376
379
  it 'does not include non-collectors' do
377
380
  name_snippet =
378
381
  <<-EOF
@@ -66,6 +66,7 @@ describe "computations from /originInfo field" do
66
66
  SPOTLIGHT_PUB_DATE_DATA.each_pair.each do |coll_name, coll_data|
67
67
  # papyri - the only Spotlight data with BC dates
68
68
  next if coll_name == 'papyri' && method_sym == :pub_year_int
69
+
69
70
  coll_data.each_pair do |mods_str, exp_vals|
70
71
  expected = exp_vals[exp_val_position]
71
72
  it "#{expected} for rec in #{coll_name}" do
@@ -303,6 +304,7 @@ describe "computations from /originInfo field" do
303
304
  end
304
305
  end
305
306
  end
307
+
306
308
  context "retains element when attribute qualifer=" do
307
309
  ['inferred', 'invalid_attr_val'].each do |attr_val|
308
310
  let(:qual_attr_val) { attr_val }
@@ -372,6 +374,7 @@ describe "computations from /originInfo field" do
372
374
  end
373
375
  end
374
376
  end
377
+
375
378
  context "retains element when attribute qualifer=" do
376
379
  ['inferred', 'invalid_attr_val'].each do |attr_val|
377
380
  let(:qual_attr_val) { attr_val }
@@ -74,6 +74,7 @@ describe "Physical Location for series, box, folder" do
74
74
  expect(@smods_rec.box).to eq expected
75
75
  end
76
76
  end
77
+
77
78
  context 'in /relatedItem/location/physicalLocation' do
78
79
  it "has the expected box label '#{expected}'" do
79
80
  @smods_rec.from_str(mods_rel_item_loc_phys_loc)
@@ -131,6 +132,7 @@ describe "Physical Location for series, box, folder" do
131
132
  expect(@smods_rec.folder).to eq expected
132
133
  end
133
134
  end
135
+
134
136
  context 'in /relatedItem/location/physicalLocation' do
135
137
  it "has the expected folder label '#{expected}'" do
136
138
  @smods_rec.from_str(mods_rel_item_loc_phys_loc)
@@ -179,12 +181,14 @@ describe "Physical Location for series, box, folder" do
179
181
  expect(@smods_rec.physical_location_str).to eq expected
180
182
  end
181
183
  end
184
+
182
185
  context 'in /relatedItem/location/physicalLocation' do
183
186
  it "has the expected location '#{expected}'" do
184
187
  @smods_rec.from_str(mods_rel_item_loc_phys_loc)
185
188
  expect(@smods_rec.physical_location_str).to eq expected
186
189
  end
187
190
  end
191
+
188
192
  context 'with multiple physicalLocation elements' do
189
193
  it "has the expected location '#{expected}'" do
190
194
  @smods_rec.from_str(mods_loc_multiple_phys_loc)
@@ -233,12 +237,14 @@ describe "Physical Location for series, box, folder" do
233
237
  expect(@smods_rec.series).to eq expected
234
238
  end
235
239
  end
240
+
236
241
  context 'in /relatedItem/location/physicalLocation' do
237
242
  it "has the expected series name '#{expected}'" do
238
243
  @smods_rec.from_str(mods_rel_item_loc_phys_loc)
239
244
  expect(@smods_rec.series).to eq expected
240
245
  end
241
246
  end
247
+
242
248
  context 'with multiple physicalLocation elements' do
243
249
  it "has the expected series name '#{expected}'" do
244
250
  @smods_rec.from_str(mods_loc_multiple_phys_loc)
@@ -5,269 +5,6 @@ describe "Format fields (searchworks.rb)" do
5
5
  @ns_decl = "xmlns='#{Mods::MODS_NS}'"
6
6
  end
7
7
 
8
- # @deprecated: this is no longer used in SW, Revs or Spotlight Jan 2016
9
- context "format" do
10
- context "Book:" do
11
- context "typeOfResource text," do
12
- it 'originInfo/issuance monographic' do
13
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>monographic</issuance></originInfo></mods>"
14
- @smods_rec.from_str(m)
15
- expect(@smods_rec.format).to eq ['Book']
16
- end
17
- context "genre" do
18
- it "'book chapter'", email: 'mods-squad 2014-05-22, Joanna Dyla' do
19
- m = "<mods #{@ns_decl}><genre>book chapter</genre><typeOfResource>text</typeOfResource></mods>"
20
- @smods_rec.from_str(m)
21
- expect(@smods_rec.format).to eq ['Book']
22
- m = "<mods #{@ns_decl}><genre>Book chapter</genre><typeOfResource>text</typeOfResource></mods>"
23
- @smods_rec.from_str(m)
24
- expect(@smods_rec.format).to eq ['Book']
25
- m = "<mods #{@ns_decl}><genre>Book Chapter</genre><typeOfResource>text</typeOfResource></mods>"
26
- @smods_rec.from_str(m)
27
- expect(@smods_rec.format).to eq ['Book']
28
- end
29
- it "'issue brief'", email: 'mods-squad 2014-05-22, Joanna Dyla' do
30
- m = "<mods #{@ns_decl}><genre>issue brief</genre><typeOfResource>text</typeOfResource></mods>"
31
- @smods_rec.from_str(m)
32
- expect(@smods_rec.format).to eq ['Book']
33
- m = "<mods #{@ns_decl}><genre>Issue brief</genre><typeOfResource>text</typeOfResource></mods>"
34
- @smods_rec.from_str(m)
35
- expect(@smods_rec.format).to eq ['Book']
36
- m = "<mods #{@ns_decl}><genre>Issue Brief</genre><typeOfResource>text</typeOfResource></mods>"
37
- @smods_rec.from_str(m)
38
- expect(@smods_rec.format).to eq ['Book']
39
- end
40
- it "'librettos'", jira: 'INDEX-98' do
41
- m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
42
- @smods_rec.from_str(m)
43
- expect(@smods_rec.format).to eq ['Book']
44
- m = "<mods #{@ns_decl}><genre>Librettos</genre><typeOfResource>text</typeOfResource></mods>"
45
- @smods_rec.from_str(m)
46
- expect(@smods_rec.format).to eq ['Book']
47
- end
48
- it "'libretto' isn't valid", jira: 'INDEX-98' do
49
- m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
50
- @smods_rec.from_str(m)
51
- expect(@smods_rec.format).to eq []
52
- end
53
- it "'project report'", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
54
- m = "<mods #{@ns_decl}><genre>project report</genre><typeOfResource>text</typeOfResource></mods>"
55
- @smods_rec.from_str(m)
56
- expect(@smods_rec.format).to eq ['Book']
57
- m = "<mods #{@ns_decl}><genre>Project report</genre><typeOfResource>text</typeOfResource></mods>"
58
- @smods_rec.from_str(m)
59
- expect(@smods_rec.format).to eq ['Book']
60
- m = "<mods #{@ns_decl}><genre>Project Report</genre><typeOfResource>text</typeOfResource></mods>"
61
- @smods_rec.from_str(m)
62
- expect(@smods_rec.format).to eq ['Book']
63
- end
64
- it "'report' isn't valid", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
65
- m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
66
- @smods_rec.from_str(m)
67
- expect(@smods_rec.format).to eq []
68
- end
69
- it "'technical report'", jira: 'GRYPHONDOR-207' do
70
- m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
71
- @smods_rec.from_str(m)
72
- expect(@smods_rec.format).to eq ['Book']
73
- m = "<mods #{@ns_decl}><genre>Technical report</genre><typeOfResource>text</typeOfResource></mods>"
74
- @smods_rec.from_str(m)
75
- expect(@smods_rec.format).to eq ['Book']
76
- m = "<mods #{@ns_decl}><genre>Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
77
- @smods_rec.from_str(m)
78
- expect(@smods_rec.format).to eq ['Book']
79
- end
80
- it "'working paper'", email: 'mods-squad 2014-05-22, Joanna Dyla' do
81
- m = "<mods #{@ns_decl}><genre>working paper</genre><typeOfResource>text</typeOfResource></mods>"
82
- @smods_rec.from_str(m)
83
- expect(@smods_rec.format).to eq ['Book']
84
- m = "<mods #{@ns_decl}><genre>Working paper</genre><typeOfResource>text</typeOfResource></mods>"
85
- @smods_rec.from_str(m)
86
- expect(@smods_rec.format).to eq ['Book']
87
- m = "<mods #{@ns_decl}><genre>Working Paper</genre><typeOfResource>text</typeOfResource></mods>"
88
- @smods_rec.from_str(m)
89
- expect(@smods_rec.format).to eq ['Book']
90
- end
91
- end
92
- end
93
- end # 'Book'
94
-
95
- context "Computer File: typeOfResource 'software, multimedia'" do
96
- it "no genre (e.g. Dataset)" do
97
- m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResource></mods>"
98
- @smods_rec.from_str(m)
99
- expect(@smods_rec.format).to eq ['Computer File']
100
- end
101
- it "genre 'game'", jira: 'GRYPHONDOR-207' do
102
- m = "<mods #{@ns_decl}><genre>game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
103
- @smods_rec.from_str(m)
104
- expect(@smods_rec.format).to eq ['Computer File']
105
- m = "<mods #{@ns_decl}><genre>Game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
106
- @smods_rec.from_str(m)
107
- expect(@smods_rec.format).to eq ['Computer File']
108
- end
109
- end
110
-
111
- it "Conference Proceedings: typeOfResource 'text', genre 'conference publication'", jira: 'GRYPHONDOR-207' do
112
- m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResource></mods>"
113
- @smods_rec.from_str(m)
114
- expect(@smods_rec.format).to eq ['Conference Proceedings']
115
- m = "<mods #{@ns_decl}><genre>Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
116
- @smods_rec.from_str(m)
117
- expect(@smods_rec.format).to eq ['Conference Proceedings']
118
- m = "<mods #{@ns_decl}><genre>Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
119
- @smods_rec.from_str(m)
120
- expect(@smods_rec.format).to eq ['Conference Proceedings']
121
- end
122
-
123
- context "Journal/Periodical: typeOfResource 'text'," do
124
- it "genre 'article" do
125
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>article</genre></mods>"
126
- @smods_rec.from_str(m)
127
- expect(@smods_rec.format).to eq ['Journal/Periodical']
128
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Article</genre></mods>"
129
- @smods_rec.from_str(m)
130
- expect(@smods_rec.format).to eq ['Journal/Periodical']
131
- end
132
- it "originInfo/issuance 'continuing'" do
133
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>continuing</issuance></originInfo></mods>"
134
- @smods_rec.from_str(m)
135
- expect(@smods_rec.format).to eq ['Journal/Periodical']
136
- end
137
- end
138
-
139
- it "Image: typeOfResource 'still image'" do
140
- m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResource></mods>"
141
- @smods_rec.from_str(m)
142
- expect(@smods_rec.format).to eq ['Image']
143
- end
144
-
145
- it "Manuscript/Archive: typeOfResource 'mixed material'" do
146
- m = "<mods #{@ns_decl}><typeOfResource>mixed material</typeOfResource></mods>"
147
- @smods_rec.from_str(m)
148
- expect(@smods_rec.format).to eq ['Manuscript/Archive']
149
- end
150
-
151
- it "Map/Globe: typeOfResource 'cartographic'" do
152
- m = "<mods #{@ns_decl}><typeOfResource>cartographic</typeOfResource></mods>"
153
- @smods_rec.from_str(m)
154
- expect(@smods_rec.format).to eq ['Map/Globe']
155
- end
156
-
157
- it "Music - Recording: typeOfResource 'sound recording-musical'", jira: 'GRYPHONDOR-207' do
158
- m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
159
- @smods_rec.from_str(m)
160
- expect(@smods_rec.format).to eq ['Music - Recording']
161
- end
162
-
163
- it "Music - Score: typeOfResource 'notated music'" do
164
- m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResource></mods>"
165
- @smods_rec.from_str(m)
166
- expect(@smods_rec.format).to eq ['Music - Score']
167
- end
168
-
169
- it "Other: typeOfResource 'text', genre 'student project report'", email: 'from Vitus, August 16, 2013' do
170
- m = "<mods #{@ns_decl}><genre>student project report</genre><typeOfResource>text</typeOfResource></mods>"
171
- @smods_rec.from_str(m)
172
- expect(@smods_rec.format).to eq ['Other']
173
- m = "<mods #{@ns_decl}><genre>Student project report</genre><typeOfResource>text</typeOfResource></mods>"
174
- @smods_rec.from_str(m)
175
- expect(@smods_rec.format).to eq ['Other']
176
- m = "<mods #{@ns_decl}><genre>Student Project report</genre><typeOfResource>text</typeOfResource></mods>"
177
- @smods_rec.from_str(m)
178
- expect(@smods_rec.format).to eq ['Other']
179
- m = "<mods #{@ns_decl}><genre>Student Project Report</genre><typeOfResource>text</typeOfResource></mods>"
180
- @smods_rec.from_str(m)
181
- expect(@smods_rec.format).to eq ['Other']
182
- end
183
-
184
- context "Sound Recording:" do
185
- it "typeOfResource 'sound recording-nonmusical', genre 'sound", jira: 'GRYPHONDOR-207' do
186
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
187
- @smods_rec.from_str(m)
188
- expect(@smods_rec.format).to eq ['Sound Recording']
189
- m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
190
- @smods_rec.from_str(m)
191
- expect(@smods_rec.format).to eq ['Sound Recording']
192
- end
193
- it "typeOfResource 'sound recording', genre 'sound", jira: 'INDEX-94' do
194
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
195
- @smods_rec.from_str(m)
196
- expect(@smods_rec.format).to eq ['Sound Recording']
197
- m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
198
- @smods_rec.from_str(m)
199
- expect(@smods_rec.format).to eq ['Sound Recording']
200
- end
201
- end
202
-
203
- it "Thesis: typeOfResource 'text', genre 'thesis'" do
204
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>thesis</genre></mods>"
205
- @smods_rec.from_str(m)
206
- expect(@smods_rec.format).to eq ['Thesis']
207
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Thesis</genre></mods>"
208
- @smods_rec.from_str(m)
209
- expect(@smods_rec.format).to eq ['Thesis']
210
- end
211
-
212
- context "Video: typeOfResource 'moving image'" do
213
- it "no genre" do
214
- m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource></mods>"
215
- @smods_rec.from_str(m)
216
- expect(@smods_rec.format).to eq ['Video']
217
- end
218
- it "genre 'motion picture'", jira: 'GRYPHONDOR-207' do
219
- m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
220
- @smods_rec.from_str(m)
221
- expect(@smods_rec.format).to eq ['Video']
222
- m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
223
- @smods_rec.from_str(m)
224
- expect(@smods_rec.format).to eq ['Video']
225
- m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
226
- @smods_rec.from_str(m)
227
- expect(@smods_rec.format).to eq ['Video']
228
- end
229
- end
230
-
231
- context "multiple format values", jira: 'INDEX-32' do
232
- it "multiple typeOfResource elements" do
233
- m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource><typeOfResource>sound recording</typeOfResource></mods>"
234
- @smods_rec.from_str(m)
235
- expect(@smods_rec.format).to eq ['Video', 'Sound Recording']
236
- end
237
- it "multiple genre elements, single typeOfResource" do
238
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
239
- @smods_rec.from_str(m)
240
- expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical']
241
- end
242
- it "mish mash" do
243
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><typeOfResource>still image</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
244
- @smods_rec.from_str(m)
245
- expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical', 'Image']
246
- end
247
- it "doesn't give duplicate values" do
248
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>issue brief</genre></mods>"
249
- @smods_rec.from_str(m)
250
- expect(@smods_rec.format).to eq ['Book']
251
- end
252
- end
253
-
254
- it "empty Array if no typeOfResource field" do
255
- m = "<mods #{@ns_decl}><originInfo>
256
- <dateCreated>1904</dateCreated>
257
- </originInfo></mods>"
258
- @smods_rec.from_str(m)
259
- expect(@smods_rec.format).to eq []
260
- end
261
-
262
- it "empty Array if weird typeOfResource value" do
263
- m = "<mods #{@ns_decl}>
264
- <typeOfResource>foo</typeOfResource>
265
- </mods>"
266
- @smods_rec.from_str(m)
267
- expect(@smods_rec.format).to eq []
268
- end
269
- end # format
270
-
271
8
  context "format_main" do
272
9
  it "3D object: typeOfResource 'three dimensional object'" do
273
10
  m = "<mods #{@ns_decl}><typeOfResource>three dimensional object</typeOfResource></mods>"
@@ -329,10 +66,10 @@ describe "Format fields (searchworks.rb)" do
329
66
  @smods_rec.from_str(m)
330
67
  expect(@smods_rec.format_main).to eq ['Book']
331
68
  end
332
- it "'report' isn't valid", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
69
+ it "'report' isn't valid, so defaults to book", jira: 'GRYP-170', github: 'gdor-indexer/#7' do
333
70
  m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
334
71
  @smods_rec.from_str(m)
335
- expect(@smods_rec.format_main).to eq []
72
+ expect(@smods_rec.format_main).to eq ['Book']
336
73
  end
337
74
  it "'student project report'", consul: '/NGDE/Format 2014-05-28' do
338
75
  m = "<mods #{@ns_decl}><genre authority=\"local\">student project report</genre><typeOfResource>text</typeOfResource></mods>"
@@ -400,10 +137,10 @@ describe "Format fields (searchworks.rb)" do
400
137
  @smods_rec.from_str(m)
401
138
  expect(@smods_rec.format_main).to eq ['Book']
402
139
  end
403
- it "'libretto' isn't valid", jira: 'INDEX-98' do
140
+ it "'libretto' isn't valid, so it defaults to book", jira: 'INDEX-98' do
404
141
  m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
405
142
  @smods_rec.from_str(m)
406
- expect(@smods_rec.format_main).to eq []
143
+ expect(@smods_rec.format_main).to eq ['Book']
407
144
  end
408
145
  it "'librettos'", jira: 'INDEX-98' do
409
146
  m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
@@ -578,57 +315,57 @@ describe "Format fields (searchworks.rb)" do
578
315
  end # format_main
579
316
 
580
317
  context "sw_genre" do
581
- it "ignores values that are not in the prescribed list" do
318
+ it "includes values that are not in the prescribed list" do
582
319
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Not on the list</genre><typeOfResource>text</typeOfResource></mods>"
583
320
  @smods_rec.from_str(m)
584
- expect(@smods_rec.sw_genre).to eq []
321
+ expect(@smods_rec.sw_genre).to eq ['Not on the list']
585
322
  end
586
323
  it "Conference proceedings: typeOfResource 'text', genre 'conference publication'" do
587
324
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">conference publication</genre><typeOfResource>text</typeOfResource></mods>"
588
325
  @smods_rec.from_str(m)
589
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
326
+ expect(@smods_rec.sw_genre).to eq ['conference publication', 'Conference proceedings']
590
327
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
591
328
  @smods_rec.from_str(m)
592
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
329
+ expect(@smods_rec.sw_genre).to eq ['Conference publication', 'Conference proceedings']
593
330
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
594
331
  @smods_rec.from_str(m)
595
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
332
+ expect(@smods_rec.sw_genre).to eq ['Conference Publication', 'Conference proceedings']
596
333
  end
597
334
  it "Thesis/Dissertation: typeOfResource 'text', genre 'thesis'" do
598
335
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">thesis</genre><typeOfResource>text</typeOfResource></mods>"
599
336
  @smods_rec.from_str(m)
600
- expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
337
+ expect(@smods_rec.sw_genre).to eq ['thesis', 'Thesis/Dissertation']
601
338
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Thesis</genre><typeOfResource>text</typeOfResource></mods>"
602
339
  @smods_rec.from_str(m)
603
- expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
340
+ expect(@smods_rec.sw_genre).to eq ['Thesis', 'Thesis/Dissertation']
604
341
  end
605
342
  it "Government Document: typeOfResource 'text', genre 'government publication'" do
606
343
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">government publication</genre><typeOfResource>text</typeOfResource></mods>"
607
344
  @smods_rec.from_str(m)
608
- expect(@smods_rec.sw_genre).to eq ['Government document']
345
+ expect(@smods_rec.sw_genre).to eq ['government publication', 'Government document']
609
346
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Government publication</genre><typeOfResource>text</typeOfResource></mods>"
610
347
  @smods_rec.from_str(m)
611
- expect(@smods_rec.sw_genre).to eq ['Government document']
348
+ expect(@smods_rec.sw_genre).to eq ['Government publication', 'Government document']
612
349
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Government Publication</genre><typeOfResource>text</typeOfResource></mods>"
613
350
  @smods_rec.from_str(m)
614
- expect(@smods_rec.sw_genre).to eq ['Government document']
351
+ expect(@smods_rec.sw_genre).to eq ['Government Publication', 'Government document']
615
352
  m = "<mods #{@ns_decl}><genre>government publication</genre><typeOfResource>text</typeOfResource></mods>"
616
353
  @smods_rec.from_str(m)
617
- expect(@smods_rec.sw_genre).to eq ['Government document']
354
+ expect(@smods_rec.sw_genre).to eq ['government publication', 'Government document']
618
355
  end
619
356
  it "Technical Report: typeOfResource 'text', genre 'technical report'" do
620
357
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">technical report</genre><typeOfResource>text</typeOfResource></mods>"
621
358
  @smods_rec.from_str(m)
622
- expect(@smods_rec.sw_genre).to eq ['Technical report']
359
+ expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report']
623
360
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Technical report</genre><typeOfResource>text</typeOfResource></mods>"
624
361
  @smods_rec.from_str(m)
625
362
  expect(@smods_rec.sw_genre).to eq ['Technical report']
626
363
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
627
364
  @smods_rec.from_str(m)
628
- expect(@smods_rec.sw_genre).to eq ['Technical report']
365
+ expect(@smods_rec.sw_genre).to eq ['Technical Report', 'Technical report']
629
366
  m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
630
367
  @smods_rec.from_str(m)
631
- expect(@smods_rec.sw_genre).to eq ['Technical report']
368
+ expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report']
632
369
  end
633
370
  it "it does not include Archived website: typeOfResource 'text', genre 'archived website'" do
634
371
  m = "<mods #{@ns_decl}><genre authority=\"marcgt\">archived website</genre><typeOfResource>text</typeOfResource></mods>"
@@ -638,13 +375,13 @@ describe "Format fields (searchworks.rb)" do
638
375
  it "capitalizes the first letter of a genre value" do
639
376
  m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">technical report</genre></mods>"
640
377
  @smods_rec.from_str(m)
641
- expect(@smods_rec.sw_genre).to eq ['Technical report']
378
+ expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report']
642
379
  m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">Technical report</genre></mods>"
643
380
  @smods_rec.from_str(m)
644
381
  expect(@smods_rec.sw_genre).to eq ['Technical report']
645
382
  m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">Technical Report</genre></mods>"
646
383
  @smods_rec.from_str(m)
647
- expect(@smods_rec.sw_genre).to eq ['Technical report']
384
+ expect(@smods_rec.sw_genre).to eq ['Technical Report', 'Technical report']
648
385
  end
649
386
  # NOTE: may need to remove plurals and/or trailing punctuation in future
650
387
  it "returns all genre values" do
@@ -655,7 +392,7 @@ describe "Format fields (searchworks.rb)" do
655
392
  <genre>thesis</genre>
656
393
  </mods>"
657
394
  @smods_rec.from_str(m)
658
- expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation', 'Conference proceedings', 'Government document']
395
+ expect(@smods_rec.sw_genre).to eq ['government publication', 'conference publication', 'thesis', 'Thesis/Dissertation', 'Conference proceedings', 'Government document']
659
396
  end
660
397
  it "doesn't have duplicates" do
661
398
  m = "<mods #{@ns_decl}>
@@ -665,7 +402,7 @@ describe "Format fields (searchworks.rb)" do
665
402
  <genre>Conference publication</genre>
666
403
  </mods>"
667
404
  @smods_rec.from_str(m)
668
- expect(@smods_rec.sw_genre).to eq ['Conference proceedings', 'Technical report']
405
+ expect(@smods_rec.sw_genre).to eq ['conference publication', 'technical report', 'Conference publication', 'Conference proceedings', 'Technical report']
669
406
  end
670
407
  it "empty Array if no genre values" do
671
408
  m = "<mods #{@ns_decl}>