stanford-mods 3.3.4 → 3.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fa228dc93f0f24e8f5c5b9b96106761ef03fcb2ad25fe2c9083fb6d1025a1a5
4
- data.tar.gz: eb507bdb0c5d07dc0b2d6aa6f5b4132d54f5d1fbeac528a91eb5ea2c97c3ad17
3
+ metadata.gz: 7028a87a57f12536c2d9aad2271ce920e738a11edd16fe1403d9958476a8c5e3
4
+ data.tar.gz: f4f6bcd19a21be08ac71f5bf09dc703957deea569f9479b1df5564540c97aad9
5
5
  SHA512:
6
- metadata.gz: b6bd720575deaefb97c80bacbddde3a2c9e6b8d48c469575ec22a04dbbf5f1ec6fc18c48951a4ff45619ed6c305608c4e954bc4d07b87201d825ae13c4dee7ce
7
- data.tar.gz: ce40138bb0489021788b64f08fc689bd23ce7c376fde6f8b9a5d897b57a3c7205c023e5b09834495ec9557a75f1efab68a484cae30df0140be074d6097bbf432
6
+ metadata.gz: 15e15c55737607e91482c2898bed91e41e659a6c809c5652183be561dd5ea0a2de576538a793be156d8eae4458c82b4950b1eaf64ed4c7b5fe61d721df3a5f1a
7
+ data.tar.gz: 22e36b2e62be2db59fbe576c7177b7460ed021656b17769f7175bf847b405763ee8e7c3f603d3c6f818a0c37d6c7cc05cf876f0138acecb36bf5c4f296afecf2
@@ -142,9 +142,9 @@ module Stanford
142
142
  @value = value
143
143
  end
144
144
 
145
- # True if the element text isn't blank or the placeholder "9999".
146
- def valid?
147
- text.present? && !['9999', '0000-00-00', 'uuuu'].include?(text.strip)
145
+ # True if the element text isn't blank or one of a set of unparseable values.
146
+ def parseable?
147
+ text.present? && !['9999', '0000-00-00', 'uuuu', '[uuuu]'].include?(text.strip)
148
148
  end
149
149
 
150
150
  def key_date?
@@ -160,6 +160,8 @@ module Stanford
160
160
  end
161
161
 
162
162
  def sort_key
163
+ return unless date
164
+
163
165
  year = if date.is_a?(EDTF::Interval)
164
166
  date.from.year
165
167
  else
@@ -339,7 +341,7 @@ module Stanford
339
341
 
340
342
  def parse_dates(elements)
341
343
  # convert to DateValue objects and keep only valid ones
342
- dates = elements.map(&:as_object).flatten.map { |element| DateValue.new(element) }.select(&:valid?)
344
+ dates = elements.map(&:as_object).flatten.map { |element| DateValue.new(element) }.select(&:parseable?)
343
345
 
344
346
  # join any date ranges into DateRange objects
345
347
  point_dates, dates = dates.partition(&:point)
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = '3.3.4'.freeze
4
+ VERSION = '3.3.6'.freeze
5
5
  end
6
6
  end
data/lib/stanford-mods.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext/integer/inflections'
3
+ require 'active_support/core_ext/object/blank'
3
4
  require 'mods'
4
5
  require 'stanford-mods/coordinate'
5
6
  require 'stanford-mods/imprint'
data/spec/imprint_spec.rb CHANGED
@@ -20,6 +20,9 @@ describe Stanford::Mods::Imprint do
20
20
  <dateIssued>
21
21
  uuuu
22
22
  </dateIssued>
23
+ <dateIssued>
24
+ [uuuu]
25
+ </dateIssued>
23
26
  <dateIssued>
24
27
  0000-00-00
25
28
  </dateIssued>' +
@@ -442,6 +442,22 @@ describe "computations from /originInfo field" do
442
442
  end
443
443
  end
444
444
 
445
+ context 'with a date not handled by EDTF' do
446
+ let(:modsxml) do
447
+ <<-EOF
448
+ <mods xmlns="http://www.loc.gov/mods/v3">
449
+ <originInfo>
450
+ <dateIssued encoding="marc">1uuu</dateIssued>
451
+ </originInfo>
452
+ </mods>
453
+ EOF
454
+ end
455
+
456
+ it 'ignores the date' do
457
+ expect(record.pub_year_sort_str).to eq nil
458
+ end
459
+ end
460
+
445
461
  context 'when it has an open-ended date range' do
446
462
  let(:modsxml) do
447
463
  <<-EOF
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
4
+ version: 3.3.6
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-09-29 00:00:00.000000000 Z
12
+ date: 2023-10-09 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.3.7
217
+ rubygems_version: 3.4.14
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: Stanford specific wrangling of MODS metadata