lutaml-model 0.8.128 → 0.8.129

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: d822754e3a7baeb6edb87dcfa7fb61c90c5da8b44920b2ad612905cb8ee9a278
4
- data.tar.gz: ef8bcf9d531357fcd8d3fd07fc5053015c1b0e6202530866adf01f7e932123de
3
+ metadata.gz: 6903f41ec929cb64ce2450b6979f832e0a832f8afbbe82a134af3db157d2fdd8
4
+ data.tar.gz: 3d2f61efc2e609ade7d440994d318c1b190255c243f33ec96538de2a4cda5774
5
5
  SHA512:
6
- metadata.gz: 9c4c5d63a666d0b8b99279de9dcf7fbee3031b694abba3729636249f701a4f67388507c13c778318f61d22ac1ce9a21940bf35960299e2a569fb024e302e3560
7
- data.tar.gz: 7eb201762de275df248d27f7fc7c5e1019cd65e63822059b7075a69aae661d8a18f8123522797155665d8688d8147a6e06d46fdffde8fbc35e9f4347bd8424b9
6
+ metadata.gz: 7f82b33a1e8ac555aa6c756007da45a99dc3e506fd58c1f780446c112397314b3a76b0978566dc3c3279651e76701f0537b87dd1c700accaeb77f789497e20dc
7
+ data.tar.gz: 1100e41da62097636496a5fe31d1ac6a77f55ac491a8a3313eb96dfa4ceda55c52ba92166eda902f07bceae1ace17fd2224c2190c9b9792c5ca76ff4ce29293f
@@ -71,9 +71,10 @@ module Lutaml
71
71
  end
72
72
 
73
73
  def as_models(schema, options: {})
74
- unless Config.xml_adapter.name.end_with?("NokogiriAdapter")
75
- raise Error, XML_ADAPTER_NOT_SET_MESSAGE
76
- end
74
+ # The schema builder resolves its own DOM builder from the
75
+ # configured adapter type (falling back to nokogiri); a stale
76
+ # adapter-class name check here rejected every caller after
77
+ # Config.xml_adapter became symbol-based (#251).
77
78
 
78
79
  parsed_schema = Lutaml::Xml::Schema::Xsd.parse(
79
80
  schema, location: options[:location]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.128"
5
+ VERSION = "0.8.129"
6
6
  end
7
7
  end
@@ -18,6 +18,7 @@ module Lutaml
18
18
  map_attribute :id, to: :id
19
19
  map_attribute :itemType, to: :item_type
20
20
  map_element :annotation, to: :annotation
21
+ map_element :simpleType, to: :simple_type
21
22
  end
22
23
 
23
24
  Lutaml::Xml::Schema::Xsd.register_model(self, :list)
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "lutaml/model/schema"
5
+ require "tmpdir"
6
+
7
+ # Runtime XSD-to-classes compilation (#251): Schema.from_xml compiles a
8
+ # schema into generated Serializable classes, and with load_classes: the
9
+ # classes are available in-process for direct parsing and serialization —
10
+ # no generated files on disk.
11
+ RSpec.describe "runtime XSD class loading" do
12
+ let(:xsd) do
13
+ <<~XSD
14
+ <?xml version="1.0" encoding="UTF-8"?>
15
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
16
+ <xs:complexType name="EntryType">
17
+ <xs:sequence>
18
+ <xs:element name="name" type="xs:string"/>
19
+ <xs:element name="year" type="xs:integer"/>
20
+ </xs:sequence>
21
+ <xs:attribute name="id" type="xs:string" use="required"/>
22
+ </xs:complexType>
23
+ <xs:element name="entry" type="EntryType"/>
24
+ </xs:schema>
25
+ XSD
26
+ end
27
+
28
+ let(:instance_xml) do
29
+ <<~XML
30
+ <entry id="e1"><name>Alpha</name><year>2024</year></entry>
31
+ XML
32
+ end
33
+
34
+ it "compiles a schema, loads the classes, and round-trips an instance" do
35
+ Dir.mktmpdir do |dir|
36
+ Lutaml::Model::Schema.from_xml(
37
+ xsd, output_dir: File.join(dir, "runtime_pilot_models"),
38
+ load_classes: true
39
+ )
40
+
41
+ doc = RuntimePilotModels::EntryType.from_xml(instance_xml)
42
+
43
+ expect(doc.name).to eq("Alpha")
44
+ expect(doc.year).to eq(2024)
45
+ expect(doc.id).to eq("e1")
46
+
47
+ expect(doc.to_xml).to include("<name>Alpha</name>")
48
+ expect(doc.to_xml).to include("<year>2024</year>")
49
+ expect(doc.to_xml).to include('id="e1"')
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "spec_helper"
4
+
5
+ RSpec.describe "xs:list nested simpleType mapping" do
6
+ it "maps the inline simpleType of a list from the parsed XSD" do
7
+ xsd = <<~XSD
8
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
9
+ <xs:element name="r">
10
+ <xs:simpleType>
11
+ <xs:list>
12
+ <xs:simpleType>
13
+ <xs:restriction base="xs:string">
14
+ <xs:enumeration value="a"/>
15
+ </xs:restriction>
16
+ </xs:simpleType>
17
+ </xs:list>
18
+ </xs:simpleType>
19
+ </xs:element>
20
+ </xs:schema>
21
+ XSD
22
+
23
+ schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
24
+ list = schema.element.first.simple_type.list
25
+
26
+ expect(list.simple_type).to be_a(Lutaml::Xml::Schema::Xsd::SimpleType)
27
+ values = Array(list.simple_type.restriction.enumeration).map(&:value)
28
+ expect(values).to eq(["a"])
29
+ end
30
+ 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.128
4
+ version: 0.8.129
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -1837,6 +1837,7 @@ files:
1837
1837
  - spec/lutaml/model/schema/renderers/namespace_spec.rb
1838
1838
  - spec/lutaml/model/schema/renderers/restricted_type_spec.rb
1839
1839
  - spec/lutaml/model/schema/renderers/union_spec.rb
1840
+ - spec/lutaml/model/schema/xml_compiler_runtime_spec.rb
1840
1841
  - spec/lutaml/model/schema/xsd_schema_spec.rb
1841
1842
  - spec/lutaml/model/schema/yaml_schema_spec.rb
1842
1843
  - spec/lutaml/model/sequence_choice_compositor_spec.rb
@@ -2054,6 +2055,7 @@ files:
2054
2055
  - spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb
2055
2056
  - spec/lutaml/xml/schema/xsd/liquid_methods/schema_spec.rb
2056
2057
  - spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb
2058
+ - spec/lutaml/xml/schema/xsd/list_simple_type_spec.rb
2057
2059
  - spec/lutaml/xml/schema/xsd/namespace_uri_remapping_spec.rb
2058
2060
  - spec/lutaml/xml/schema/xsd/schema_helper_methods_spec.rb
2059
2061
  - spec/lutaml/xml/schema/xsd/schema_mapping_spec.rb