mods 3.0.0 → 3.0.3

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: 30381fee9ce7d47827010ce02902834f10118daeb381bdfa65bcc5adf778b65f
4
- data.tar.gz: 65b9fac4ebee7589010039dbba9cbd8b204a94987443ec2c68e36a7509f39685
3
+ metadata.gz: f6ac4089b58e673c2783c670e689cb6901bbad611a7271c95f1f8909726beb07
4
+ data.tar.gz: ee1ee35aeae21d319485212f56535e4bc06068470295f5adcf3ff8593a06c9d0
5
5
  SHA512:
6
- metadata.gz: e9ecec0384d8c4d931cace14b32ddc9e2b5161ed6ef9f61af27fb89d9993643db790f98966f8ddea419008bd03588cbc6aaf4dfee25b404c5a392deae1b3e78e
7
- data.tar.gz: 79b733073abbf0ee6dc8da9835c86e44be67f1f298a4e09f3d6380772ff51713cd63c121daf2bb0ae0751ab9ffb3954003eb24ecffde1a7e89ed3c542cead994
6
+ metadata.gz: 553a4d9e91f50357ff56b5e2c19404386852308c30f06f67ccf6baa586f74f3f4bdbfd05826d3225aac8a0793bdccd5049994e5df04ef691a86c7777a21e554c
7
+ data.tar.gz: a496b63bef0f1b512d0e3c87886ee80b6665dd90044387d5ce318cc2471d855fcac64839d7d95e9bca75ca1705d786ee0b6220e254b10d31fa32a79768521d66
data/lib/mods/date.rb CHANGED
@@ -56,6 +56,9 @@ module Mods
56
56
 
57
57
  # Less strict W3CDTF-encoded date parser
58
58
  class W3cdtfFormat < Date
59
+ def self.normalize_to_edtf(text)
60
+ super.gsub('-00', '')
61
+ end
59
62
  end
60
63
 
61
64
  # Strict EDTF parser
@@ -180,7 +183,7 @@ module Mods
180
183
 
181
184
  def self.munge_to_yyyy(text)
182
185
  value = roman_to_int(text.upcase)
183
- (value - 1).to_s.rjust(2, "0") + 'XX'
186
+ (value - 1).to_s.rjust(2, "0") + 'xx'
184
187
  end
185
188
  end
186
189
 
@@ -191,7 +194,7 @@ module Mods
191
194
  REGEX = /(?<century>\d{2})--/
192
195
  def self.normalize_to_edtf(text)
193
196
  matches = text.match(REGEX)
194
- "#{matches[:century]}XX"
197
+ "#{matches[:century]}xx"
195
198
  end
196
199
  end
197
200
 
@@ -201,7 +204,7 @@ module Mods
201
204
 
202
205
  def self.normalize_to_edtf(text)
203
206
  matches = text.match(REGEX)
204
- "#{matches[:century].to_i - 1}XX"
207
+ "#{matches[:century].to_i - 1}xx"
205
208
  end
206
209
  end
207
210
 
@@ -221,7 +224,7 @@ module Mods
221
224
 
222
225
  def self.normalize_to_edtf(text)
223
226
  matches = text.match(REGEX)
224
- "#{matches[:year]}X"
227
+ "#{matches[:year]}x"
225
228
  end
226
229
  end
227
230
 
@@ -231,7 +234,7 @@ module Mods
231
234
 
232
235
  def self.normalize_to_edtf(text)
233
236
  matches = text.match(REGEX)
234
- "#{matches[:year]}X"
237
+ "#{matches[:year]}x"
235
238
  end
236
239
  end
237
240
 
@@ -457,6 +460,10 @@ module Mods
457
460
  :century
458
461
  elsif date_range.is_a? EDTF::Decade
459
462
  :decade
463
+ elsif date.is_a? EDTF::Season
464
+ :month
465
+ elsif date.is_a? EDTF::Interval
466
+ date_range.precision
460
467
  else
461
468
  case date.precision
462
469
  when :month
@@ -492,7 +499,7 @@ module Mods
492
499
  case date_range
493
500
  when EDTF::Unknown
494
501
  nil
495
- when EDTF::Epoch, EDTF::Interval
502
+ when EDTF::Epoch, EDTF::Interval, EDTF::Season
496
503
  date_range.min
497
504
  when EDTF::Set
498
505
  date_range.to_a.first
@@ -517,7 +524,7 @@ module Mods
517
524
  case date_range
518
525
  when EDTF::Unknown
519
526
  nil
520
- when EDTF::Epoch, EDTF::Interval
527
+ when EDTF::Epoch, EDTF::Interval, EDTF::Season
521
528
  date_range.max
522
529
  when EDTF::Set
523
530
  date_range.to_a.last.change(month: 12, day: 31)
@@ -533,7 +540,7 @@ module Mods
533
540
 
534
541
  def date_range
535
542
  @date_range ||= if text =~ /u/
536
- ::Date.edtf(text.gsub('u', 'X')) || date
543
+ ::Date.edtf(text.gsub('u', 'x').gsub('X', 'x')) || date
537
544
  else
538
545
  date
539
546
  end
data/lib/mods/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Mods
2
2
  # this is the Ruby Gem version
3
- VERSION = '3.0.0'.freeze
3
+ VERSION = '3.0.3'.freeze
4
4
  end
@@ -101,6 +101,8 @@ RSpec.describe Mods::Date do
101
101
  '1900-06' => :month,
102
102
  '1900-06-uu' => :month,
103
103
  '1900-06-15' => :day,
104
+ '2014-01-01/2020-12-31' => :day,
105
+ '1986-22' => :month
104
106
  }.each do |data, expected|
105
107
  describe "with #{data}" do
106
108
  let(:date_element) { "<dateCreated encoding=\"edtf\">#{data}</dateCreated>" }
@@ -200,9 +202,9 @@ RSpec.describe Mods::Date do
200
202
  {
201
203
  '1905' => Date.parse('1905-01-01')..Date.parse('1905-12-31'),
202
204
  '190u' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
203
- '190X' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
205
+ '190x' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
204
206
  '19uu' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
205
- '19XX' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
207
+ '19xx' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
206
208
  '1856/1876' => Date.parse('1856-01-01')..Date.parse('1876-12-31'),
207
209
  '[1667,1668,1670..1672]' => Date.parse('1667-01-01')..Date.parse('1672-12-31'),
208
210
  '1900-uu' => Date.parse('1900-01-01')..Date.parse('1900-12-31'),
@@ -229,6 +231,7 @@ RSpec.describe Mods::Date do
229
231
  {
230
232
  '1753' => Date.parse('1753-01-01')..Date.parse('1753-12-31'),
231
233
  '-1753' => Date.parse('-1753-01-01')..Date.parse('-1753-12-31'),
234
+ '1992-00-00' => Date.parse('1992-01-01')..Date.parse('1992-12-31'),
232
235
  '1992-05-06' => Date.parse('1992-05-06')..Date.parse('1992-05-06'),
233
236
  '1992-04' => Date.parse('1992-04-01')..Date.parse('1992-04-30'),
234
237
  '2004-02' => Date.parse('2004-02-01')..Date.parse('2004-02-29'),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.3
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-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri