stanford-mods 2.6.0 → 2.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/integer/inflections'
2
+
1
3
  module Stanford
2
4
  module Mods
3
5
  ##
@@ -45,9 +47,10 @@ module Stanford
45
47
  else
46
48
  date_field_keys.map do |date_field|
47
49
  next unless origin_info_node.respond_to?(date_field)
50
+
48
51
  date_elements = origin_info_node.send(date_field)
49
52
  date_elements.map(&:as_object).map(&:first) if date_elements.any?
50
- end.first
53
+ end.compact.first
51
54
  end
52
55
 
53
56
  if date_elements.nil? || date_elements.none?
@@ -82,6 +85,7 @@ module Stanford
82
85
  compact_values = values.compact.reject { |v| v.strip.empty? }
83
86
  return compact_values.join(delimiter) if compact_values.length == 1 ||
84
87
  !ends_in_terminating_punctuation?(delimiter)
88
+
85
89
  compact_values.each_with_index.map do |value, i|
86
90
  if (compact_values.length - 1) == i || # last item?
87
91
  ends_in_terminating_punctuation?(value)
@@ -104,6 +108,7 @@ module Stanford
104
108
 
105
109
  def publisher_vals_str(origin_info_node)
106
110
  return if origin_info_node.publisher.text.strip.empty?
111
+
107
112
  publishers = origin_info_node.publisher.reject do |p|
108
113
  p.text.strip.empty?
109
114
  end.map(&:text)
@@ -114,6 +119,7 @@ module Stanford
114
119
 
115
120
  def place_vals_str(origin_info_node)
116
121
  return if origin_info_node.place.text.strip.empty?
122
+
117
123
  places = place_terms(origin_info_node).reject do |p|
118
124
  p.text.strip.empty?
119
125
  end.map(&:text)
@@ -130,6 +136,7 @@ module Stanford
130
136
  def place_terms(origin_info_element)
131
137
  return [] unless origin_info_element.respond_to?(:place) &&
132
138
  origin_info_element.place.respond_to?(:placeTerm)
139
+
133
140
  if unencoded_place_terms?(origin_info_element)
134
141
  origin_info_element.place.placeTerm.select do |term|
135
142
  !term.attributes['type'].respond_to?(:value) ||
@@ -142,6 +149,7 @@ module Stanford
142
149
  term.attributes['authority'].respond_to?(:value) &&
143
150
  term.attributes['authority'].value == 'marccountry' &&
144
151
  MARC_COUNTRIES.include?(term.text.strip)
152
+
145
153
  term = term.clone
146
154
  term.content = MARC_COUNTRIES[term.text.strip]
147
155
  term
@@ -154,12 +162,14 @@ module Stanford
154
162
  def date_str(origin_info_node)
155
163
  date_vals = origin_info_date_vals(origin_info_node)
156
164
  return if date_vals.empty?
165
+
157
166
  date_vals.map(&:strip).join(' ')
158
167
  end
159
168
 
160
169
  def origin_info_date_vals(origin_info_node)
161
170
  date_field_keys.map do |date_field|
162
171
  next unless origin_info_node.respond_to?(date_field)
172
+
163
173
  date_elements = origin_info_node.send(date_field)
164
174
  date_elements_display_vals(date_elements) if date_elements.present?
165
175
  end.compact.flatten
@@ -338,8 +348,8 @@ module Stanford
338
348
  else
339
349
  ng_date_element.content
340
350
  end
341
- rescue
342
- ng_date_element.content
351
+ rescue
352
+ ng_date_element.content
343
353
  end
344
354
  ng_date_element
345
355
  end
@@ -352,8 +362,8 @@ module Stanford
352
362
  else
353
363
  ng_date_element.content
354
364
  end
355
- rescue
356
- ng_date_element.content
365
+ rescue
366
+ ng_date_element.content
357
367
  end
358
368
  ng_date_element
359
369
  end
@@ -376,8 +386,8 @@ module Stanford
376
386
  else
