stanford-mods 3.3.8 → 3.3.10

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: b1e3a3a94c0657e2e29e3290209d67ea16d1f10d1cece61e334543f33c8cde7f
4
- data.tar.gz: 17edb99128248caed061cc87d4d547bf896b7a915d08fdad9e2f209f2d6457fe
3
+ metadata.gz: cb1b017fccf0e3f74a5c0594e5a21a43f7816055b2c67486392af2308ce85860
4
+ data.tar.gz: b992e7323c4e096d0714d5391a9c4206745c536f99b2fad92fbe9b1affb89645
5
5
  SHA512:
6
- metadata.gz: ec96c2955e6e96205b83395953413bfb2662af53f2725c9c13149688ac6c15b2da8cf4e46fa8aea8ac299b212204bbf680cdfa876780169a25707661903c259b
7
- data.tar.gz: 1e5a8ddd8ad2e2a90ea37363335f1655fe6a4ef58b5d37089b38be265f00a91f617f7593f4b617d0f7dc1d066045ec926f207d2d308fa9c748170a03545e4cf7
6
+ metadata.gz: d28ee675c3f53cf6052b732883487475ec44519a5a79241a0de4e1aa798daae208a6f6d5c951d561745a8035b35f5f8716788f9e7520833a5cdc49d19533d832
7
+ data.tar.gz: e992ac4964d4b857084427c6a2e291c1c2cbe219d5b524be328a86aa1670cbe0993cc803d66c374b0460ba41239318b5f05533f9060fac7415220983886a7ca9
@@ -10,6 +10,8 @@ module Stanford
10
10
  # however, the date_parsing class only does years, and this does finer tuned dates and also
11
11
  # reformats them according to the encoding.
12
12
  class Imprint
13
+ BCE_CHAR_SORT_MAP = { '0' => '9', '1' => '8', '2' => '7', '3' => '6', '4' => '5', '5' => '4', '6' => '3', '7' => '2', '8' => '1', '9' => '0' }.freeze
14
+
13
15
  attr_reader :element
14
16
 
15
17
  # @param [Nokogiri::XML::Node] an originInfo node
@@ -46,7 +48,7 @@ module Stanford
46
48
  end.compact.flatten
47
49
  end
48
50
 
49
- # called by mods_display gem, so made public
51
+ # called by mods_display gem
50
52
  def publisher_vals_str
51
53
  return if element.publisher.text.strip.empty?
52
54
 
@@ -56,6 +58,13 @@ module Stanford
56
58
  compact_and_join_with_delimiter(publishers, ' : ')
57
59
  end
58
60
 
61
+ # called by mods_display gem
62
+ def edition_vals_str
63
+ element.edition.reject do |e|
64
+ e.text.strip.empty?
65
+ end.map(&:text).join(' ').strip
66
+ end
67
+
59
68
  private
60
69
 
61
70
  def compact_and_join_with_delimiter(values, delimiter)
@@ -77,12 +86,6 @@ module Stanford
77
86
  value.strip.end_with?('.', ',', ':', ';')
78
87
  end
79
88
 
80
- def edition_vals_str
81
- element.edition.reject do |e|
82
- e.text.strip.empty?
83
- end.map(&:text).join(' ').strip
84
- end
85
-
86
89
  # PLACE processing methods ------
87
90
 
88
91
  def place_vals_str
@@ -169,19 +172,25 @@ module Stanford
169
172
  date.year
170
173
  end
171
174
 
172
- str = if year < 1
173
- (-1 * year - 1000).to_s
175
+ str = if year > 0
176
+ # for CE dates, we can just pad them out to 4 digits and sort normally...
177
+ year.to_s.rjust(4, "0")
174
178
  else
175
- year.to_s
179
+ # ... but for BCE, because we're sorting lexically, we need to invert the digits (replacing 0 with 9, 1 with 8, etc.),
180
+ # we prefix it with a hyphen (which will sort before any digit) and the number of digits (also inverted) to get
181
+ # it to sort correctly.
182
+ inverted_year = year.abs.to_s.chars.map { |c| BCE_CHAR_SORT_MAP[c] }.join
183
+ length_prefix = BCE_CHAR_SORT_MAP[inverted_year.to_s.length.to_s]
184
+ "-#{length_prefix}#{inverted_year}"
176
185
  end
177
186
 
178
187
  case value.precision
179
188
  when :decade
180
- str[0..2] + "-"
189
+ str[0...-1] + "-"
181
190
  when :century
182
- str[0..1] + "--"
191
+ str[0...-2] + "--"
183
192
  else
184
- str.rjust(4, "0")
193
+ str
185
194
  end
186
195
  end
187
196
 
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = '3.3.8'.freeze
4
+ VERSION = '3.3.10'.freeze
5
5
  end
6
6
  end
@@ -383,7 +383,7 @@ describe "computations from /originInfo field" do
383
383
  end
384
384
 
385
385
  it 'returns the earliest date with the funky lexical sort encoding' do
386
- expect(record.pub_year_sort_str).to eq '-751'
386
+ expect(record.pub_year_sort_str).to eq '-6750'
387
387
  end
388
388
  end
389
389
 
@@ -400,7 +400,23 @@ describe "computations from /originInfo field" do
400
400
  end
401
401
 
402
402
  it 'returns the earliest date of the range with the funky lexical sort encoding' do
403
- expect(record.pub_year_sort_str).to eq '-751'
403
+ expect(record.pub_year_sort_str).to eq '-6750'
404
+ end
405
+ end
406
+
407
+ context 'with a really old BCE date (e.g. ky899rv1161)' do
408
+ let(:modsxml) do
409
+ <<-EOF
410
+ <mods xmlns="http://www.loc.gov/mods/v3">
411
+ <originInfo>
412
+ <dateIssued encoding="edtf">Y-12345</dateIssued>
413
+ </originInfo>
414
+ </mods>
415
+ EOF
416
+ end
417
+
418
+ it 'returns the earliest date of the range with the funky lexical sort encoding' do
419
+ expect(record.pub_year_sort_str).to eq '-487654'
404
420
  end
405
421
  end
406
422
 
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.3.8
4
+ version: 3.3.10
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: 2023-11-30 00:00:00.000000000 Z
12
+ date: 2025-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.4.13
217
+ rubygems_version: 3.5.9
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: Stanford specific wrangling of MODS metadata