mods 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mods/date.rb +10 -8
- data/lib/mods/version.rb +1 -1
- data/spec/lib/date_spec.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ac4089b58e673c2783c670e689cb6901bbad611a7271c95f1f8909726beb07
|
4
|
+
data.tar.gz: ee1ee35aeae21d319485212f56535e4bc06068470295f5adcf3ff8593a06c9d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 553a4d9e91f50357ff56b5e2c19404386852308c30f06f67ccf6baa586f74f3f4bdbfd05826d3225aac8a0793bdccd5049994e5df04ef691a86c7777a21e554c
|
7
|
+
data.tar.gz: a496b63bef0f1b512d0e3c87886ee80b6665dd90044387d5ce318cc2471d855fcac64839d7d95e9bca75ca1705d786ee0b6220e254b10d31fa32a79768521d66
|
data/lib/mods/date.rb
CHANGED
@@ -183,7 +183,7 @@ module Mods
|
|
183
183
|
|
184
184
|
def self.munge_to_yyyy(text)
|
185
185
|
value = roman_to_int(text.upcase)
|
186
|
-
(value - 1).to_s.rjust(2, "0") + '
|
186
|
+
(value - 1).to_s.rjust(2, "0") + 'xx'
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
@@ -194,7 +194,7 @@ module Mods
|
|
194
194
|
REGEX = /(?<century>\d{2})--/
|
195
195
|
def self.normalize_to_edtf(text)
|
196
196
|
matches = text.match(REGEX)
|
197
|
-
"#{matches[:century]}
|
197
|
+
"#{matches[:century]}xx"
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
@@ -204,7 +204,7 @@ module Mods
|
|
204
204
|
|
205
205
|
def self.normalize_to_edtf(text)
|
206
206
|
matches = text.match(REGEX)
|
207
|
-
"#{matches[:century].to_i - 1}
|
207
|
+
"#{matches[:century].to_i - 1}xx"
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -224,7 +224,7 @@ module Mods
|
|
224
224
|
|
225
225
|
def self.normalize_to_edtf(text)
|
226
226
|
matches = text.match(REGEX)
|
227
|
-
"#{matches[:year]}
|
227
|
+
"#{matches[:year]}x"
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -234,7 +234,7 @@ module Mods
|
|
234
234
|
|
235
235
|
def self.normalize_to_edtf(text)
|
236
236
|
matches = text.match(REGEX)
|
237
|
-
"#{matches[:year]}
|
237
|
+
"#{matches[:year]}x"
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
@@ -460,6 +460,8 @@ module Mods
|
|
460
460
|
:century
|
461
461
|
elsif date_range.is_a? EDTF::Decade
|
462
462
|
:decade
|
463
|
+
elsif date.is_a? EDTF::Season
|
464
|
+
:month
|
463
465
|
elsif date.is_a? EDTF::Interval
|
464
466
|
date_range.precision
|
465
467
|
else
|
@@ -497,7 +499,7 @@ module Mods
|
|
497
499
|
case date_range
|
498
500
|
when EDTF::Unknown
|
499
501
|
nil
|
500
|
-
when EDTF::Epoch, EDTF::Interval
|
502
|
+
when EDTF::Epoch, EDTF::Interval, EDTF::Season
|
501
503
|
date_range.min
|
502
504
|
when EDTF::Set
|
503
505
|
date_range.to_a.first
|
@@ -522,7 +524,7 @@ module Mods
|
|
522
524
|
case date_range
|
523
525
|
when EDTF::Unknown
|
524
526
|
nil
|
525
|
-
when EDTF::Epoch, EDTF::Interval
|
527
|
+
when EDTF::Epoch, EDTF::Interval, EDTF::Season
|
526
528
|
date_range.max
|
527
529
|
when EDTF::Set
|
528
530
|
date_range.to_a.last.change(month: 12, day: 31)
|
@@ -538,7 +540,7 @@ module Mods
|
|
538
540
|
|
539
541
|
def date_range
|
540
542
|
@date_range ||= if text =~ /u/
|
541
|
-
::Date.edtf(text.gsub('u', 'X')) || date
|
543
|
+
::Date.edtf(text.gsub('u', 'x').gsub('X', 'x')) || date
|
542
544
|
else
|
543
545
|
date
|
544
546
|
end
|
data/lib/mods/version.rb
CHANGED
data/spec/lib/date_spec.rb
CHANGED
@@ -101,7 +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
|
104
|
+
'2014-01-01/2020-12-31' => :day,
|
105
|
+
'1986-22' => :month
|
105
106
|
}.each do |data, expected|
|
106
107
|
describe "with #{data}" do
|
107
108
|
let(:date_element) { "<dateCreated encoding=\"edtf\">#{data}</dateCreated>" }
|
@@ -201,9 +202,9 @@ RSpec.describe Mods::Date do
|
|
201
202
|
{
|
202
203
|
'1905' => Date.parse('1905-01-01')..Date.parse('1905-12-31'),
|
203
204
|
'190u' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
|
204
|
-
'
|
205
|
+
'190x' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
|
205
206
|
'19uu' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
|
206
|
-
'
|
207
|
+
'19xx' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
|
207
208
|
'1856/1876' => Date.parse('1856-01-01')..Date.parse('1876-12-31'),
|
208
209
|
'[1667,1668,1670..1672]' => Date.parse('1667-01-01')..Date.parse('1672-12-31'),
|
209
210
|
'1900-uu' => Date.parse('1900-01-01')..Date.parse('1900-12-31'),
|
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.
|
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-
|
12
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|