377
387
  my_ng_date_element.content
378
388
  end
379
- rescue
380
- my_ng_date_element.content
389
+ rescue
390
+ my_ng_date_element.content
381
391
  end
382
392
  my_ng_date_element
383
393
  end
@@ -392,14 +402,13 @@ module Stanford
392
402
  # note: not calling DateParsing.display_str_for_century directly because non-year text is lost
393
403
  century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP) if orig_date_str
394
404
  if century_matches
395
- require 'active_support/core_ext/integer/inflections'
396
405
  new_century_str = "#{(century_matches[3].to_i + 1).ordinalize} century"
397
406
  my_ng_date_element.content = "#{century_matches[1]}#{new_century_str}#{century_matches[4]}"
398
407
  else
399
408
  my_ng_date_element.content
400
409
  end
401
- rescue
402
- my_ng_date_element.content
410
+ rescue
411
+ my_ng_date_element.content
403
412
  end
404
413
  my_ng_date_element
405
414
  end
@@ -17,7 +17,7 @@ module Stanford
17
17
  first_wo_role ||= n if n.role.empty?
18
18
  n.role.each { |r|
19
19
  if r.authority.include?('marcrelator') &&
20
- (r.value.include?('Creator') || r.value.include?('Author'))
20
+ r.value.any? { |v| v.match(/creator/i) || v.match?(/author/i) }
21
21
  result ||= n.display_value_w_date
22
22
  end
23
23
  }
@@ -45,6 +45,7 @@ module Stanford
45
45
  result = []
46
46
  mods_ng_xml.personal_name.map do |n|
47
47
  next if n.role.size.zero?
48
+
48
49
  n.role.each { |r|
49
50
  result << n.display_value_w_date unless includes_marc_relator_collector_role?(r)
50
51
  }
@@ -58,6 +59,7 @@ module Stanford
58
59
  result = []
59
60
  mods_ng_xml.personal_name.each do |n|
60
61
  next if n.role.size.zero?
62
+
61
63
  n.role.each { |r|
62
64
  result << n.display_value_w_date if includes_marc_relator_collector_role?(r)
63
65
  }
@@ -82,6 +82,7 @@ module Stanford
82
82
  def year_display_str(date_el_array)
83
83
  result = date_parsing_result(date_el_array, :date_str_for_display)
84
84
  return result if result
85
+
85
86
  _ignore, orig_str_to_parse = self.class.earliest_year_str(date_el_array)
86
87
  DateParsing.date_str_for_display(orig_str_to_parse) if orig_str_to_parse
87
88
  end
@@ -93,6 +94,7 @@ module Stanford
93
94
  def year_int(date_el_array)
94
95
  result = date_parsing_result(date_el_array, :year_int_from_date_str)
95
96
  return result if result
97
+
96
98
  year_int, _ignore = self.class.earliest_year_int(date_el_array)
97
99
  year_int if year_int
98
100
  end
@@ -104,6 +106,7 @@ module Stanford
104
106
  def year_sort_str(date_el_array)
105
107
  result = date_parsing_result(date_el_array, :sortable_year_string_from_date_str)
106
108
  return result if result
109
+
107
110
  sortable_str, _ignore = self.class.earliest_year_str(date_el_array)
108
111
  sortable_str if sortable_str
109
112
  end
@@ -115,6 +118,7 @@ module Stanford
115
118
  def date_created_elements(ignore_approximate = false)
116
119
  date_created_nodeset = mods_ng_xml.origin_info.dateCreated
117
120
  return self.class.remove_approximate(date_created_nodeset) if ignore_approximate
121
+
118
122
  date_created_nodeset.to_a
119
123
  end
120
124
 
@@ -125,6 +129,7 @@ module Stanford
125
129
  def date_issued_elements(ignore_approximate = false)
126
130
  date_issued_nodeset = mods_ng_xml.origin_info.dateIssued
