stanford-mods 3.0.0.alpha1 → 3.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bccde0bc740f4135ee9de0b7255f3ac347a16c858ca463801111f37f8ad84ecc
4
- data.tar.gz: a6e3fc9534efe4e37b05bf047007a5b9e3cd41f662e568b1b2333a1cc1213dce
3
+ metadata.gz: 57865ef64be3774919a58f9771243fb7f5090b09867fae098d3fa5ae6e2523cf
4
+ data.tar.gz: 1a09641f450a3739c9c61598ec4ad7a4f1f7b410c804d12df6d50530fb249cb7
5
5
  SHA512:
6
- metadata.gz: 7ab80915b8f299e35822e9f2b6e0047cf1b32c62bec9ac0218daeb0d7bd3fb4753d1668075b754e5a9a955098fb785c94a9c188654295894c2867fc7d04f7574
7
- data.tar.gz: fb1e1835b67fb30c7d19c2046c08a9a60bddda35b6b4067bb3518c8d8d9385a09d80846fc46e958f67d9a0eb89dcb2aef36ede3da03fc723f0158d1db3b81ee9
6
+ metadata.gz: c86f9171a032d1349068b43f6cf1272fbdf4a24419a58f66040132d7de2ea745853707b803608ea3344a137e544eff0e7e291a7b9c3922c09fe0568c68409a5e
7
+ data.tar.gz: d031a52bb328ae6efa0e42e7050fc4f990295509e4ee0a4b4c1f93f51b2412049b16c87091f27b95a02ed95be1278ccd5cbcc11771f59272bf77f82d73bd3bb2
@@ -25,7 +25,7 @@ module Stanford
25
25
 
26
26
  # @return [Array<String>] values for author_person_facet, author_person_display
27
27
  def sw_person_authors
28
- mods_ng_xml.personal_names.map(&:display_value_w_date)
28
+ mods_ng_xml.personal_name.map(&:display_value_w_date)
29
29
  end
30
30
 
31
31
  # return the display_value_w_date for all <mods><name> elements that do not have type='personal'
@@ -15,7 +15,7 @@ module Stanford
15
15
  # look for a keyDate and use it if there is one; otherwise pick earliest date
16
16
  # @param [Boolean] ignore_approximate true if approximate dates (per qualifier attribute) should be ignored; false if approximate dates should be included
17
17
  # @return [Integer] publication year as an Integer
18
- # @note for sorting: 5 B.C. => -5; 666 B.C. => -666
18
+ # @note for sorting: 5 BCE => -5; 666 BCE => -666
19
19
  def pub_year_int(fields = [:dateIssued, :dateCreated, :dateCaptured], ignore_approximate: false)
20
20
  fields.each do |date_key|
21
21
  values = mods_ng_xml.origin_info.send(date_key)
@@ -31,7 +31,7 @@ module Stanford
31
31
  # look for a keyDate and use it if there is one; otherwise pick earliest date
32
32
  # @param [Boolean] ignore_approximate true if approximate dates (per qualifier attribute) should be ignored; false if approximate dates should be included
33
33
  # @return [String] single String containing publication year for lexical sorting
34
- # @note for string sorting 5 B.C. = -5 => -995; 6 B.C. => -994, so 6 B.C. sorts before 5 B.C.
34
+ # @note for string sorting 5 BCE = -5 => -995; 6 BCE => -994, so 6 BCE sorts before 5 BCE
35
35
  # @deprecated use pub_year_int
36
36
  def pub_year_sort_str(fields = [:dateIssued, :dateCreated, :dateCaptured], ignore_approximate: false)
37
37
  fields.each do |date_key|
@@ -44,12 +44,12 @@ module Stanford
44
44
  end
45
45
 
46
46
  # return a single string intended for display of pub year
47
- # 0 < year < 1000: add A.D. suffix
48
- # year < 0: add B.C. suffix. ('-5' => '5 B.C.', '700 B.C.' => '700 B.C.')
47
+ # 0 < year < 1000: add CE suffix
48
+ # year < 0: add BCE suffix. ('-5' => '5 BCE', '700 BCE' => '700 BCE')
49
49
  # 195u => 195x
50
50
  # 19uu => 19xx
51
- # '-5' => '5 B.C.'
52
- # '700 B.C.' => '700 B.C.'
51
+ # '-5' => '5 BCE'
52
+ # '700 BCE' => '700 BCE'
53
53
  # '7th century' => '7th century'
54
54
  # date ranges?
55
55
  # prefer dateIssued (any) before dateCreated (any) before dateCaptured (any)
@@ -72,6 +72,10 @@ module Stanford
72
72
  origin_info.map { |el| Stanford::Mods::Imprint.new(el) }
73
73
  end
74
74
 
75
+ def place
76
+ term_values([:origin_info, :place, :placeTerm])
77
+ end
78
+
75
79
  # @return [String] single String containing imprint information for display
76
80
  def imprint_display_str
77
81
  imprints.map(&:display_str).reject(&:empty?).join('; ')
@@ -9,41 +9,49 @@ module Stanford
9
9
  # Searchworks requires that the MODS has a '//titleInfo/title'
