relaton 3.1.15 → 3.1.16
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/relaton/bib/model/type/plain_date.rb +25 -4
- data/lib/relaton/core/processor.rb +7 -2
- data/lib/relaton/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b7286c99d15f19823983e5965873648750e480124f4d72e97a58ca511bd2068
|
|
4
|
+
data.tar.gz: dc9148ea2bc0c47f14828183bb6c11b7fc8c4a44fc664e005d4ae6683a364a6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e84b0544a255c1dd857aaaf1a10632b9fbaa1d2e15e5d7c44dbaf0d696f96320c0b00356d9cc823f2579dbb2d82a8331eaba4262e0346d52b06ad2333b18a264
|
|
7
|
+
data.tar.gz: f240a5bf6b24a6679cd9407634e2590b6717fc5e42a2675214fb1631785f464b7b3e18976f4f20f65bf2436eeb64e836037866c5759cc8866a19305006413f1c
|
|
@@ -2,15 +2,36 @@ require "date"
|
|
|
2
2
|
|
|
3
3
|
module Relaton
|
|
4
4
|
module Bib
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
5
|
+
# Value type for validity-class dates that preserves the precision of
|
|
6
|
+
# the input: date-only input serializes as xs:date, input carrying a
|
|
7
|
+
# time serializes as ISO 8601 dateTime ("2010-10-10T12:21:00Z"). The
|
|
8
|
+
# bibdata schema requires dateTime whenever a time is present, so
|
|
9
|
+
# truncating to ::Date silently loses bibitem validity times
|
|
10
|
+
# (relaton#636; the truncating cast shipped in cf535198 for the Bipm
|
|
11
|
+
# static-file round-trip, whose date-only fixtures are unaffected).
|
|
9
12
|
class PlainDate < Lutaml::Model::Type::Date
|
|
10
13
|
def self.cast(value, options = {})
|
|
14
|
+
# String with a time component: parse as ::DateTime, keeping
|
|
15
|
+
# offset and precision (lutaml's Date cast truncates these).
|
|
16
|
+
return ::DateTime.parse(value) if value.is_a?(String) && value =~ /T\d{2}:\d{2}/
|
|
17
|
+
# ::DateTime objects already carry the caller's precision.
|
|
18
|
+
return value if value.is_a?(::DateTime)
|
|
19
|
+
# A string without a time component ("2018-04-15+05:30") is
|
|
20
|
+
# date-only regardless of its zone offset: keep xs:date.
|
|
11
21
|
result = super
|
|
12
22
|
result.is_a?(::DateTime) ? result.to_date : result
|
|
13
23
|
end
|
|
24
|
+
|
|
25
|
+
def self.serialize(value, options = {})
|
|
26
|
+
case value
|
|
27
|
+
when ::DateTime
|
|
28
|
+
value.offset.zero? ? value.strftime("%FT%TZ") : value.xmlschema
|
|
29
|
+
when ::Date
|
|
30
|
+
value.iso8601
|
|
31
|
+
else
|
|
32
|
+
super
|
|
33
|
+
end
|
|
34
|
+
end
|
|
14
35
|
end
|
|
15
36
|
end
|
|
16
37
|
end
|
|
@@ -97,7 +97,12 @@ module Relaton
|
|
|
97
97
|
hit = @pubid_memo[key]
|
|
98
98
|
@pubid_memo.key?(key)
|
|
99
99
|
end
|
|
100
|
-
|
|
100
|
+
# Copy on handout (relaton#636): the memo stores one parse per
|
|
101
|
+
# [class, reference], and callers may mutate the identifier
|
|
102
|
+
# they receive (validity, extent, typed_stage). Handing out
|
|
103
|
+
# the memoized instance let one caller's mutation poison
|
|
104
|
+
# every later hit of the same reference.
|
|
105
|
+
return hit.dup if present
|
|
101
106
|
|
|
102
107
|
parsed =
|
|
103
108
|
begin
|
|
@@ -114,7 +119,7 @@ require_relative "../bib"
|
|
|
114
119
|
@pubid_memo.shift while @pubid_memo.size >= MEMO_LIMIT
|
|
115
120
|
@pubid_memo[key] = parsed
|
|
116
121
|
end
|
|
117
|
-
parsed
|
|
122
|
+
parsed&.dup
|
|
118
123
|
end
|
|
119
124
|
end
|
|
120
125
|
|
data/lib/relaton/version.rb
CHANGED