127
131
  return self.class.remove_approximate(date_issued_nodeset) if ignore_approximate
132
+
128
133
  date_issued_nodeset.to_a
129
134
  end
130
135
 
@@ -194,6 +199,7 @@ module Stanford
194
199
  # @return [Integer, String] year as a String or Integer, depending on method_sym
195
200
  def date_parsing_result(date_el_array, method_sym)
196
201
  return if date_el_array.empty?
202
+
197
203
  # prefer keyDate
198
204
  key_date_el = self.class.keyDate(date_el_array)
199
205
  DateParsing.send(method_sym, key_date_el.content) if key_date_el
@@ -239,6 +245,7 @@ module Stanford
239
245
  return nil unless pub_date
240
246
  return "#{pub_date.to_i + 1000} B.C." if pub_date.start_with?('-')
241
247
  return pub_date unless pub_date.include? '--'
248
+
242
249
  "#{pub_date[0, 2].to_i + 1}th century"
243
250
  end
244
251
 
@@ -251,6 +258,7 @@ module Stanford
251
258
  pd = pd.gsub('--', '00')
252
259
  end
253
260
  fail "pub_date_sort was about to return a non 4 digit value #{pd}!" if pd && pd.length != 4
261
+
254
262
  pd
255
263
  end
256
264
 
@@ -261,6 +269,7 @@ module Stanford
261
269
  def pub_date_display
262
270
  return dates_no_marc_encoding.first unless dates_no_marc_encoding.empty?
263
271
  return dates_marc_encoding.first unless dates_marc_encoding.empty?
272
+
264
273
  nil
265
274
  end
266
275
 
@@ -274,6 +283,7 @@ module Stanford
274
283
  # use the cached year if there is one
275
284
  if @pub_year
276
285
  return nil if @pub_year == ''
286
+
277
287
  return @pub_year
278
288
  end
279
289
 
@@ -307,6 +317,7 @@ module Stanford
307
317
  def pub_dates
308
318
  return dates_marc_encoding unless dates_marc_encoding.empty?
309
319
  return dates_no_marc_encoding unless dates_no_marc_encoding.empty?
320
+
310
321
  nil
311
322
  end
312
323
 
@@ -410,6 +421,7 @@ module Stanford
410
421
  dates.each do |f_date|
411
422
  matches = f_date.scan(/\d{1}th/)
412
423
  next if matches.empty?
424
+
413
425
  if matches.length == 1
414
426
  @pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'
415
427
  return @pub_year
@@ -436,6 +448,7 @@ module Stanford
436
448
  dates.each do |f_date|
437
449
  matches = f_date.scan(/\d{2}th/)
438
450
  next if matches.empty?
451
+
439
452
  if matches.length == 1
440
453
  @pub_year = (matches.first[0, 2].to_i - 1).to_s + '--'
441
454
  return @pub_year
@@ -464,6 +477,7 @@ module Stanford
464
477
  # Single digit u notation
465
478
  matches = f_date.scan(/\d{3}u/)
466
479
  return matches.first.tr('u', '0') if matches.length == 1
480
+
467
481
  # Double digit u notation
468
482
  matches = f_date.scan(/\d{2}u{2}/)
469
483
  return matches.first.tr('u', '-') if matches.length == 1
@@ -153,12 +153,13 @@ module Stanford
153
153
  first_title_info_node.title.text.strip.empty? ? nil : first_title_info_node.title.text.strip
154
154
  end
155
155
 
156
+ # Searchworks requires that the MODS has a '//titleInfo/title'
156
157
  # @return [String] value for title_245_search, title_full_display
157
158
  def sw_full_title
159
+ return nil if !first_title_info_node || !title
158
160
 
159
- return nil unless first_title_info_node
160
161
  preSubTitle = nonSort_title ? [nonSort_title, title].compact.join(" ") : title
161
- preSubTitle.sub!(/:$/, '') if preSubTitle # remove trailing colon
162
+ preSubTitle.sub!(/:$/, '')
162
163
 
