pubid 2.0.0.pre.alpha.21 → 2.0.0.pre.alpha.22
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/pubid/identifier.rb +25 -16
- data/lib/pubid/version.rb +1 -1
- 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: 66d60e36543915798799cd4fabcb09a4dbed2431a821868e1378bcd31dc0f3ae
|
|
4
|
+
data.tar.gz: ab348fe88082f60ec86aee6a3fc42524bbbe038752070eb68f451757523b11fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 666e8519e41f8fef01e75a7ab8fdffeb062366c16f982147e6fe68cc052f7c4b99864c8b6f6ab6821a8c5ac76a51d571403d884cfe0e0eb13693048e6f109c2e
|
|
7
|
+
data.tar.gz: 41615b507c3e7386e689af5c5dd25c885c71dc93762c49f61850030ed38d861b538bac5ad554ce9b6d70475aa112efcce725bacddf9dd717db45576c752f8f7e
|
data/lib/pubid/identifier.rb
CHANGED
|
@@ -158,13 +158,13 @@ module Pubid
|
|
|
158
158
|
# the year on every round trip — the same collision
|
|
159
159
|
# `fold_scalar_aliases` guards against on the constructor path.
|
|
160
160
|
# `edition` keeps its own name, so it is never a collision.
|
|
161
|
-
return if flat_key != attr_name.
|
|
161
|
+
return if flat_key != attr_name.name && declared_attribute?(flat_key)
|
|
162
162
|
|
|
163
163
|
key = data.key?(flat_key) ? flat_key : flat_key.to_sym
|
|
164
164
|
value = data[key]
|
|
165
165
|
return if value.nil? || value.is_a?(::Hash)
|
|
166
166
|
|
|
167
|
-
field = flat_scalar_fields.fetch(attr_name).
|
|
167
|
+
field = flat_scalar_fields.fetch(attr_name).name
|
|
168
168
|
if value.is_a?(::Array)
|
|
169
169
|
# A collection of components (`copublishers`) flattens to a list of
|
|
170
170
|
# scalars; anything else in a list is not the flat form.
|
|
@@ -172,12 +172,12 @@ module Pubid
|
|
|
172
172
|
return unless value.all? { |v| scalar_value?(v) }
|
|
173
173
|
|
|
174
174
|
data.delete(key)
|
|
175
|
-
data[attr_name.
|
|
175
|
+
data[attr_name.name] = value.map { |v| { field => v.to_s } }
|
|
176
176
|
return
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
data.delete(key)
|
|
180
|
-
data[attr_name.
|
|
180
|
+
data[attr_name.name] = { field => value.to_s }
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
# True when +name+ is declared as a collection on this class.
|
|
@@ -267,17 +267,19 @@ module Pubid
|
|
|
267
267
|
# edition as a plain `year` attribute, and folding there would destroy it.
|
|
268
268
|
def fold_scalar_aliases(attrs)
|
|
269
269
|
SCALAR_ATTRIBUTE_ALIASES.each do |alias_name, (target, field)|
|
|
270
|
-
|
|
270
|
+
alias_str = alias_name.name
|
|
271
|
+
key = attrs.key?(alias_name) ? alias_name : alias_str
|
|
271
272
|
next unless attrs.key?(key)
|
|
272
|
-
next if attributes.key?(alias_name) || attributes.key?(
|
|
273
|
+
next if attributes.key?(alias_name) || attributes.key?(alias_str)
|
|
273
274
|
next unless component_attribute?(target)
|
|
274
275
|
|
|
275
276
|
value = attrs.delete(key)
|
|
276
277
|
next if value.nil?
|
|
277
278
|
|
|
278
|
-
|
|
279
|
+
target_str = target.name
|
|
280
|
+
existing = attrs[target] || attrs[target_str] || {}
|
|
279
281
|
existing = component_to_hash(existing)
|
|
280
|
-
attrs.delete(
|
|
282
|
+
attrs.delete(target_str)
|
|
281
283
|
attrs[target] = existing.merge(field => value.to_s)
|
|
282
284
|
end
|
|
283
285
|
end
|
|
@@ -286,7 +288,7 @@ module Pubid
|
|
|
286
288
|
# declares the attribute as a plain :string keeps the scalar untouched.
|
|
287
289
|
def coerce_component_scalars(attrs)
|
|
288
290
|
FLAT_SCALAR_FIELDS.each do |attr_name, field|
|
|
289
|
-
key = attrs.key?(attr_name) ? attr_name : attr_name.
|
|
291
|
+
key = attrs.key?(attr_name) ? attr_name : attr_name.name
|
|
290
292
|
next unless attrs.key?(key)
|
|
291
293
|
next unless component_attribute?(attr_name)
|
|
292
294
|
|
|
@@ -774,16 +776,23 @@ module Pubid
|
|
|
774
776
|
super
|
|
775
777
|
end
|
|
776
778
|
|
|
779
|
+
# Pure function of the class name; relaton resolves it per registry
|
|
780
|
+
# lookup and per cache-key build, so the kebab-case rebuild (two gsub
|
|
781
|
+
# passes + interpolations) ran on every call — a top string
|
|
782
|
+
# allocation site in metanorma's bibliography phase. Singleton ivars
|
|
783
|
+
# are not inherited, so each concrete class memoizes its own.
|
|
777
784
|
def self.polymorphic_name
|
|
778
785
|
return nil unless name
|
|
779
786
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
.
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
+
@pubid_polymorphic_name ||= begin
|
|
788
|
+
parts = name.split("::")
|
|
789
|
+
flavor = parts[1]&.downcase
|
|
790
|
+
type_kebab = parts.last
|
|
791
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1-\2')
|
|
792
|
+
.gsub(/([a-z\d])([A-Z])/, '\1-\2')
|
|
793
|
+
.downcase
|
|
794
|
+
"pubid:#{flavor}:#{type_kebab}"
|
|
795
|
+
end
|
|
787
796
|
end
|
|
788
797
|
|
|
789
798
|
def root
|
data/lib/pubid/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.pre.alpha.
|
|
4
|
+
version: 2.0.0.pre.alpha.22
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|