10
10
  # @return [String] value for title_245_search, title_full_display
11
11
  def sw_full_title(title_info = first_title_info_node, sortable: false)
12
- return unless title_info
12
+ return unless title_info&.children&.any?
13
13
 
14
14
  title = title_info.title&.text&.strip
15
-
16
15
  return if title.nil? || title.empty?
17
16
 
18
- nonSort_title = title_info.nonSort&.text&.strip
17
+ title = ''
18
+ previous_element = nil
19
+
20
+ title_info.children.select { |value| title_parts.include? value.name }.each do |value|
21
+ next if value.name == 'nonSort' && sortable
19
22
 
20
- preSubTitle = [(nonSort_title unless sortable), title].compact.join(' ')
23
+ str = value.text.strip
24
+ next if str.empty?
21
25
 
22
- preSubTitle.sub!(/:$/, '')
26
+ delimiter = if title.empty? || title.end_with?(' ')
27
+ nil
28
+ elsif previous_element&.name == 'nonSort' && title.end_with?('-', '\'')
29
+ nil
30
+ elsif title.end_with?('.', ',', ':', ';')
31
+ ' '
32
+ elsif value.name == 'subTitle'
33
+ ' : '
34
+ elsif value.name == 'partName' && previous_element.name == 'partNumber'
35
+ ', '
36
+ elsif value.name == 'partNumber' || value.name == 'partName'
37
+ '. '
38
+ else
39
+ ' '
40
+ end
23
41
 
24
- subTitle = title_info.subTitle.text.strip
25
- preParts = subTitle.empty? ? preSubTitle : preSubTitle + " : " + subTitle
26
- preParts.sub!(/\.$/, '') if preParts # remove trailing period
42
+ title += delimiter if delimiter
43
+ title += str
27
44
 
28
- partName = title_info.partName.text.strip unless title_info.partName.text.strip.empty?
29
- partNumber = title_info.partNumber.text.strip unless title_info.partNumber.text.strip.empty?
30
- partNumber.sub!(/,$/, '') if partNumber # remove trailing comma
31
- if partNumber && partName
32
- parts = partNumber + ", " + partName
33
- elsif partNumber
34
- parts = partNumber
35
- elsif partName
36
- parts = partName
45
+ previous_element = value
37
46
  end
38
- parts.sub!(/\.$/, '') if parts
39
47
 
40
- result = parts ? preParts + ". " + parts : preParts
41
- return nil unless result
48
+ title += "." unless title =~ /\s*[[:punct:]]$/
49
+
50
+ title.strip
51
+ end
42
52
 
43
- result += "." unless result =~ /[[:punct:]]$/
44
- result.strip!
45
- result = nil if result.empty?
46
- result
53
+ def title_parts
54
+ %w[nonSort title subTitle partName partNumber]
47
55
  end
48
56
 
49
57
  # like sw_full_title without trailing \,/;:.
@@ -57,7 +65,7 @@ module Stanford
57
65
  # this includes all titles except
58
66
  # @return [Array<String>] values for title_variant_search
59
67
  def sw_addl_titles
60
- (full_titles - first_title_info_node.full_title).reject(&:blank?)
68
+ (full_titles - Array(first_title_info_node&.full_title)).reject(&:blank?)
61
69
  end
62
70
 
63
71
  # Returns a sortable version of the main title
@@ -76,4 +84,4 @@ module Stanford
76
84
  end
77
85
  end
78
86
  end
79
- end
87
+ end
@@ -65,11 +65,14 @@ module Stanford
65
65
  # @param [String] point coordinate point in degrees notation
66
66
  # @return [Float] converted value in decimal notation
67
67
  def coord_to_decimal(point)