163
164
  subTitle = first_title_info_node.subTitle.text.strip
164
165
  preParts = subTitle.empty? ? preSubTitle : preSubTitle + " : " + subTitle
@@ -178,6 +179,7 @@ module Stanford
178
179
 
179
180
  result = parts ? preParts + ". " + parts : preParts
180
181
  return nil unless result
182
+
181
183
  result += "." unless result =~ /[[:punct:]]$/
182
184
  result.strip!
183
185
  result = nil if result.empty?
@@ -191,13 +193,20 @@ module Stanford
191
193
  def sw_title_display
192
194
  result = sw_full_title
193
195
  return nil unless result
196
+
194
197
  result.sub(/[\.,;:\/\\]+$/, '').strip
195
198
  end
196
199
 
197
200
  # this includes all titles except
198
201
  # @return [Array<String>] values for title_variant_search
199
202
  def sw_addl_titles
200
- full_titles.select { |s| s !~ Regexp.new(Regexp.escape(sw_short_title)) }
203
+ excluded_title = sw_short_title || sw_title_display
204
+ if excluded_title.present?
205
+ title_regex = Regexp.new(Regexp.escape(excluded_title))
206
+ full_titles.reject { |s| s =~ title_regex }.reject(&:blank?)
207
+ else
208
+ full_titles.reject(&:blank?)
209
+ end
201
210
  end
202
211
 
203
212
  # Returns a sortable version of the main title
@@ -235,6 +244,7 @@ module Stanford
235
244
  def format_main
236
245
  types = typeOfResource
237
246
  return [] unless types
