stanford-mods 3.3.9 → 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 +4 -4
- data/lib/stanford-mods/imprint.rb +14 -6
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/origin_info_spec.rb +18 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb1b017fccf0e3f74a5c0594e5a21a43f7816055b2c67486392af2308ce85860
|
4
|
+
data.tar.gz: b992e7323c4e096d0714d5391a9c4206745c536f99b2fad92fbe9b1affb89645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -170,19 +172,25 @@ module Stanford
|
|
170
172
|
date.year
|
171
173
|
end
|
172
174
|
|
173
|
-
str = if year
|
174
|
-
|
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")
|
175
178
|
else
|
176
|
-
|
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}"
|
177
185
|
end
|
178
186
|
|
179
187
|
case value.precision
|
180
188
|
when :decade
|
181
|
-
str[0
|
189
|
+
str[0...-1] + "-"
|
182
190
|
when :century
|
183
|
-
str[0
|
191
|
+
str[0...-2] + "--"
|
184
192
|
else
|
185
|
-
str
|
193
|
+
str
|
186
194
|
end
|
187
195
|
end
|
188
196
|
|
data/spec/origin_info_spec.rb
CHANGED
@@ -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 '-
|
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 '-
|
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.
|
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:
|
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.
|
217
|
+
rubygems_version: 3.5.9
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Stanford specific wrangling of MODS metadata
|