68
- regex = /(?<dir>[NESW])\s*(?<deg>\d+)[°⁰º](?:(?<min>\d+)[ʹ'])?(?:(?<sec>\d+)[ʺ"])?/
68
+ regex = Regexp.union(
69
+ /(?<dir>[NESW])\s*(?<deg>\d+)[°⁰º](?:(?<min>\d+)[ʹ'])?(?:(?<sec>\d+)[ʺ"])?/,
70
+ /^\s*(?<dir>[NESW])\s*(?<deg>\d+(?:[.]\d+)?)\s*$/
71
+ )
69
72
  match = regex.match(point)
70
73
  return Float::INFINITY unless match
71
74
 
72
- dec = match['deg'].to_i
75
+ dec = match['deg'].to_f
73
76
  dec += match['min'].to_f / 60
74
77
  dec += match['sec'].to_f / 60 / 60
75
78
  dec = -1 * dec if match['dir'] == 'W' || match['dir'] == 'S'
@@ -15,7 +15,7 @@ module Stanford
15
15
  @xml = xml
16
16
  end
17
17
 
18
- # get display value for year, generally an explicit year or "17th century" or "5 B.C." or "1950s" or '845 A.D.'
18
+ # get display value for year, generally an explicit year or "17th century" or "5 BCE" or "1950s" or '845 CE'
19
19
  # @return [String, nil] String value for year if we could parse one, nil otherwise
20
20
  def date_str_for_display
21
21
  date = xml&.as_object&.date
@@ -32,9 +32,9 @@ module Stanford
32
32
  if !self.class.year_int_valid? date.year
33
33
  xml.text
34
34
  elsif date.year < 1
35
- "#{date.year.abs + 1} B.C."
35
+ "#{date.year.abs + 1} BCE"
36
36
  elsif date.year < 1000
37
- "#{date.year} A.D."
37
+ "#{date.year} CE"
38
38
  else
39
39
  date.year.to_s
40
40
  end
@@ -49,7 +49,7 @@ module Stanford
49
49
 
50
50
  # get String sortable value year if we can parse date_str to get a year.
51
51
  # SearchWorks currently uses a string field for pub date sorting; thus so does Spotlight.
52
- # The values returned must *lexically* sort in chronological order, so the B.C. dates are tricky
52
+ # The values returned must *lexically* sort in chronological order, so the BCE dates are tricky
53
53
  # @return [String, nil] String sortable year if we could parse one, nil otherwise
54
54
  # note that these values must *lexically* sort to create a chronological sort.
55
55
  def sortable_year_string_from_date_str
@@ -149,7 +149,7 @@ module Stanford
149
149
  end
150
150
 
151
151
  # Element text reduced to digits and hyphen. Captures date ranges and
152
- # negative (B.C.) dates. Used for comparison/deduping.
152
+ # negative (BCE) dates. Used for comparison/deduping.
153
153
  def base_value
154
154
  if text =~ /^\[?1\d{3}-\d{2}\??\]?$/
155
155
  return text.sub(/(\d{2})(\d{2})-(\d{2})/, '\1\2-\1\3')
@@ -166,8 +166,26 @@ module Stanford
166
166
  return text.strip unless text =~ /^-?\d+$/ || text =~ /^[\dXxu?-]{4}$/
167
167
  end
168
168
 
169
- # Delegate to the appropriate decoding method, if any
170
- case value.precision
169
+ if date.is_a?(EDTF::Interval)
170
+ if value.precision == :century || value.precision == :decade
171
+ return format_date(date, value.precision)
172
+ end
173
+
174
+ range = [
175
+ format_date(date.min, date.min.precision),
176
+ format_date(date.max, date.max.precision)
177
+ ].uniq.compact
178
+
179
+ return text.strip if range.empty?
180
+
181
+ range.join(' - ')
182
+ else
183
+ format_date(date, value.precision) || text.strip
184
+ end
185
+ end
186
+
187
+ def format_date(date, precision)
188
+ case precision
171
189
  when :day
172
190
  date.strftime('%B %e, %Y')
173
191
  when :month
@@ -175,32 +193,39 @@ module Stanford
175
193
  when :year
176
194
  year = date.year
177
195
  if year < 1
178
- "#{year.abs + 1} B.C."
179
- # Any dates before the year 1000 are explicitly marked A.D.
196
+ "#{year.abs + 1} BCE"
197
+ # Any dates before the year 1000 are explicitly marked CE
180
198
  elsif year > 1 && year < 1000
181
- "#{year} A.D."
199
+ "#{year} CE"
182
200
  else
183
201
  year.to_s
184
202
  end
185
203
  when :century
186
- return "#{(date.to_s[0..1].to_i + 1).ordinalize} century"
204
+ if date.year.negative?
205
+ "#{((date.year / 100).abs + 1).ordinalize} century BCE"
206
+ else
207
+ "#{((date.year / 100) + 1).ordinalize} century"
208
+ end
187
209
  when :decade
188
- return "#{date.year}s"
189
- else
190
- text.strip
210
+ "#{date.year}s"
191
211
  end
192
212
  end
193
213
 
194
- # Decoded date with "B.C." or "A.D." and qualifier markers. See (outdated):
214
+ # Decoded date with "BCE" or "CE" and qualifier markers. See (outdated):
195
215
  # https://consul.stanford.edu/display/chimera/MODS+display+rules#MODSdisplayrules-3b.%3CoriginInfo%3E
196
216
  def qualified_value
197
- date = decoded_value
198
-
199
- return "[ca. #{date}]" if qualifier == 'approximate'
200
- return "[#{date}?]" if qualifier == 'questionable'
201
- return "[#{date}]" if qualifier == 'inferred'
217
+ qualified_format = case qualifier
218
+ when 'approximate'
219
+ '[ca. %s]'
220
+ when 'questionable'
221
+ '[%s?]'
222
+ when 'inferred'
223
+ '[%s]'
224
+ else
225
+ '%s'
226
+ end
202
227
 
203
- date
228
+ format(qualified_format, decoded_value)
204
229
  end
205
230
  end
206
231
 
@@ -225,7 +250,7 @@ module Stanford
225
250
  @start&.encoding || @stop&.encoding
226
251
  end
227
252
 
228
- # Decoded dates with "B.C." or "A.D." and qualifier markers applied to
253
+ # Decoded dates with "BCE" or "CE" and qualifier markers applied to
229
254
  # the entire range, or individually if dates differ.
230
255
  def qualified_value
231
256
  if @start&.qualifier == @stop&.qualifier
@@ -281,7 +306,7 @@ module Stanford
281
306
 
282
307
  dates = dates - duplicated_ranges
283
308
 
284
- # output formatted dates with qualifiers, A.D./B.C., etc.
309
+ # output formatted dates with qualifiers, CE/BCE, etc.
285
310
  dates.map(&:qualified_value)
286
311
  end
287
312
  end
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = '3.0.0.alpha1'.freeze
4
+ VERSION = '3.2.0'.freeze
5
5
  end
6
6
  end
@@ -700,7 +700,7 @@ SEARCHWORKS_IMPRINT_DATA = {
700
700
  <dateIssued encoding="marc" point="start" keyDate="yes">0850</dateIssued>
701
701
  <dateIssued encoding="marc" point="end">1499</dateIssued>
702
702
  <issuance>monographic</issuance>' +
703
- mods_origin_info_end_str => 'California, 850 A.D. - 1499',
703
+ mods_origin_info_end_str => 'California, 850 CE - 1499',
704
704
  # coll rec bd001pp3337
705
705
  # coll rec fn508pj9953
706
706
  mods_origin_info_start_str +
@@ -728,7 +728,7 @@ SEARCHWORKS_IMPRINT_DATA = {
728
728
  <dateCreated point="start" qualifier="approximate" keyDate="yes">850</dateCreated>
729
729
  <dateCreated point="end" qualifier="approximate">1499</dateCreated>
730
730
  <issuance>monographic</issuance>' +
731
- mods_origin_info_end_str => 'England, [ca. 850 A.D. - 1499]',
731
+ mods_origin_info_end_str => 'England, [ca. 850 CE - 1499]',
732
732
  # sc582cv9633
733
733
  mods_origin_info_start_str +
734
734
  '<dateCreated keydate="yes">1314</dateCreated>
@@ -1055,7 +1055,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1055
1055
  <originInfo>
1056
1056
  <dateCreated encoding="edtf" point="start" keyDate="yes">-18</dateCreated>
1057
1057
  <dateCreated encoding="edtf" point="end">-17</dateCreated>' +
1058
- mods_origin_info_end_str => 'Spain; 19 B.C. - 18 B.C.',
1058
+ mods_origin_info_end_str => 'Spain; 19 BCE - 18 BCE',
1059
1059
  # bb408km1389
1060
1060
  mods_origin_info_start_str +
1061
1061
  ' <place supplied="yes">
@@ -1065,7 +1065,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1065
1065
  <originInfo>
1066
1066
  <dateCreated encoding="edtf" point="start" keyDate="yes">-1</dateCreated>
1067
1067
  <dateCreated encoding="edtf" point="end">11</dateCreated>' +
1068
- mods_origin_info_end_str => 'Lyon (France); 2 B.C. - 11 A.D.',
1068
+ mods_origin_info_end_str => 'Lyon (France); 2 BCE - 11 CE',
1069
1069
  # cs470ng8064
1070
1070
  mods_origin_info_start_str +
1071
1071
  ' <place supplied="yes">
@@ -1075,7 +1075,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1075
1075
  <originInfo>
1076
1076
  <dateCreated encoding="edtf" point="start" keyDate="yes">-1</dateCreated>
1077
1077
  <dateCreated encoding="edtf" point="end">0</dateCreated>' +
1078
- mods_origin_info_end_str => 'Antioch (Turkey) (?); 2 B.C. - 1 B.C.',
1078
+ mods_origin_info_end_str => 'Antioch (Turkey) (?); 2 BCE - 1 BCE',
1079
1079
  # vh834jh5059
1080
1080
  mods_origin_info_start_str +
1081
1081
  ' <place supplied="yes">
@@ -1085,7 +1085,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1085
1085
  <originInfo>
1086
1086
  <dateCreated encoding="edtf" point="start" keyDate="yes">13</dateCreated>
1087
1087
  <dateCreated encoding="edtf" point="end">14</dateCreated>' +
1088
- mods_origin_info_end_str => 'Lyon (France); 13 A.D. - 14 A.D.',
1088
+ mods_origin_info_end_str => 'Lyon (France); 13 CE - 14 CE',
1089
1089
  # sk424bh9379
1090
1090
  mods_origin_info_start_str +
1091
1091
  ' <place supplied="yes">
@@ -1095,7 +1095,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1095
1095
  <originInfo>
1096
1096
  <dateCreated encoding="edtf" point="start" keyDate="yes">34</dateCreated>
1097
1097
  <dateCreated encoding="edtf" point="end">35</dateCreated>' +
1098
- mods_origin_info_end_str => 'Alexandria (Egypt); 34 A.D. - 35 A.D.'
1098
+ mods_origin_info_end_str => 'Alexandria (Egypt); 34 CE - 35 CE'
1099
1099
  },
1100
1100
  # rigler
1101
1101
  'rumsey' =>
@@ -1235,7 +1235,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1235
1235
  '<dateIssued encoding="marc" point="start">800</dateIssued>
1236
1236
  <dateIssued encoding="marc" point="end">1899</dateIssued>
1237
1237
  <issuance>monographic</issuance>' +
1238
- mods_origin_info_end_str => '800 A.D. - 1899',
1238
+ mods_origin_info_end_str => '800 CE - 1899',
1239
1239
  # dc882bs3541
1240
1240
  mods_origin_info_start_str +
1241
1241
  '<place>
@@ -1245,7 +1245,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1245
1245
  <dateCreated encoding="w3cdtf" point="end" qualifier="approximate">0799</dateCreated>
1246
1246
  <dateCreated encoding="w3cdtf" keyDate="yes"/>
1247
1247
  <issuance>monographic</issuance>' +
1248
- mods_origin_info_end_str => 'Egypt, [ca. 700 A.D. - 799 A.D.]',
1248
+ mods_origin_info_end_str => 'Egypt, [ca. 700 CE - 799 CE]',
1249
1249
  # hg026ds6978
1250
1250
  mods_origin_info_start_str +
1251
1251
  '<place>
@@ -1253,7 +1253,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1253
1253
  </place>
1254
1254
  <dateCreated encoding="w3cdtf" keyDate="yes">0816</dateCreated>
1255
1255
  <issuance>monographic</issuance>' +
1256
- mods_origin_info_end_str => 'Central Arab lands, 816 A.D.',
1256
+ mods_origin_info_end_str => 'Central Arab lands, 816 CE',
1257
1257
  # ch617yk2621
1258
1258
  mods_origin_info_start_str +
1259
1259
  '<place>
@@ -1273,7 +1273,7 @@ SEARCHWORKS_IMPRINT_DATA = {
1273
1273
  <dateCreated encoding="w3cdtf" point="end" qualifier="approximate">1000</dateCreated>
1274
1274
  <dateCreated encoding="w3cdtf" keyDate="yes"/>
1275
1275
  <issuance>monographic</issuance>' +
1276
- mods_origin_info_end_str => 'Byzantine Empire, [ca. 950 A.D. - 1000]',
1276
+ mods_origin_info_end_str => 'Byzantine Empire, [ca. 950 CE - 1000]',
1277
1277
  # hj537kj5737
1278
1278
  mods_origin_info_start_str +
1279
1279
  '<dateIssued>15th century CE</dateIssued>
@@ -607,7 +607,7 @@ SEARCHWORKS_PUB_DATE_DATA = {
607
607
  mods_origin_info_start_str +
608
608
  '<dateIssued encoding="marc" point="start" keyDate="yes">0850</dateIssued>' +
609
609
  '<dateIssued encoding="marc" point="end">1499</dateIssued>' +
610
- mods_origin_info_end_str => [850, '850 A.D. - 1499'],
610
+ mods_origin_info_end_str => [850, '850 CE - 1499'],
611
611
  # coll rec bd001pp3337
612
612
  mods_origin_info_start_str +
613
613
  '<dateIssued encoding="marc" keyDate="yes" point="start">1000</dateIssued>' +
@@ -637,7 +637,7 @@ SEARCHWORKS_PUB_DATE_DATA = {
637
637
  mods_origin_info_start_str +
638
638
  '<dateCreated point="start" qualifier="approximate" keyDate="yes">850</dateCreated>' +
639
639
  '<dateCreated point="end" qualifier="approximate">1499</dateCreated>' +
640
- mods_origin_info_end_str => [850, '850 A.D. - 1499'],
640
+ mods_origin_info_end_str => [850, '850 CE - 1499'],
641
641
  # sc582cv9633
642
642
  mods_origin_info_start_str +
643
643
  '<dateCreated keydate="yes">1314</dateCreated>' +
@@ -722,12 +722,12 @@ SEARCHWORKS_PUB_DATE_DATA = {
722
722
  mods_origin_info_start_str +
723
723
  '<dateCreated keyDate="yes" point="start" qualifier="approximate">199 B.C.</dateCreated>' +
724
724
  '<dateCreated keyDate="yes" point="end" qualifier="approximate">100 B.C.</dateCreated>' +
725
- mods_origin_info_end_str => [-198, '199 B.C. - 100 B.C.'],
725
+ mods_origin_info_end_str => [-198, '199 BCE - 100 BCE'],
726
726
  # ww728rz0477
727
727
  mods_origin_info_start_str +
728
728
  '<dateCreated keyDate="yes" point="start" qualifier="approximate">211 B.C.</dateCreated>' +
729
729
  '<dateCreated keyDate="yes" point="end" qualifier="approximate">150 B.C.</dateCreated>' +
730
- mods_origin_info_end_str => [-210, '211 B.C. - 150 B.C.']
730
+ mods_origin_info_end_str => [-210, '211 BCE - 150 BCE']
731
731
  },
732
732
  # pcc
733
733
  # peace
@@ -796,27 +796,27 @@ SEARCHWORKS_PUB_DATE_DATA = {
796
796
  mods_origin_info_start_str +
797
797
  '<dateCreated encoding="edtf" point="start" keyDate="yes">-18</dateCreated>' +
798
798
  '<dateCreated encoding="edtf" point="end">-17</dateCreated>' +
799
- mods_origin_info_end_str => [-18, '19 B.C. - 17 B.C.'],
799
+ mods_origin_info_end_str => [-18, '19 BCE - 17 BCE'],
800
800
  # bb408km1389
801
801
  mods_origin_info_start_str +
802
802
  '<dateCreated encoding="edtf" point="start" keyDate="yes">-1</dateCreated>' +
803
803
  '<dateCreated encoding="edtf" point="end">11</dateCreated>' +
804
- mods_origin_info_end_str => [-1, '2 B.C. - 11 A.D.'],
804
+ mods_origin_info_end_str => [-1, '2 BCE - 11 CE'],
805
805
  # cs470ng8064
806
806
  mods_origin_info_start_str +
807
807
  '<dateCreated encoding="edtf" point="start" keyDate="yes">-1</dateCreated>' +
808
808
  '<dateCreated encoding="edtf" point="end">0</dateCreated>' +
809
- mods_origin_info_end_str => [-1, '2 B.C. - 0 A.D.'],
809
+ mods_origin_info_end_str => [-1, '2 BCE - 0 CE'],
810
810
  # vh834jh5059
811
811
  mods_origin_info_start_str +
812
812
  '<dateCreated encoding="edtf" point="start" keyDate="yes">13</dateCreated>' +
813
813
  '<dateCreated encoding="edtf" point="end">14</dateCreated>' +
814
- mods_origin_info_end_str => [13, '13 A.D. - 14 A.D.'],
814
+ mods_origin_info_end_str => [13, '13 CE - 14 CE'],
815
815
  # sk424bh9379
816
816
  mods_origin_info_start_str +
817
817
  '<dateCreated encoding="edtf" point="start" keyDate="yes">34</dateCreated>' +
818
818
  '<dateCreated encoding="edtf" point="end">35</dateCreated>' +
819
- mods_origin_info_end_str => [34, '34 A.D. - 35 A.D.']
819
+ mods_origin_info_end_str => [34, '34 CE - 35 CE']
820
820
  },
821
821
  # rigler
822
822
  # rumsey
@@ -931,23 +931,23 @@ SEARCHWORKS_PUB_DATE_DATA = {
931
931
  mods_origin_info_start_str +
932
932
  '<dateIssued encoding="marc" point="start">800</dateIssued>' +
933
933
  '<dateIssued encoding="marc" point="start">1899</dateIssued>' +
934
- mods_origin_info_end_str => [800, '800 A.D.'],
934
+ mods_origin_info_end_str => [800, '800 CE'],
935
935
  # dc882bs3541
936
936
  mods_origin_info_start_str +
937
937
  '<dateCreated encoding="w3cdtf" point="start" qualifier="approximate" keyDate="yes">0700</dateCreated>' +
938
938
  '<dateCreated encoding="w3cdtf" point="end" qualifier="approximate">0799</dateCreated>' +
939
939
  '<dateCreated encoding="w3cdtf" keyDate="yes"/>' +
940
- mods_origin_info_end_str => [700, '700 A.D. - 799 A.D.'],
940
+ mods_origin_info_end_str => [700, '700 CE - 799 CE'],
941
941
  # hg026ds6978
942
942
  mods_origin_info_start_str +
943
943
  '<dateCreated encoding="w3cdtf" keyDate="yes">0816</dateCreated>' +
944
- mods_origin_info_end_str => [816, '816 A.D.'],
944
+ mods_origin_info_end_str => [816, '816 CE'],
945
945
  # ct437ht0445
946
946
  mods_origin_info_start_str +
947
947
  '<dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">0900</dateCreated>' +
948
948
  '<dateCreated encoding="w3cdtf" point="end" qualifier="approximate">0999</dateCreated>' +
949
949
  '<dateCreated encoding="w3cdtf" keyDate="yes"/>' +
950
- mods_origin_info_end_str => [900, '900 A.D. - 999 A.D.'],
950
+ mods_origin_info_end_str => [900, '900 CE - 999 CE'],
951
951
  # ch617yk2621
952
952
  mods_origin_info_start_str +
953
953
  '<dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">1000</dateCreated>' +
@@ -959,7 +959,7 @@ SEARCHWORKS_PUB_DATE_DATA = {
959
959
  '<dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">0950</dateCreated>' +
960
960
  '<dateCreated encoding="w3cdtf" point="end" qualifier="approximate">1000</dateCreated>' +
961
961
  '<dateCreated encoding="w3cdtf" keyDate="yes"/>' +
962
- mods_origin_info_end_str => [950, '950 A.D. - 1000'],
962
+ mods_origin_info_end_str => [950, '950 CE - 1000'],
963
963
  # hj537kj5737
964
964
  mods_origin_info_start_str +
965
965
  '<dateIssued>15th century CE</dateIssued>' +
@@ -156,7 +156,7 @@ SPOTLIGHT_PUB_DATE_DATA = {
156
156
  mods_origin_info_start_str +
157
157
  '<dateIssued encoding="marc" point="start" keyDate="yes">0850</dateIssued>' +
158
158
  '<dateIssued encoding="marc" point="end">1499</dateIssued>' +
159
- mods_origin_info_end_str => ['0850', '850 A.D.'],
159
+ mods_origin_info_end_str => ['0850', '850 CE'],
160
160
  # nc881qb8504
161
161
  mods_origin_info_start_str +
162
162
  '<dateCreated point="start" qualifier="approximate" keyDate="yes">1000</dateCreated>' +
@@ -236,12 +236,12 @@ SPOTLIGHT_PUB_DATE_DATA = {
236
236
  mods_origin_info_start_str +
237
237
  '<dateCreated keyDate="yes" point="start" qualifier="approximate">200 B.C.</dateCreated>' +
238
238
  '<dateCreated keyDate="yes" point="end" qualifier="approximate">180 B.C.</dateCreated>' +
239
- mods_origin_info_end_str => ['-801', '200 B.C.'],
239
+ mods_origin_info_end_str => ['-801', '200 BCE'],
240
240
  # ww728rz0477
241
241
  mods_origin_info_start_str +
242
242
  '<dateCreated keyDate="yes" point="start" qualifier="approximate">211 B.C.</dateCreated>' +
243
243
  '<dateCreated keyDate="yes" point="end" qualifier="approximate">150 B.C.</dateCreated>' +
244
- mods_origin_info_end_str => ['-790', '211 B.C.']
244
+ mods_origin_info_end_str => ['-790', '211 BCE']
245
245
  },
246
246
  'renaissance' =>
247
247
  { # key is mods_xml; values = [pub date sortable facet value, pub date single string facet value]
data/spec/imprint_spec.rb CHANGED
@@ -108,7 +108,7 @@ describe Stanford::Mods::Imprint do
108
108
  it 'presents centuries' do
109
109
  smods_rec.from_str <<-XML
110
110
  #{mods_origin_info_start_str}
111
- <dateIssued encoding="edtf">18XX</dateIssued>
111
+ <dateIssued encoding="edtf">18xx</dateIssued>
112
112
  #{mods_origin_info_end_str}
113
113
  XML
114
114
 
@@ -120,7 +120,7 @@ describe Stanford::Mods::Imprint do
120
120
  it 'presents decades' do
121
121
  smods_rec.from_str <<-XML
122
122
  #{mods_origin_info_start_str}
123
- <dateIssued encoding="edtf">147X</dateIssued>
123
+ <dateIssued encoding="edtf">147x</dateIssued>
124
124
  #{mods_origin_info_end_str}
125
125
  XML
126
126
 
@@ -129,7 +129,7 @@ describe Stanford::Mods::Imprint do
129
129
  expect(updated_element).to eq '1470s'
130
130
  end
131
131
 
132
- it 'adds A.D. to early years' do
132
+ it 'adds CE to early years' do
133
133
  smods_rec.from_str <<-XML
134
134
  #{mods_origin_info_start_str}
135
135
  <dateIssued encoding="edtf">988</dateIssued>
@@ -138,10 +138,10 @@ describe Stanford::Mods::Imprint do
138
138
 
139
139
  imp = stanford_mods_imprint(smods_rec)
140
140
  updated_element = imp.send(:date_str)
141
- expect(updated_element).to eq '988 A.D.'
141
+ expect(updated_element).to eq '988 CE'
142
142
  end
143
143
 
144
- it 'adds B.C. to B.C. years' do
144
+ it 'adds BCE to BCE years' do
145
145
  smods_rec.from_str <<-XML
146
146
  #{mods_origin_info_start_str}
147
147
  <dateIssued encoding="edtf">-5</dateIssued>
@@ -150,10 +150,10 @@ describe Stanford::Mods::Imprint do
150
150
 
151
151
  imp = stanford_mods_imprint(smods_rec)
152
152
  updated_element = imp.send(:date_str)
153
- expect(updated_element).to eq '6 B.C.'
153
+ expect(updated_element).to eq '6 BCE'
154
154
  end
155
155
 
156
- it 'has special handling for the year 0 (1 B.C.)' do
156
+ it 'has special handling for the year 0 (1 BCE)' do
157
157
  smods_rec.from_str <<-XML
158
158
  #{mods_origin_info_start_str}
159
159
  <dateIssued>0</dateIssued>
@@ -162,7 +162,7 @@ describe Stanford::Mods::Imprint do
162
162
 
163
163
  imp = stanford_mods_imprint(smods_rec)
164
164
  updated_element = imp.send(:date_str)
165
- expect(updated_element).to eq '1 B.C.'
165
+ expect(updated_element).to eq '1 BCE'
166
166
  end
167
167
 
168
168
  it 'presents years + months' do
@@ -189,6 +189,31 @@ describe Stanford::Mods::Imprint do
189
189
  expect(updated_element).to eq 'April 2, 1948'
190
190
  end
191
191
 
192
+ it 'handles very precise EDTF ranges' do
193
+ smods_rec.from_str <<-XML
194
+ #{mods_origin_info_start_str}
195
+ <dateIssued encoding="edtf">2014-01/2020-12-31</dateIssued>
196
+ #{mods_origin_info_end_str}
197
+ XML
198
+
199
+ imp = stanford_mods_imprint(smods_rec)
200
+ updated_element = imp.send(:date_str)
201
+ expect(updated_element).to eq 'January 2014 - December 31, 2020'
202
+ end
203
+
204
+ xit 'handles BC EDTF centuries' do
205
+ # ruby-edtf apparently can't handle this format
206
+ smods_rec.from_str <<-XML
207
+ #{mods_origin_info_start_str}
208
+ <dateIssued encoding="edtf">-09XX</dateIssued>
209
+ #{mods_origin_info_end_str}
210
+ XML
211
+
212
+ imp = stanford_mods_imprint(smods_rec)
213
+ updated_element = imp.send(:date_str)
214
+ expect(updated_element).to eq '10th century BCE'
215
+ end
216
+
192
217
  it 'handles the approximate qualifier' do
193
218
  smods_rec.from_str <<-XML
194
219
  #{mods_origin_info_start_str}
@@ -210,13 +235,13 @@ describe Stanford::Mods::Imprint do
210
235
 
211
236
  imp = stanford_mods_imprint(smods_rec)
212
237
  updated_element = imp.send(:date_str)
213
- expect(updated_element).to eq '[322 A.D.?]'
238
+ expect(updated_element).to eq '[322 CE?]'
214
239
  end
215
240
 
216
241
  it 'handles the inferred qualifier' do
217
242
  smods_rec.from_str <<-XML
218
243
  #{mods_origin_info_start_str}
219
- <dateIssued encoding="edtf" qualifier="inferred">190X</dateIssued>
244
+ <dateIssued encoding="edtf" qualifier="inferred">190x</dateIssued>
220
245
  #{mods_origin_info_end_str}
221
246
  XML
222
247
 
@@ -9,10 +9,6 @@ describe Stanford::Mods::Coordinate do
9
9
  expect(described_class.new('W80°--E100°/N487°--S42°')).not_to be_valid
10
10
  end
11
11
 
12
- it 'rejects coordinates without degree symbols' do
13
- expect(described_class.new('W 650--W 100/N 700--N 550')).not_to be_valid
14
- end
15
-
16
12
  it 'rejects malformed coordinates' do
17
13
  expect(described_class.new('(E29°--E35/°S12°--S16°).')).not_to be_valid
18
14
  end
@@ -43,7 +39,9 @@ describe Stanford::Mods::Coordinate do
43
39
  %((W 170⁰--E 55⁰/N 40⁰--S 36⁰).) =>
44
40
  '-170.0 -36.0 55.0 40.0', # superscript 0 is almost a degree character..
45
41
  %((W 0°-W 0°/S 90°---S 90°)) =>
46
- '-0.0 -90.0 -0.0 -90.0' # one dash, two dashes, three dashes.. what's the difference?
42
+ '-0.0 -90.0 -0.0 -90.0', # one dash, two dashes, three dashes.. what's the difference?
43
+ %((W 030.6--E 068.1/N 041.7--S 042.4)) =>
44
+ '-30.6 -42.4 68.1 41.7'
47
45
  }.each do |value, expected|
48
46
  describe 'parsing' do
49
47
  let(:subject) { described_class.new(value) }
@@ -89,7 +89,7 @@ describe "computations from /originInfo field" do
89
89
  context '#pub_year_int' do
90
90
  it_behaves_like "single pub date value", :pub_year_int, 0
91
91
  # papyri - the only Spotlight data with BC dates
92
- it '-200 for 200 B.C.' do
92
+ it '-199 for 200 B.C.' do
93
93
  # hd778hw9236
94
94
  mods_str = mods_origin_info_start_str +
95
95
  '<dateCreated keyDate="yes" point="start" qualifier="approximate">200 B.C.</dateCreated>' +
@@ -98,7 +98,7 @@ describe "computations from /originInfo field" do
98
98
  smods_rec.from_str(mods_str)
99
99
  expect(smods_rec.pub_year_int).to eq(-199)
100
100
  end
101
- it '-211 for 211 B.C.' do
101
+ it '-210 for 211 B.C.' do
102
102
  # ww728rz0477
103
103
  mods_str = mods_origin_info_start_str +
104
104
  '<dateCreated keyDate="yes" point="start" qualifier="approximate">211 B.C.</dateCreated>' +
@@ -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><nonSort>The</nonSort></titleInfo></mods>"
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><nonSort>The</nonSort></titleInfo></mods>"
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 : a history.'
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 : a history'
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
@@ -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', '~> 3.0', '>= 3.0.1'
19
+ gem.add_dependency 'mods', '~> 3.0', '>= 3.0.3'
20
20
  # active_support for .ordinalize, eg. 1 -> 1st, 2 -> 2nd for centuries
21
21
  gem.add_dependency 'activesupport'
22
22
 
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: 3.0.0.alpha1
4
+ version: 3.2.0
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: 2022-02-01 00:00:00.000000000 Z
12
+ date: 2022-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '3.0'
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 3.0.1
23
+ version: 3.0.3
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '3.0'
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.1
33
+ version: 3.0.3
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activesupport
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -213,11 +213,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  requirements:
216
- - - ">"
216
+ - - ">="
217
217
  - !ruby/object:Gem::Version
218
- version: 1.3.1
218
+ version: '0'
219
219
  requirements: []
220
- rubygems_version: 3.2.32
220
+ rubygems_version: 3.3.7
221
221
  signing_key:
222
222
  specification_version: 4
223
223
  summary: Stanford specific wrangling of MODS metadata