247
+
238
248
  article_genres = ['article', 'Article',
239
249
  'book chapter', 'Book chapter', 'Book Chapter',
240
250
  'issue brief', 'Issue brief', 'Issue Brief',
@@ -295,6 +305,7 @@ module Stanford
295
305
  def sw_genre
296
306
  genres = term_values(:genre)
297
307
  return [] unless genres
308
+
298
309
  val = genres.map(&:to_s)
299
310
  thesis_pub = ['thesis', 'Thesis']
300
311
  val << 'Thesis/Dissertation' if (genres & thesis_pub).any?
@@ -314,6 +325,7 @@ module Stanford
314
325
  def catkey
315
326
  catkey = term_values([:record_info, :recordIdentifier])
316
327
  return nil unless catkey && !catkey.empty?
328
+
317
329
  catkey.first.tr('a', '') # ensure catkey is numeric only
318
330
  end
319
331
  end # class Record
@@ -1,5 +1,7 @@
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
4
+ # code egy-Egyd from rfc5646
3
5
  SEARCHWORKS_LANGUAGES = {
4
6
  'aaa' => 'Afar',
5
7
  'abk' => 'Abkhaz',
@@ -30,6 +32,7 @@ SEARCHWORKS_LANGUAGES = {
30
32
  'arp' => 'Arapaho',
31
33
  'art' => 'Artificial (Other)',
32
34
  'arw' => 'Arawak',
35
+ 'ase' => 'American Sign Language',
33
36
  'asm' => 'Assamese',
34
37
  'ast' => 'Bable',
35
38
  'ath' => 'Athapascan (Other)',
@@ -123,6 +126,7 @@ SEARCHWORKS_LANGUAGES = {
123
126
  'dzo' => 'Dzongkha',
124
127
  'efi' => 'Efik',
125
128
  'egy' => 'Egyptian',
129
+ 'egy-Egyd' => 'Egyptian, Demotic',
126
130
  'eka' => 'Ekajuk',
127
131
  'elx' => 'Elamite',
128
132
  'eng' => 'English',
@@ -109,12 +109,14 @@ module Stanford
109
109
  if codes && codes.size > xvals.size
110
110
  subject.geographicCode.each { |n|
111
111
  next unless n.authority != 'marcgac' && n.authority != 'marccountry'
112
+
112
113
  sw_logger.info("#{druid} has subject geographicCode element with untranslated encoding (#{n.authority}): #{n.to_xml}")
113
114
  }
114
115
  end
115
116
 
116
117
  # FIXME: stanford-mods should be returning [], not nil ...
117
118
  return nil if !result || result.empty?
119
+
118
120
  result
119
121
  end
120
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.6.0".freeze
4
+ VERSION = '2.6.4'.freeze
5
5
  end
6
6
  end
data/lib/stanford-mods.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'mods'
2
3
  require 'stanford-mods/date_parsing'
3
4
  require 'stanford-mods/coordinate'
@@ -272,7 +272,7 @@ describe "date parsing methods" do
272
272
  '10/1/90' => '1990',
273
273
  '10/21/08' => '2008',
274
274
  '5-1-59' => '1959',
275
- '5-1-21' => '1921',
275
+ '5-1-29' => '1929',
276
276
  '5-1-14' => '2014'
277
277
  }
278
278
  # example string as key, expected parsed value as value
@@ -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
data/spec/imprint_spec.rb CHANGED
@@ -14,6 +14,7 @@ describe Stanford::Mods::Imprint do
14
14
  '' => [],
15
15
  '<dateIssued point="start">unparsable</dateIssued>' => [],
16
16
  '<dateIssued>1957</dateIssued>' => [1957],
17
+ '<dateCreated>1957</dateCreated>' => [1957],
17
18
  '<dateIssued>195u</dateIssued>' => (1950..1959).to_a,
18
19
  '<dateCreated keyDate="yes">1964</dateCreated><dateIssued>195u</dateIssued>' => [1964],
19
20
  '<dateIssued>1964</dateIssued><dateCreated>195u</dateCreated>' => [1964],
@@ -30,6 +31,7 @@ describe Stanford::Mods::Imprint do
30
31
  end
31
32
  end
32
33
  end
34
+
33
35
  describe 'bad dates' do
34
36
  it 'ignores bad date values' do
35
37
  smods_rec.from_str(mods_origin_info_start_str +
data/spec/name_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe "name/author concepts" do
11
11
  </name>" }
12
12
  let(:plain_creator_text) { "<name>
13
13
  <namePart>plain_creator_text</namePart>
14
- <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
14
+ <role><roleTerm type='text' authority='marcrelator'>creator</roleTerm></role>
15
15
  </name>" }
16
16
  let(:plain_creator_non_mr) { "<name>
17
17
  <namePart>plain_creator_non_mr</namePart>
@@ -23,7 +23,7 @@ describe "name/author concepts" do
23
23
  </name>" }
24
24
  let(:plain_author_text) { "<name>
25
25
  <namePart>plain_author_text</namePart>
26
- <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
26
+ <role><roleTerm type='text' authority='marcrelator'>author</roleTerm></role>
27
27
  </name>" }
28
28
  let(:plain_author_non_mr) { "<name>
29
29
  <namePart>plain_author_non_mr</namePart>
@@ -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)
@@ -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')
@@ -240,6 +240,7 @@ describe "Subject fields (searchworks.rb)" do
240
240
  expect(@smods_rec.subject_other_subvy_search).to be_nil
241
241
  end
242
242
  end
243
+
243
244
  context "genre subelement" do
244
245
  it "should have a separate value for each genre element" do
245
246
  m = "<mods #{@ns_decl}>
@@ -266,6 +267,7 @@ describe "Subject fields (searchworks.rb)" do
266
267
  before :each do
267
268
  allow(@smods_rec.sw_logger).to receive(:info).with(/ has subject geographicCode element with untranslated encoding \(iso3166\): <geographicCode authority=.*>us<\/geographicCode>/)
268
269
  end
270
+
269
271
  it "should be nil if there are no values in the MODS" do
270
272
  @smods_rec = Stanford::Mods::Record.new
271
273
  @smods_rec.from_str(@ng_mods_no_subject.to_s)