lutaml-model 0.8.82 → 0.8.83
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/Gemfile +5 -1
- data/lib/lutaml/model/serializable.rb +32 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/plan_hydrator.rb +27 -0
- 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: 4e310af71c7b500226adc361854223a83e397520a48ab69760a80b47fd81b228
|
|
4
|
+
data.tar.gz: 7ad34288dc8429662936509d872e993eac0e76f31ff045f7c232273fd6912a9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 114ba7bf5b76479faca00e3b1a34cf58f9794e00b1ab31270109ca8f97a5a875d63ad1ec5ca1819db8e4f3d2083ff2bbc2b72b9f75c77b3a6800d606e3733615
|
|
7
|
+
data.tar.gz: bc410377e8d4fe638afebabcaf99b4dec94819b0e2414f8b276f3c80946250f39df39fa54f3aecd32ca825841830ed58de71a4f8f70f2a7e8dc8a405eab608e6
|
data/Gemfile
CHANGED
|
@@ -44,7 +44,11 @@ gem "rexml"
|
|
|
44
44
|
# Native engines stay development-only: every adapter detects and
|
|
45
45
|
# degrades gracefully at runtime (safe requires + prefer-if-available).
|
|
46
46
|
# yeptris ships no Windows prebuilt platform gem.
|
|
47
|
-
|
|
47
|
+
# leptris floor: the plan hydrator's one-crossing snapshot
|
|
48
|
+
# (leptris_plan_value_children_snapshot) landed in 1.9.273.0; older
|
|
49
|
+
# gems fall back to accessor enumeration at runtime, but CI and dev
|
|
50
|
+
# resolve the snapshot-capable line.
|
|
51
|
+
gem "leptris", ">= 1.9.273.0"
|
|
48
52
|
gem "teptris"
|
|
49
53
|
gem "yeptris" unless Gem.win_platform?
|
|
50
54
|
# TODO: revert rng branch to main when lutaml/rng#32 is merged
|
|
@@ -8,6 +8,38 @@ module Lutaml
|
|
|
8
8
|
# model classes actually inherit from (lutaml-model#18).
|
|
9
9
|
include Serialize
|
|
10
10
|
extend ComparableModel::ClassMethods
|
|
11
|
+
|
|
12
|
+
# Ivars that must never take part in inspect output: they either
|
|
13
|
+
# walk the whole graph (@lutaml_parent climbs to the root, and
|
|
14
|
+
# parent-child mutual recursion never terminates under the
|
|
15
|
+
# default Object#inspect) or are bulky parse bookkeeping.
|
|
16
|
+
INSPECT_EXCLUDED_IVARS = %i[
|
|
17
|
+
@lutaml_parent @lutaml_root @lutaml_register @using_default
|
|
18
|
+
@element_order @attribute_order @encoding
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
21
|
+
# Bounded, Struct-like inspect: scalars by value, collections by
|
|
22
|
+
# size, child models by class name. The default Object#inspect
|
|
23
|
+
# recurses through @lutaml_parent and re-enters children forever
|
|
24
|
+
# on real parsed documents.
|
|
25
|
+
def inspect
|
|
26
|
+
parts = (instance_variables - INSPECT_EXCLUDED_IVARS).map do |iv|
|
|
27
|
+
"#{iv}=#{self.class.inspect_value(instance_variable_get(iv))}"
|
|
28
|
+
end
|
|
29
|
+
"#<#{self.class.name}#{' ' + parts.join(', ') unless parts.empty?}>"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class << self
|
|
33
|
+
def inspect_value(value)
|
|
34
|
+
case value
|
|
35
|
+
when nil, true, false, Numeric, Symbol then value.inspect
|
|
36
|
+
when String then value.inspect.length > 48 ? "#{value.inspect[0, 45]}...".inspect : value.inspect
|
|
37
|
+
when Array then "(#{value.size} items)"
|
|
38
|
+
when Hash then "{#{value.size} keys}"
|
|
39
|
+
else "##{value.class.name}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
11
43
|
end
|
|
12
44
|
end
|
|
13
45
|
end
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -398,7 +398,34 @@ module Lutaml
|
|
|
398
398
|
nil
|
|
399
399
|
end
|
|
400
400
|
|
|
401
|
+
# Capability probe, not duck-typing: the snapshot landed in
|
|
402
|
+
# leptris 1.9.273.0; bundles still resolving an older gem
|
|
403
|
+
# (lockfiles, prefer-if-available resolution) must keep the
|
|
404
|
+
# accessor enumeration instead of NoMethodError-ing every
|
|
405
|
+
# XML parse (the 0.8.82 regression).
|
|
406
|
+
SNAPSHOT_CAPABLE =
|
|
407
|
+
Leptris::XML::PlanValue.method_defined?(:children_snapshot)
|
|
408
|
+
|
|
401
409
|
def group_children(value, row_tags = nil)
|
|
410
|
+
return group_children_snapshot(value, row_tags) if SNAPSHOT_CAPABLE
|
|
411
|
+
|
|
412
|
+
grouped = {}
|
|
413
|
+
want_tags = !row_tags.nil?
|
|
414
|
+
tagged = want_tags ? {} : nil
|
|
415
|
+
value.count.times do |i|
|
|
416
|
+
child = value.at(i)
|
|
417
|
+
name = child.name
|
|
418
|
+
next if name.nil? # content runs, read separately
|
|
419
|
+
|
|
420
|
+
(grouped[name] ||= []) << child
|
|
421
|
+
if want_tags && child.type_tag != 0
|
|
422
|
+
(tagged[child.type_tag] ||= []) << child
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
[grouped, tagged]
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def group_children_snapshot(value, row_tags)
|
|
402
429
|
# One crossing per subtree: names/tags/children come back in
|
|
403
430
|
# parallel arrays from leptris_plan_value_children_snapshot.
|
|
404
431
|
names, tags, children = value.children_snapshot
|