lutaml-model 0.8.200 → 0.8.202
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/.github/scripts/test_installed_gem.rb +1 -13
- data/.github/workflows/downstream-performance.yml +1 -22
- data/.github/workflows/performance.yml +1 -33
- data/.github/workflows/rake.yml +2 -6
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -4
- data/Gemfile +0 -23
- data/README.adoc +25 -86
- data/Rakefile +2 -167
- data/docs/_guides/advanced-mapping.adoc +6 -6
- data/docs/_guides/character-encoding.adoc +0 -3
- data/docs/_guides/gem-integration.adoc +1 -1
- data/docs/_guides/index.adoc +0 -4
- data/docs/_guides/xml/type-namespaces.adoc +1 -1
- data/docs/_guides/xml-guide-0.8.0.adoc +2 -2
- data/docs/_guides/xml-namespaces.adoc +2 -3
- data/docs/_guides/xml_mappings/03_architecture.adoc +2 -2
- data/docs/_guides/xml_mappings/07_best_practices.adoc +2 -3
- data/docs/_guides/xml_mappings/08_troubleshooting.adoc +1 -9
- data/docs/_pages/comparison-with-shale.adoc +1 -1
- data/docs/_pages/configuration.adoc +6 -40
- data/docs/_pages/index.adoc +0 -1
- data/docs/_pages/serialization_adapters.adoc +4 -16
- data/docs/_references/architecture.adoc +1 -1
- data/docs/_references/lutaml-namespace-planning.md +1 -1
- data/docs/_references/three-phase-namespace-architecture.adoc +1 -2
- data/docs/_references/xsd-generation-with-namespace-support.adoc +3 -8
- data/docs/_tutorials/lutaml-xml-architecture.adoc +2 -8
- data/docs/architecture.md +7 -11
- data/docs/conversion_caching.adoc +1 -1
- data/docs/index.adoc +0 -1
- data/docs/key_value_data_model.adoc +1 -1
- data/docs/namespace-management.adoc +4 -10
- data/lib/lutaml/json/format.rb +0 -1
- data/lib/lutaml/json/generator_options.rb +0 -1
- data/lib/lutaml/key_value/transform.rb +9 -16
- data/lib/lutaml/lml/document_builder.rb +2 -2
- data/lib/lutaml/lml/entity_types.rb +2 -2
- data/lib/lutaml/model/adapter_resolver.rb +5 -15
- data/lib/lutaml/model/attribute.rb +14 -2
- data/lib/lutaml/model/cached_type_resolver.rb +1 -7
- data/lib/lutaml/model/error/unknown_adapter_type_error.rb +1 -1
- data/lib/lutaml/model/global_context.rb +3 -5
- data/lib/lutaml/model/instrumentation.rb +0 -3
- data/lib/lutaml/model/mapping/mapping_rule.rb +6 -10
- data/lib/lutaml/model/register.rb +20 -31
- data/lib/lutaml/model/runtime_compatibility.rb +0 -92
- data/lib/lutaml/model/schema/class_loader.rb +2 -4
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/simple_types.rb +2 -3
- data/lib/lutaml/model/serialize/attribute_definition.rb +10 -184
- data/lib/lutaml/model/serialize/conversion_caching.rb +1 -5
- data/lib/lutaml/model/serialize/model_import.rb +0 -5
- data/lib/lutaml/model/serialize/value_mapping.rb +0 -3
- data/lib/lutaml/model/services/rule_value_extractor.rb +4 -7
- data/lib/lutaml/model/store.rb +10 -17
- data/lib/lutaml/model/toml.rb +0 -2
- data/lib/lutaml/model/transformation_registry.rb +3 -7
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model.rb +3 -19
- data/lib/lutaml/toml/format.rb +4 -8
- data/lib/lutaml/xml/adapter/moxml_adapter.rb +1 -7
- data/lib/lutaml/xml/adapter.rb +0 -4
- data/lib/lutaml/xml/adapter_loader.rb +1 -6
- data/lib/lutaml/xml/builder/base.rb +0 -3
- data/lib/lutaml/xml/builder.rb +0 -8
- data/lib/lutaml/xml/data_model.rb +1 -1
- data/lib/lutaml/xml/doctype_extractor.rb +3 -3
- data/lib/lutaml/xml/format.rb +22 -74
- data/lib/lutaml/xml/leptris/plan_compiler.rb +1 -2
- data/lib/lutaml/xml/model_transform.rb +14 -24
- data/lib/lutaml/xml/polymorphic_value_handler.rb +1 -1
- data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
- data/lib/lutaml/xml/schema/builder.rb +6 -9
- data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
- data/lib/lutaml/xml/xml_element.rb +3 -2
- data/lib/lutaml/xml/xsd_validator.rb +4 -11
- data/lib/lutaml/yaml/adapter/yeptris_adapter.rb +2 -2
- data/lib/lutaml/yamls/adapter_loader.rb +1 -5
- data/lib/tasks/performance_comparator.rb +1 -1
- data/lutaml-model.gemspec +3 -8
- data/spec/benchmarks/xml_parsing_benchmark_spec.rb +1 -1
- data/spec/lutaml/json/adapter/standard_adapter_spec.rb +6 -9
- data/spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb +0 -2
- data/spec/lutaml/model/cached_type_resolver_spec.rb +2 -54
- data/spec/lutaml/model/cdata_spec.rb +2 -15
- data/spec/lutaml/model/encoding_spec.rb +0 -9
- data/spec/lutaml/model/except_spec.rb +0 -7
- data/spec/lutaml/model/json_spec.rb +0 -14
- data/spec/lutaml/model/mixed_content_spec.rb +6 -46
- data/spec/lutaml/model/ordered_content_spec.rb +0 -7
- data/spec/lutaml/model/polymorphic_scalar_member_spec.rb +57 -0
- data/spec/lutaml/model/processing_instruction_spec.rb +0 -6
- data/spec/lutaml/model/runtime_compatibility_spec.rb +0 -37
- data/spec/lutaml/model/serializable_spec.rb +0 -2
- data/spec/lutaml/model/toml_spec.rb +0 -23
- data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +0 -4
- data/spec/lutaml/xml/adapter/order_spec.rb +1 -1
- data/spec/lutaml/xml/adapter/xml_namespace_spec.rb +0 -7
- data/spec/lutaml/xml/attribute_namespace_disjointness_spec.rb +6 -6
- data/spec/lutaml/xml/builder/builder_spec.rb +0 -24
- data/spec/lutaml/xml/default_namespace_spec.rb +1 -8
- data/spec/lutaml/xml/doctype_preservation_spec.rb +0 -4
- data/spec/lutaml/xml/entity_fragmentation_spec.rb +0 -6
- data/spec/lutaml/xml/fpi_namespace_spec.rb +0 -21
- data/spec/lutaml/xml/mapping_spec.rb +8 -15
- data/spec/lutaml/xml/namespace_scope_vcard_spec.rb +0 -7
- data/spec/lutaml/xml/namespace_spec.rb +0 -13
- data/spec/lutaml/xml/prefix_control_spec.rb +0 -6
- data/spec/lutaml/xml/schema/builder_moxml_spec.rb +1 -1
- data/spec/lutaml/xml/xml_adapter_spec.rb +0 -7
- data/spec/lutaml/xml/xml_spec.rb +2 -88
- data/spec/spec_helper.rb +5 -24
- data/spec/support/test_adapter_config.rb +6 -6
- metadata +1 -32
- data/.github/workflows/js-pr-check.yml +0 -106
- data/.github/workflows/js-sync.yml +0 -55
- data/.github/workflows/opal.yml +0 -65
- data/.gitmodules +0 -6
- data/.rspec-opal +0 -5
- data/docs/_guides/opal.adoc +0 -232
- data/lib/compat/opal/generate_boot.rb +0 -137
- data/lib/compat/opal/js_bundle_entry.rb +0 -42
- data/lib/compat/opal/lutaml_model_boot.rb +0 -638
- data/lib/compat/opal/monitor.rb +0 -31
- data/lib/compat/opal/moxml/adapter/customized_rexml/entity_reference.rb +0 -9
- data/lib/compat/opal/moxml/adapter/customized_rexml/formatter.rb +0 -225
- data/lib/compat/opal/moxml/adapter/customized_rexml.rb +0 -11
- data/lib/compat/opal/moxml_boot.rb +0 -68
- data/lib/compat/opal/objectspace_shim.rb +0 -23
- data/lib/compat/opal/rexml/namespace.rb +0 -59
- data/lib/compat/opal/rexml/parsers/baseparser.rb +0 -1016
- data/lib/compat/opal/rexml/source.rb +0 -214
- data/lib/compat/opal/rexml/text.rb +0 -426
- data/lib/compat/opal/rexml/xmltokens.rb +0 -45
- data/lib/compat/opal/rexml_compat.rb +0 -85
- data/lib/compat/opal/yaml_compat.rb +0 -32
- data/lib/lutaml/model/cached_type_resolver/mutex_hash_cache.rb +0 -53
- data/lib/lutaml/model/schema/schema_builder/oga.rb +0 -92
- data/lib/lutaml/xml/schema/builder/oga.rb +0 -92
- data/spec/lutaml/model/boot_manifest_spec.rb +0 -30
- data/spec/lutaml/model/opal_smoke_spec.rb +0 -199
- data/spec/lutaml/model/serialize/attribute_definition_block_form_spec.rb +0 -244
- data/spec/lutaml/xml/adapter/oga_adapter_spec.rb +0 -135
- data/spec/lutaml/xml/opal_xml_spec.rb +0 -204
- data/spec/support/opal.rb +0 -9
|
@@ -125,7 +125,7 @@ RSpec.describe "XML adapter order metadata" do
|
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
%i[nokogiri ox
|
|
128
|
+
%i[nokogiri ox rexml].each do |engine|
|
|
129
129
|
describe "the :#{engine} lane" do
|
|
130
130
|
it_behaves_like "consistent order metadata",
|
|
131
131
|
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(engine)
|
|
@@ -512,13 +512,6 @@ RSpec.describe "XmlNamespace" do
|
|
|
512
512
|
end
|
|
513
513
|
end
|
|
514
514
|
|
|
515
|
-
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
516
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
517
|
-
it_behaves_like "an XML namespace parser",
|
|
518
|
-
described_class
|
|
519
|
-
end
|
|
520
|
-
end
|
|
521
|
-
|
|
522
515
|
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
523
516
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
524
517
|
it_behaves_like "an XML namespace parser",
|
|
@@ -7,8 +7,8 @@ require "spec_helper"
|
|
|
7
7
|
# serialization (lutaml-model#744).
|
|
8
8
|
#
|
|
9
9
|
# The coexisting-spelling cases under nokogiri/rexml additionally require the
|
|
10
|
-
# moxml adapter fixes (lutaml/moxml#94, lutaml/moxml#95);
|
|
11
|
-
#
|
|
10
|
+
# moxml adapter fixes (lutaml/moxml#94, lutaml/moxml#95); ox already
|
|
11
|
+
# preserves same-local-name attributes across namespaces.
|
|
12
12
|
module AttributeNamespaceDisjointnessSpec
|
|
13
13
|
class XmiNs < Lutaml::Xml::Namespace
|
|
14
14
|
uri "http://www.example.com/xmi"
|
|
@@ -56,7 +56,7 @@ RSpec.describe "Attribute namespace-disjoint parsing" do
|
|
|
56
56
|
%(<probe type="EAnone_void" xmlns:xmi="http://www.example.com/xmi" xmi:type="uml:Parameter"/>)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
%i[
|
|
59
|
+
%i[ox nokogiri].each do |adapter|
|
|
60
60
|
context "with the #{adapter} adapter" do
|
|
61
61
|
it "routes a namespaced rule to the attribute bound to its URI" do
|
|
62
62
|
probe = AttributeNamespaceDisjointnessSpec.parse(namespaced_xmi,
|
|
@@ -85,8 +85,8 @@ RSpec.describe "Attribute namespace-disjoint parsing" do
|
|
|
85
85
|
|
|
86
86
|
# Same-local-name attributes coexisting on one element require the moxml
|
|
87
87
|
# fixes (lutaml/moxml#94 drops one under nokogiri; lutaml/moxml#95 crashes
|
|
88
|
-
# under rexml), so these cases run on the
|
|
89
|
-
%i[
|
|
88
|
+
# under rexml), so these cases run on the engine that preserves both.
|
|
89
|
+
%i[ox].each do |adapter|
|
|
90
90
|
context "with the #{adapter} adapter" do
|
|
91
91
|
it "keeps both spellings disjoint regardless of document order" do
|
|
92
92
|
[both_spellings, both_spellings_plain_first].each do |xml|
|
|
@@ -116,7 +116,7 @@ RSpec.describe "Attribute namespace-disjoint parsing" do
|
|
|
116
116
|
xmi_type: "uml:Parameter",
|
|
117
117
|
plain_type: "EAnone_void",
|
|
118
118
|
)
|
|
119
|
-
reparsed = AttributeNamespaceDisjointnessSpec.parse(probe.to_xml, :
|
|
119
|
+
reparsed = AttributeNamespaceDisjointnessSpec.parse(probe.to_xml, :ox)
|
|
120
120
|
|
|
121
121
|
expect(reparsed.xmi_type).to eq("uml:Parameter")
|
|
122
122
|
expect(reparsed.plain_type).to eq("EAnone_void")
|
|
@@ -192,30 +192,6 @@ RSpec.describe "XML Builder consistency" do
|
|
|
192
192
|
it_behaves_like "a consistent XML builder"
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
-
describe "on :oga" do
|
|
196
|
-
let(:engine) { :oga }
|
|
197
|
-
|
|
198
|
-
it_behaves_like "a consistent XML builder"
|
|
199
|
-
|
|
200
|
-
it "defaults namespace validation to lenient under Opal" do
|
|
201
|
-
allow(Lutaml::Model::RuntimeCompatibility).to receive(:opal?)
|
|
202
|
-
.and_return(true)
|
|
203
|
-
|
|
204
|
-
builder = Lutaml::Xml::Builder::Base.build(engine: engine) do |xml|
|
|
205
|
-
xml.create_and_add_element(
|
|
206
|
-
"root",
|
|
207
|
-
attributes: {
|
|
208
|
-
"xmlns" => "-//OASIS//DTD XML Exchange Table Model 19990315//EN",
|
|
209
|
-
},
|
|
210
|
-
)
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
expect(builder.to_xml).to include(
|
|
214
|
-
'xmlns="-//OASIS//DTD XML Exchange Table Model 19990315//EN"',
|
|
215
|
-
)
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
195
|
describe "on :rexml" do
|
|
220
196
|
let(:engine) { :rexml }
|
|
221
197
|
|
|
@@ -95,7 +95,7 @@ RSpec.describe DefaultNamespaceSpec do
|
|
|
95
95
|
# and namespace has element_form_default: :unqualified (W3C default),
|
|
96
96
|
# so child is in BLANK namespace and MUST declare xmlns="".
|
|
97
97
|
#
|
|
98
|
-
# All adapters (Nokogiri, Ox
|
|
98
|
+
# All adapters (Nokogiri, Ox) now correctly add xmlns=""
|
|
99
99
|
# to explicitly place child in blank namespace.
|
|
100
100
|
expect(xml).to include('xmlns="http://example.com/ns"')
|
|
101
101
|
expect(xml).to include('<child xmlns="">Content</child>')
|
|
@@ -179,11 +179,4 @@ RSpec.describe DefaultNamespaceSpec do
|
|
|
179
179
|
described_class
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
|
-
|
|
183
|
-
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
184
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
185
|
-
it_behaves_like "default namespace serialization",
|
|
186
|
-
described_class
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
182
|
end
|
|
@@ -563,12 +563,6 @@ RSpec.describe "XML Entity Fragmentation Issue #5" do
|
|
|
563
563
|
end
|
|
564
564
|
end
|
|
565
565
|
|
|
566
|
-
describe "with Oga adapter" do
|
|
567
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
568
|
-
it_behaves_like "XML entity preservation", :oga
|
|
569
|
-
end
|
|
570
|
-
end
|
|
571
|
-
|
|
572
566
|
describe "with Ox adapter" do
|
|
573
567
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
574
568
|
it_behaves_like "XML entity preservation", :ox
|
|
@@ -69,27 +69,6 @@ RSpec.describe "FPI Namespace Handling" do
|
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
context "with Oga adapter" do
|
|
73
|
-
before(:all) do
|
|
74
|
-
Lutaml::Model::Config.xml_adapter_type = :oga
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "converts FPI namespace to URN on serialization" do
|
|
78
|
-
xml = <<~XML
|
|
79
|
-
<table xmlns="-//OASIS//DTD XML Exchange Table Model 19990315//EN">
|
|
80
|
-
<entry>Data</entry>
|
|
81
|
-
</table>
|
|
82
|
-
XML
|
|
83
|
-
|
|
84
|
-
adapter_class = Lutaml::Model::Config.xml_adapter
|
|
85
|
-
doc = adapter_class.parse(xml)
|
|
86
|
-
|
|
87
|
-
output = doc.to_xml
|
|
88
|
-
|
|
89
|
-
expect(output).to include("urn:publicid:-//OASIS//DTD+XML+Exchange+Table+Model+19990315//EN")
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
72
|
context "helper methods in BaseAdapter" do
|
|
94
73
|
before(:all) do
|
|
95
74
|
# Use any adapter to test the class methods
|
|
@@ -624,7 +624,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
624
624
|
serialized = parsed.to_xml
|
|
625
625
|
|
|
626
626
|
# Different adapters have different hoisting behaviors:
|
|
627
|
-
# - Nokogiri
|
|
627
|
+
# - Nokogiri: Hoists namespace to parent
|
|
628
628
|
# - Ox: No namespace declaration (uses inline xmi prefix without xmlns)
|
|
629
629
|
expected = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
630
630
|
# Ox doesn't add xmlns declaration when model has no namespace
|
|
@@ -634,7 +634,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
634
634
|
</ownedComment>
|
|
635
635
|
XML
|
|
636
636
|
else
|
|
637
|
-
# Nokogiri
|
|
637
|
+
# Nokogiri hoists the namespace
|
|
638
638
|
xml_with_element_hoisted.strip
|
|
639
639
|
end
|
|
640
640
|
expect(serialized).to be_xml_equivalent_to(expected)
|
|
@@ -653,7 +653,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
653
653
|
serialized = parsed.to_xml
|
|
654
654
|
|
|
655
655
|
# Different adapters have different hoisting behaviors:
|
|
656
|
-
# - Nokogiri
|
|
656
|
+
# - Nokogiri: Hoists namespace to parent
|
|
657
657
|
# - Ox: No namespace declaration (uses inline xmi prefix without xmlns)
|
|
658
658
|
expected = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
659
659
|
# Ox doesn't add xmlns declaration when model has no namespace
|
|
@@ -663,7 +663,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
663
663
|
</ownedComment>
|
|
664
664
|
XML
|
|
665
665
|
else
|
|
666
|
-
# Nokogiri
|
|
666
|
+
# Nokogiri hoists the namespace
|
|
667
667
|
xml_with_same_name_attribute_and_element_hoisted
|
|
668
668
|
end
|
|
669
669
|
expect(serialized).to be_xml_equivalent_to(expected)
|
|
@@ -704,7 +704,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
704
704
|
</SameElementName>
|
|
705
705
|
XML
|
|
706
706
|
else
|
|
707
|
-
# Nokogiri
|
|
707
|
+
# Nokogiri: CityGML preserves PREFIX format, GML uses DEFAULT
|
|
708
708
|
<<~XML
|
|
709
709
|
<SameElementName xmlns="http://www.omg.org/spec/XMI/20131001" App="hello">
|
|
710
710
|
<ApplicationSchema xmlns="http://www.sparxsystems.com/profiles/GML/1.0">GML App</ApplicationSchema>
|
|
@@ -801,7 +801,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
801
801
|
it "reads element without namespace" do
|
|
802
802
|
# NOTE: mapping with namespace: nil, prefix: nil has differing adapter behavior:
|
|
803
803
|
# - Nokogiri: Cannot parse element with parent namespace prefix, returns nil
|
|
804
|
-
# - Ox
|
|
804
|
+
# - Ox: Can parse element with parent namespace prefix successfully
|
|
805
805
|
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
806
806
|
expect(parsed.without_namespace).to be_nil
|
|
807
807
|
else
|
|
@@ -820,7 +820,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
820
820
|
expect(reparsed.with_default_namespace).to eq("default namespace text")
|
|
821
821
|
expect(reparsed.with_namespace.value).to eq("explicit namespace text")
|
|
822
822
|
else
|
|
823
|
-
# Ox
|
|
823
|
+
# Ox can parse the element successfully
|
|
824
824
|
# When parent has element_form_default: :qualified (ParentNamespace has this),
|
|
825
825
|
# children without explicit namespace inherit parent's namespace.
|
|
826
826
|
# WithoutNamespaceElement has no namespace declaration, so it inherits.
|
|
@@ -917,7 +917,7 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
917
917
|
# instead of prefix format for child elements with different namespaces.
|
|
918
918
|
# Both are W3C compliant.
|
|
919
919
|
let(:expected_xml) do
|
|
920
|
-
# Ox uses prefix format, Nokogiri
|
|
920
|
+
# Ox uses prefix format, Nokogiri uses default format
|
|
921
921
|
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
922
922
|
<<~XML
|
|
923
923
|
<ChildNamespaceNil xmlns="http://www.omg.org/spec/XMI/20131001">
|
|
@@ -1134,13 +1134,6 @@ RSpec.describe Lutaml::Xml::Mapping do
|
|
|
1134
1134
|
end
|
|
1135
1135
|
end
|
|
1136
1136
|
|
|
1137
|
-
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
1138
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
1139
|
-
it_behaves_like "having XML Mappings",
|
|
1140
|
-
described_class
|
|
1141
|
-
end
|
|
1142
|
-
end
|
|
1143
|
-
|
|
1144
1137
|
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
1145
1138
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
1146
1139
|
it_behaves_like "having XML Mappings", described_class
|
|
@@ -597,13 +597,6 @@ RSpec.describe "namespace_scope with vCard" do
|
|
|
597
597
|
end
|
|
598
598
|
end
|
|
599
599
|
|
|
600
|
-
context "with Oga adapter" do
|
|
601
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
602
|
-
it_behaves_like "namespace_scope behavior",
|
|
603
|
-
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
604
|
-
end
|
|
605
|
-
end
|
|
606
|
-
|
|
607
600
|
context "with REXML adapter" do
|
|
608
601
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
609
602
|
it_behaves_like "namespace_scope behavior",
|
|
@@ -685,19 +685,6 @@ RSpec.describe "XML Namespace Handling" do
|
|
|
685
685
|
it_behaves_like "namespace inheritance behavior"
|
|
686
686
|
end
|
|
687
687
|
|
|
688
|
-
describe "with Oga adapter" do
|
|
689
|
-
around do |example|
|
|
690
|
-
Lutaml::Model::Config.xml_adapter_type = :oga
|
|
691
|
-
example.run
|
|
692
|
-
end
|
|
693
|
-
|
|
694
|
-
after(:all) do
|
|
695
|
-
Lutaml::Model::Config.xml_adapter_type = :nokogiri
|
|
696
|
-
end
|
|
697
|
-
|
|
698
|
-
it_behaves_like "namespace inheritance behavior"
|
|
699
|
-
end
|
|
700
|
-
|
|
701
688
|
describe "with REXML adapter" do
|
|
702
689
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
703
690
|
around do |example|
|
|
@@ -268,12 +268,6 @@ RSpec.describe "XML Prefix Control" do
|
|
|
268
268
|
end
|
|
269
269
|
end
|
|
270
270
|
|
|
271
|
-
context "with Oga adapter" do
|
|
272
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
273
|
-
it_behaves_like "prefix control behavior", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
|
|
277
271
|
context "with REXML adapter" do
|
|
278
272
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
279
273
|
it_behaves_like "prefix control behavior",
|
|
@@ -4,7 +4,7 @@ require "spec_helper"
|
|
|
4
4
|
|
|
5
5
|
RSpec.describe Lutaml::Xml::Schema::Builder do
|
|
6
6
|
# issue #1184: schema generation rides the CONFIGURED engine through
|
|
7
|
-
# the moxml layer. The dedicated Nokogiri
|
|
7
|
+
# the moxml layer. The dedicated Nokogiri wrapper keeps its
|
|
8
8
|
# lanes; every other engine (ox, leptris, rexml) generates through
|
|
9
9
|
# the Moxml wrapper instead of silently substituting Nokogiri.
|
|
10
10
|
|
|
@@ -238,13 +238,6 @@ RSpec.describe "XmlAdapter" do
|
|
|
238
238
|
end
|
|
239
239
|
end
|
|
240
240
|
|
|
241
|
-
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
242
|
-
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
243
|
-
it_behaves_like "an XML adapter",
|
|
244
|
-
described_class
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
|
|
248
241
|
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
249
242
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
250
243
|
it_behaves_like "an XML adapter",
|
data/spec/lutaml/xml/xml_spec.rb
CHANGED
|
@@ -34,82 +34,8 @@ RSpec.describe Lutaml::Xml do
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
describe "schema autoloads" do
|
|
37
|
-
it "
|
|
38
|
-
expect(described_class::Schema.const_defined?(:Xsd, false))
|
|
39
|
-
.to be(!Lutaml::Model::RuntimeCompatibility.opal?)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "does not autoload schema constants when loaded under Opal" do
|
|
43
|
-
script = <<~'RUBY'
|
|
44
|
-
require "lutaml/model/runtime_compatibility"
|
|
45
|
-
|
|
46
|
-
module Lutaml
|
|
47
|
-
module Model
|
|
48
|
-
module RuntimeCompatibility
|
|
49
|
-
def self.opal?
|
|
50
|
-
true
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
require "lutaml/xml/schema"
|
|
57
|
-
|
|
58
|
-
schema_constants = %i[
|
|
59
|
-
Xsd XsdSchema RelaxngSchema Builder BuiltinTypes
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
loaded_constants = schema_constants.select do |constant_name|
|
|
63
|
-
Lutaml::Xml::Schema.autoload?(constant_name) ||
|
|
64
|
-
Lutaml::Xml::Schema.const_defined?(constant_name, false)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
if loaded_constants.any?
|
|
68
|
-
abort "loaded schema constants: #{loaded_constants.join(', ')}"
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
puts :ok
|
|
72
|
-
RUBY
|
|
73
|
-
|
|
74
|
-
result, status = run_ruby(script)
|
|
75
|
-
|
|
76
|
-
expect(status.success?).to be(true), result
|
|
77
|
-
expect(result).to include("ok")
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
describe "schema methods" do
|
|
82
|
-
before do
|
|
83
|
-
allow(Lutaml::Model::RuntimeCompatibility).to receive(:opal?)
|
|
84
|
-
.and_return(true)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "raises NotImplementedError for XSD generation under Opal" do
|
|
88
|
-
expect do
|
|
89
|
-
Lutaml::Model::Schema.to_xsd(Object)
|
|
90
|
-
end.to raise_error(
|
|
91
|
-
NotImplementedError,
|
|
92
|
-
"XSD schema generation is not available under Opal.",
|
|
93
|
-
)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "raises NotImplementedError for RELAX NG generation under Opal" do
|
|
97
|
-
expect do
|
|
98
|
-
Lutaml::Model::Schema.to_relaxng(Object)
|
|
99
|
-
end.to raise_error(
|
|
100
|
-
NotImplementedError,
|
|
101
|
-
"RELAX NG schema generation requires Nokogiri, " \
|
|
102
|
-
"which is not available under Opal.",
|
|
103
|
-
)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "raises NotImplementedError for XML schema compilation under Opal" do
|
|
107
|
-
expect do
|
|
108
|
-
Lutaml::Model::Schema.from_xml("<schema/>")
|
|
109
|
-
end.to raise_error(
|
|
110
|
-
NotImplementedError,
|
|
111
|
-
"XML schema compilation is not available under Opal.",
|
|
112
|
-
)
|
|
37
|
+
it "registers the schema constant autoloads" do
|
|
38
|
+
expect(described_class::Schema.const_defined?(:Xsd, false)).to be(true)
|
|
113
39
|
end
|
|
114
40
|
end
|
|
115
41
|
|
|
@@ -118,7 +44,6 @@ RSpec.describe Lutaml::Xml do
|
|
|
118
44
|
# Hide any existing constants first
|
|
119
45
|
hide_const("Nokogiri") if Object.const_defined?(:Nokogiri)
|
|
120
46
|
hide_const("Ox") if Object.const_defined?(:Ox)
|
|
121
|
-
hide_const("Oga") if Object.const_defined?(:Oga)
|
|
122
47
|
hide_const("REXML") if Object.const_defined?(:REXML)
|
|
123
48
|
# When the leptris gem is in the bundle, moxml prefers it over every
|
|
124
49
|
# other engine; the legacy-detection contexts below must opt out to
|
|
@@ -155,16 +80,6 @@ RSpec.describe Lutaml::Xml do
|
|
|
155
80
|
end
|
|
156
81
|
end
|
|
157
82
|
|
|
158
|
-
context "when Oga is available" do
|
|
159
|
-
before do
|
|
160
|
-
stub_const("Oga", Module.new)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it "returns :oga" do
|
|
164
|
-
expect(described_class.detect_xml_adapter).to eq(:oga)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
83
|
context "when no adapters are detected" do
|
|
169
84
|
it "falls back to moxml default (:nokogiri)" do
|
|
170
85
|
expect(described_class.detect_xml_adapter).to eq(:nokogiri)
|
|
@@ -175,7 +90,6 @@ RSpec.describe Lutaml::Xml do
|
|
|
175
90
|
before do
|
|
176
91
|
stub_const("Nokogiri", Module.new)
|
|
177
92
|
stub_const("Ox", Module.new)
|
|
178
|
-
stub_const("Oga", Module.new)
|
|
179
93
|
end
|
|
180
94
|
|
|
181
95
|
it "prefers Nokogiri" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "liquid"
|
|
3
|
+
require "liquid"
|
|
4
4
|
require "rspec/matchers"
|
|
5
|
-
require "canon"
|
|
5
|
+
require "canon"
|
|
6
6
|
|
|
7
7
|
RSpec.configure do |config|
|
|
8
8
|
# Enable flags like --only-failures and --next-failure
|
|
@@ -86,22 +86,6 @@ RSpec.configure do |config|
|
|
|
86
86
|
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
-
|
|
90
|
-
# Under Opal, exclude specs that require native-only adapters,
|
|
91
|
-
# filesystem, subprocess, schema compilation, or liquid templates.
|
|
92
|
-
if RUBY_ENGINE == "opal"
|
|
93
|
-
config.filter_run_excluding(
|
|
94
|
-
:native_adapter,
|
|
95
|
-
:native_fs,
|
|
96
|
-
:subprocess,
|
|
97
|
-
:performance,
|
|
98
|
-
:examples,
|
|
99
|
-
:consistency,
|
|
100
|
-
:xsd_schema,
|
|
101
|
-
:relaxng,
|
|
102
|
-
:liquid,
|
|
103
|
-
)
|
|
104
|
-
end
|
|
105
89
|
end
|
|
106
90
|
|
|
107
91
|
# configuration example
|
|
@@ -114,9 +98,7 @@ require_relative "support/test_adapter_config"
|
|
|
114
98
|
# require_relative "../lib/lutaml/model/toml_adapter/toml_rb_adapter"
|
|
115
99
|
|
|
116
100
|
Lutaml::Model::Config.configure do |config|
|
|
117
|
-
config.xml_adapter_type = if
|
|
118
|
-
:oga
|
|
119
|
-
elsif ENV["XML_ADAPTER"]
|
|
101
|
+
config.xml_adapter_type = if ENV["XML_ADAPTER"]
|
|
120
102
|
ENV["XML_ADAPTER"].to_sym
|
|
121
103
|
else
|
|
122
104
|
:nokogiri
|
|
@@ -124,11 +106,10 @@ Lutaml::Model::Config.configure do |config|
|
|
|
124
106
|
config.hash_adapter_type = :standard
|
|
125
107
|
config.json_adapter_type = :standard
|
|
126
108
|
config.yaml_adapter_type = :standard
|
|
127
|
-
|
|
128
|
-
config.toml_adapter_type = :toml_rb unless RUBY_ENGINE == "opal"
|
|
109
|
+
config.toml_adapter_type = :toml_rb
|
|
129
110
|
end
|
|
130
111
|
|
|
131
|
-
# Configure Canon for XML equivalence testing
|
|
112
|
+
# Configure Canon for XML equivalence testing
|
|
132
113
|
if defined?(Canon::Config)
|
|
133
114
|
Canon::Config.configure do |config|
|
|
134
115
|
config.xml.match.profile = :spec_friendly
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Implements Adapter First Strategy:
|
|
6
6
|
# - Start with primary adapter (Nokogiri)
|
|
7
|
-
# - Enable other adapters (Ox
|
|
7
|
+
# - Enable other adapters (Ox) incrementally once they pass full test suite
|
|
8
8
|
#
|
|
9
9
|
# Usage:
|
|
10
10
|
# # Enable only Nokogiri (primary)
|
|
@@ -42,7 +42,7 @@ class TestAdapterConfig
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# Enable an adapter for testing
|
|
45
|
-
# @param name [Symbol] Adapter name (:nokogiri, :ox
|
|
45
|
+
# @param name [Symbol] Adapter name (:nokogiri, :ox)
|
|
46
46
|
def enable_adapter(name)
|
|
47
47
|
adapters_to_test << name unless adapters_to_test.include?(name)
|
|
48
48
|
end
|
|
@@ -56,7 +56,7 @@ class TestAdapterConfig
|
|
|
56
56
|
|
|
57
57
|
# Get the adapter lane for an engine: the one moxml adapter
|
|
58
58
|
# pinned to that engine.
|
|
59
|
-
# @param name [Symbol] Engine name (:nokogiri, :ox, :
|
|
59
|
+
# @param name [Symbol] Engine name (:nokogiri, :ox, :rexml, :leptris)
|
|
60
60
|
# @return [Class] The pinned adapter class
|
|
61
61
|
def adapter_class(name)
|
|
62
62
|
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(name)
|
|
@@ -65,7 +65,7 @@ class TestAdapterConfig
|
|
|
65
65
|
# Get list of all available adapter names
|
|
66
66
|
# @return [Array<Symbol>] List of all adapter names
|
|
67
67
|
def all_adapters
|
|
68
|
-
%i[nokogiri ox
|
|
68
|
+
%i[nokogiri ox rexml]
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# Get engine name by adapter class
|
|
@@ -79,7 +79,7 @@ class TestAdapterConfig
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
# Initial configuration: Primary adapter (Nokogiri) only
|
|
82
|
-
# Enable other adapters (Ox
|
|
82
|
+
# Enable other adapters (Ox) incrementally once they pass full test suite
|
|
83
83
|
TestAdapterConfig.configure do |config|
|
|
84
|
-
config.enabled_adapters = %i[nokogiri
|
|
84
|
+
config.enabled_adapters = %i[nokogiri]
|
|
85
85
|
end
|