lutaml-model 0.8.139 → 0.8.140

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: a027b25146b1db5759062241ef72d4e6cfb7122f4dff800d5683535bf4767c5b
4
- data.tar.gz: 2b49a35df1f800d47d18b2e79737fe58fccc79385a2f38e5e5c9169acae84063
3
+ metadata.gz: e4340bd1bf4b75d088acb5a60a68073d2980d419fe5c7f59412966956a58e377
4
+ data.tar.gz: 829a741bc56fa070059d8198887cc51051859f64a2aeab747814c5f0d278356b
5
5
  SHA512:
6
- metadata.gz: e66ba7f1fff3188bbe477aa108681b53cfbacaec36f7dfd652a54c6305f083a28fc4992e6586312fc22da9bded0864f5336f848538b755a315f8c4fbdde3d427
7
- data.tar.gz: 8f1039a43171dea42d3bf5f3db295ae4bc44e15d087fc531a9910515d307634410d3a6b102adfff2b5ee30764ff0e19dbefdeb9e1c84618332981bc95f4c67ab
6
+ metadata.gz: 14cda9bfd53830559db4848694f3118289958108e17f9445a079c585c8aed5f637878d4b1a0b4f232f1dca8d12100f4d56d73bb8289d2e73cd625a42682c90df
7
+ data.tar.gz: 124577fb5f037a6dea46e3da4f409713fadcc2ca2398e34a578d47230be5651274d3eabac7342fc708b2939c59d56f4248bfe97da88cc39dddce509cdffc83ef
@@ -374,9 +374,6 @@ module Lutaml
374
374
  # compiled seed cannot know about (SchemaRepository's
375
375
  # @parsed_schemas/@namespace_registry/@type_index): construct
376
376
  # through the real constructor for them, exactly as the walk
377
- # did before the compiled seed existed. The seed stays the
378
- # fast path for classes using the standard initializer.
379
- return new(lutaml_register: register) if constructs_through_initialize?
380
377
  # did before the compiled seed existed, register included. The
381
378
  # seed stays the fast path for classes using the standard
382
379
  # initializer.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.139"
5
+ VERSION = "0.8.140"
6
6
  end
7
7
  end
@@ -1556,6 +1556,7 @@ module Lutaml
1556
1556
  @attributes
1557
1557
  @elements
1558
1558
  @processing_instruction_mappings
1559
+ @all_attributes_rule
1559
1560
  @register_elements
1560
1561
  @register_attributes
1561
1562
  @register_element_sequences
@@ -511,9 +511,11 @@ module Lutaml
511
511
  end
512
512
 
513
513
  # #1031: wildcard attribute families. After the explicit attribute
514
- # rules have consumed their names, every remaining unprefixed
515
- # attribute matching the rule's pattern lands in the target Hash —
516
- # names claimed by explicit rules never leak into it.
514
+ # rules have consumed their names, every remaining attribute
515
+ # matching the rule's pattern lands in the target Hash — names
516
+ # claimed by explicit rules never leak into it. The key is the name
517
+ # as written, prefix included: keyed by its local name, xlink:href
518
+ # would serialize back as a plain href attribute.
517
519
  def apply_all_attributes_deserialization(doc, instance, xml_mapping)
518
520
  rule = xml_mapping.all_attributes_rule
519
521
  return if rule.nil?
@@ -524,8 +526,9 @@ module Lutaml
524
526
  claimed = attribute_names_claimed_by_rules(xml_mapping)
525
527
  remainder = {}
526
528
  element.attributes.each_value do |attr|
527
- name = attr.unprefixed_name.to_s
528
- next if claimed.include?(name)
529
+ next if claimed.include?(attr.unprefixed_name.to_s)
530
+
531
+ name = attr.name.to_s
529
532
  next if rule.matching && !rule.matching.match?(name)
530
533
 
531
534
  remainder[name] = attr.value
@@ -86,4 +86,35 @@ RSpec.describe "map_all_attributes" do
86
86
 
87
87
  expect(model.other_attributes).to eq("zeta" => "1")
88
88
  end
89
+
90
+ it "keeps a prefixed attribute's prefix through a round-trip" do
91
+ xml = '<mn xmlns:xlink="http://www.w3.org/1999/xlink" name="x" ' \
92
+ 'data-title="T" xlink:href="#t"/>'
93
+ klass = Class.new(Lutaml::Model::Serializable) do
94
+ attribute :name, :string
95
+ attribute :other_attributes, :hash
96
+
97
+ xml do
98
+ element "mn"
99
+ map_attribute "name", to: :name
100
+ map_all_attributes to: :other_attributes
101
+ end
102
+ end
103
+ stub_const("MapAllPrefixedModel", klass)
104
+
105
+ model = klass.from_xml(xml)
106
+
107
+ expect(model.other_attributes).to eq("data-title" => "T", "xlink:href" => "#t")
108
+ expect(model.to_xml).to include('xlink:href="#t"')
109
+ expect(model.to_xml).not_to include(' href="#t"')
110
+ end
111
+
112
+ it "is inherited by a subclass along with the other mappings" do
113
+ stub_const("MapAllAttributesChild", Class.new(stubbed))
114
+
115
+ model = MapAllAttributesChild.from_xml('<mn name="x" data-title="T"/>')
116
+
117
+ expect(model.data_attributes).to eq("data-title" => "T")
118
+ expect(model.to_xml).to include('data-title="T"')
119
+ end
89
120
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.139
4
+ version: 0.8.140
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.