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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3c3cdc0b150a034d2c96f2fa7cebc3678bee7083cd99cf84e8d3f4990e5b938
4
- data.tar.gz: 43c2fd5b0675e6bf1387fa84e844f5d5ff8f6b2869c1704b1f64c742e874de49
3
+ metadata.gz: 66d60e36543915798799cd4fabcb09a4dbed2431a821868e1378bcd31dc0f3ae
4
+ data.tar.gz: ab348fe88082f60ec86aee6a3fc42524bbbe038752070eb68f451757523b11fd
5
5
  SHA512:
6
- metadata.gz: 16c1f176a92304b36c26b36ab083a7f9d59cc00124ba7a44a276f6cb843c6666d32b303ebcaf0544173766446bdaf3ff95d78db89b953a37e3ccd5814473ac8a
7
- data.tar.gz: 5181fb2df1d2b1d0103b9d2e455ed04be1e539c78fcad15c473fed0d1de93ec9a7b80cf533504a712befdedfb4ce80241b6d077519c8261bef195baab5f0c0f6
6
+ metadata.gz: 666e8519e41f8fef01e75a7ab8fdffeb062366c16f982147e6fe68cc052f7c4b99864c8b6f6ab6821a8c5ac76a51d571403d884cfe0e0eb13693048e6f109c2e
7
+ data.tar.gz: 41615b507c3e7386e689af5c5dd25c885c71dc93762c49f61850030ed38d861b538bac5ad554ce9b6d70475aa112efcce725bacddf9dd717db45576c752f8f7e
@@ -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.to_s && declared_attribute?(flat_key)
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).to_s
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.to_s] = value.map { |v| { field => v.to_s } }
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.to_s] = { field => value.to_s }
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
- key = attrs.key?(alias_name) ? alias_name : alias_name.to_s
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?(alias_name.to_s)
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
- existing = attrs[target] || attrs[target.to_s] || {}
279
+ target_str = target.name
280
+ existing = attrs[target] || attrs[target_str] || {}
279
281
  existing = component_to_hash(existing)
280
- attrs.delete(target.to_s)
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.to_s
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
- parts = name.split("::")
781
- flavor = parts[1]&.downcase
782
- type_kebab = parts.last
783
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1-\2')
784
- .gsub(/([a-z\d])([A-Z])/, '\1-\2')
785
- .downcase
786
- "pubid:#{flavor}:#{type_kebab}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pubid
4
- VERSION = "2.0.0.pre.alpha.21"
4
+ VERSION = "2.0.0.pre.alpha.22"
5
5
  end
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.21
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-02 00:00:00.000000000 Z
11
+ date: 2026-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model