lutaml-model 0.8.190 → 0.8.192
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/lib/compat/opal/generate_boot.rb +5 -4
- data/lib/compat/opal/lutaml_model_boot.rb +0 -7
- data/lib/lutaml/model/attribute.rb +6 -11
- data/lib/lutaml/model/serialize/format_conversion.rb +4 -6
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/adapter/adapter_helpers.rb +3 -3
- data/lib/lutaml/xml/adapter/base_adapter.rb +13 -29
- data/lib/lutaml/xml/adapter/moxml_adapter.rb +113 -22
- data/lib/lutaml/xml/adapter/xml_parser.rb +6 -8
- data/lib/lutaml/xml/adapter/xml_serializer.rb +3 -1
- data/lib/lutaml/xml/adapter.rb +0 -4
- data/lib/lutaml/xml/adapter_element.rb +19 -9
- data/lib/lutaml/xml/adapter_loader.rb +26 -11
- data/lib/lutaml/xml/builder/base.rb +6 -7
- data/lib/lutaml/xml/document.rb +1 -1
- data/lib/lutaml/xml/format.rb +0 -10
- data/lib/lutaml/xml/leptris/plan_hydrator.rb +2 -2
- data/spec/lutaml/model/cdata_spec.rb +11 -27
- data/spec/lutaml/model/direct_construction_verbatim_spec.rb +82 -0
- data/spec/lutaml/model/encoding_spec.rb +6 -6
- data/spec/lutaml/model/except_spec.rb +5 -7
- data/spec/lutaml/model/mixed_content_spec.rb +22 -25
- data/spec/lutaml/model/multiple_mapping_spec.rb +8 -10
- data/spec/lutaml/model/ordered_content_spec.rb +5 -8
- data/spec/lutaml/model/processing_instruction_spec.rb +6 -9
- data/spec/lutaml/model/serialize/attribute_definition_block_form_spec.rb +1 -1
- data/spec/lutaml/model/serialize/builder_spec.rb +1 -1
- data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +5 -8
- data/spec/lutaml/xml/adapter/empty_document_diagnostics_spec.rb +3 -4
- data/spec/lutaml/xml/adapter/nokogiri_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/oga_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/order_spec.rb +8 -22
- data/spec/lutaml/xml/adapter/over_cap_parse_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/ox_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/rexml_adapter_spec.rb +2 -2
- data/spec/lutaml/xml/adapter/xml_namespace_spec.rb +5 -8
- data/spec/lutaml/xml/adapter_loader_spec.rb +15 -3
- data/spec/lutaml/xml/adapter_metadata_default_spec.rb +1 -1
- data/spec/lutaml/xml/adapter_moxml_engine_spec.rb +1 -2
- data/spec/lutaml/xml/builder/builder_spec.rb +28 -20
- data/spec/lutaml/xml/default_namespace_spec.rb +4 -5
- data/spec/lutaml/xml/entity_fragmentation_spec.rb +2 -2
- data/spec/lutaml/xml/mapping_rule_spec.rb +1 -2
- data/spec/lutaml/xml/mapping_spec.rb +12 -14
- data/spec/lutaml/xml/namespace_missing_prefix_spec.rb +1 -1
- data/spec/lutaml/xml/namespace_preservation_spec.rb +11 -11
- data/spec/lutaml/xml/namespace_scope_vcard_spec.rb +5 -8
- data/spec/lutaml/xml/prefix_control_spec.rb +5 -8
- data/spec/lutaml/xml/type_namespace_prefix_spec.rb +2 -2
- data/spec/lutaml/xml/xml_adapter_spec.rb +5 -8
- data/spec/lutaml/xml/xml_declaration_spec.rb +19 -19
- data/spec/spec_helper.rb +2 -2
- data/spec/support/test_adapter_config.rb +9 -25
- metadata +2 -21
- data/lib/lutaml/xml/adapter/leptris_adapter.rb +0 -16
- data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +0 -16
- data/lib/lutaml/xml/adapter/oga_adapter.rb +0 -20
- data/lib/lutaml/xml/adapter/ox_adapter.rb +0 -16
- data/lib/lutaml/xml/adapter/rexml_adapter.rb +0 -25
- data/lib/lutaml/xml/builder/leptris.rb +0 -13
- data/lib/lutaml/xml/builder/nokogiri.rb +0 -13
- data/lib/lutaml/xml/builder/oga.rb +0 -13
- data/lib/lutaml/xml/builder/ox.rb +0 -13
- data/lib/lutaml/xml/builder/rexml.rb +0 -13
- data/lib/lutaml/xml/leptris/element.rb +0 -34
- data/lib/lutaml/xml/nokogiri/element.rb +0 -34
- data/lib/lutaml/xml/nokogiri.rb +0 -10
- data/lib/lutaml/xml/oga/element.rb +0 -15
- data/lib/lutaml/xml/oga.rb +0 -10
- data/lib/lutaml/xml/ox/element.rb +0 -15
- data/lib/lutaml/xml/ox.rb +0 -10
- data/lib/lutaml/xml/rexml/element.rb +0 -15
- data/lib/lutaml/xml/rexml.rb +0 -10
- data/lib/tasks/xml_optimization_benchmark.rb +0 -178
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require_relative "../../../lib/lutaml/model"
|
|
3
|
-
require "lutaml/xml/adapter/
|
|
4
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
6
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
3
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
7
4
|
|
|
8
5
|
module CdataSpec
|
|
9
6
|
class Beta < Lutaml::Model::Serializable
|
|
@@ -369,9 +366,9 @@ RSpec.describe CdataSpec do
|
|
|
369
366
|
instance = parent_mapper.from_xml(input_xml)
|
|
370
367
|
result_xml = parent_mapper.to_xml(instance)
|
|
371
368
|
|
|
372
|
-
expected_output = if adapter_class == Lutaml::Xml::Adapter::
|
|
369
|
+
expected_output = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
373
370
|
expected_oga_xml
|
|
374
|
-
elsif adapter_class == Lutaml::Xml::Adapter::
|
|
371
|
+
elsif adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
375
372
|
expected_ox_xml
|
|
376
373
|
else
|
|
377
374
|
expected_nokogiri_xml
|
|
@@ -467,9 +464,9 @@ RSpec.describe CdataSpec do
|
|
|
467
464
|
|
|
468
465
|
# due to the difference in capturing
|
|
469
466
|
# newlines in ox and nokogiri adapters
|
|
470
|
-
expected_result = if adapter_class == Lutaml::Xml::Adapter::
|
|
467
|
+
expected_result = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
471
468
|
expected_nokogiri_xml
|
|
472
|
-
elsif adapter_class == Lutaml::Xml::Adapter::
|
|
469
|
+
elsif adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
473
470
|
expected_ox_xml
|
|
474
471
|
else
|
|
475
472
|
expected_xml
|
|
@@ -539,9 +536,9 @@ RSpec.describe CdataSpec do
|
|
|
539
536
|
|
|
540
537
|
# due to the difference in capturing
|
|
541
538
|
# newlines in ox and nokogiri adapters
|
|
542
|
-
expected_result = if adapter_class == Lutaml::Xml::Adapter::
|
|
539
|
+
expected_result = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
543
540
|
expected_xml
|
|
544
|
-
elsif adapter_class == Lutaml::Xml::Adapter::
|
|
541
|
+
elsif adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
545
542
|
expected_ox_xml
|
|
546
543
|
else
|
|
547
544
|
expected_xml
|
|
@@ -573,25 +570,12 @@ RSpec.describe CdataSpec do
|
|
|
573
570
|
end
|
|
574
571
|
end
|
|
575
572
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
describe Lutaml::Xml::Adapter::OxAdapter do
|
|
581
|
-
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
582
|
-
it_behaves_like "cdata behavior",
|
|
583
|
-
described_class
|
|
584
|
-
end
|
|
585
|
-
end
|
|
586
|
-
|
|
587
|
-
describe Lutaml::Xml::Adapter::OgaAdapter do
|
|
588
|
-
it_behaves_like "cdata behavior", described_class
|
|
589
|
-
end
|
|
573
|
+
%i[nokogiri ox oga rexml].each do |engine|
|
|
574
|
+
next unless TestAdapterConfig.adapter_enabled?(engine)
|
|
590
575
|
|
|
591
|
-
|
|
592
|
-
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
576
|
+
describe "the :#{engine} lane" do
|
|
593
577
|
it_behaves_like "cdata behavior",
|
|
594
|
-
|
|
578
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(engine)
|
|
595
579
|
end
|
|
596
580
|
end
|
|
597
581
|
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#1252: direct construction must keep an assigned String
|
|
6
|
+
# verbatim, even when the declared type is a Serializable whose
|
|
7
|
+
# (derived or explicit) mapping exposes a scalar `content` rule. The
|
|
8
|
+
# scalar-coercion contract (#1228, #978) belongs to the format
|
|
9
|
+
# boundary (from_json/from_yaml/from_hash) only.
|
|
10
|
+
RSpec.describe "direct construction keeps assigned scalars verbatim" do
|
|
11
|
+
let(:text_element_class) do
|
|
12
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
13
|
+
attribute :content, Lutaml::Model::Serializable, default: -> { "" },
|
|
14
|
+
polymorphic: [Lutaml::Model::Type::String, :array]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
let(:title_class) do
|
|
19
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
20
|
+
attribute :content, "VerbatimTextElement"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
before do
|
|
25
|
+
stub_const("VerbatimTextElement", text_element_class)
|
|
26
|
+
stub_const("VerbatimTitle", title_class)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# The ceradoc shape: derived mapping, polymorphic inner content.
|
|
30
|
+
it "keeps the String with a derived content mapping (#1252)" do
|
|
31
|
+
title = VerbatimTitle.new(content: "Test Document")
|
|
32
|
+
|
|
33
|
+
expect(title.content).to be_a(String)
|
|
34
|
+
expect(title.content).to eq("Test Document")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "keeps the String with an explicit keyed content mapping" do
|
|
38
|
+
element_class = Class.new(Lutaml::Model::Serializable) do
|
|
39
|
+
attribute :content, :string
|
|
40
|
+
|
|
41
|
+
key_value do
|
|
42
|
+
map "content", to: :content
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
stub_const("VerbatimMappedElement", element_class)
|
|
46
|
+
|
|
47
|
+
holder = Class.new(Lutaml::Model::Serializable) do
|
|
48
|
+
attribute :body, "VerbatimMappedElement"
|
|
49
|
+
end
|
|
50
|
+
stub_const("VerbatimMappedHolder", holder)
|
|
51
|
+
|
|
52
|
+
model = VerbatimMappedHolder.new(body: "plain text")
|
|
53
|
+
|
|
54
|
+
expect(model.body).to be_a(String)
|
|
55
|
+
expect(model.body).to eq("plain text")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "still coerces at the deserialization boundary (#1228 contract)" do
|
|
59
|
+
element_class = Class.new(Lutaml::Model::Serializable) do
|
|
60
|
+
attribute :content, :string
|
|
61
|
+
|
|
62
|
+
key_value do
|
|
63
|
+
map "content", to: :content
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
stub_const("BoundaryMappedElement", element_class)
|
|
67
|
+
|
|
68
|
+
holder = Class.new(Lutaml::Model::Serializable) do
|
|
69
|
+
attribute :body, "BoundaryMappedElement"
|
|
70
|
+
|
|
71
|
+
key_value do
|
|
72
|
+
map "body", to: :body
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
stub_const("BoundaryHolder", holder)
|
|
76
|
+
|
|
77
|
+
model = BoundaryHolder.from_json('{"body": "wire text"}')
|
|
78
|
+
|
|
79
|
+
expect(model.body).to be_a(BoundaryMappedElement)
|
|
80
|
+
expect(model.body.content).to eq("wire text")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -255,26 +255,26 @@ RSpec.describe "XML Encoding Handling" do
|
|
|
255
255
|
end
|
|
256
256
|
end
|
|
257
257
|
|
|
258
|
-
if defined?(Lutaml::Xml::Adapter::
|
|
258
|
+
if defined?(Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri))
|
|
259
259
|
describe "with Nokogiri adapter" do
|
|
260
|
-
it_behaves_like "encoding behavior", Lutaml::Xml::Adapter::
|
|
260
|
+
it_behaves_like "encoding behavior", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
261
261
|
end
|
|
262
262
|
end
|
|
263
263
|
|
|
264
|
-
if defined?(Lutaml::Xml::Adapter::
|
|
264
|
+
if defined?(Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox))
|
|
265
265
|
describe "with Ox adapter" do
|
|
266
266
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
267
267
|
it_behaves_like "encoding behavior",
|
|
268
|
-
Lutaml::Xml::Adapter::
|
|
268
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
269
269
|
end
|
|
270
270
|
end
|
|
271
271
|
end
|
|
272
272
|
|
|
273
|
-
if defined?(Lutaml::Xml::Adapter::
|
|
273
|
+
if defined?(Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga))
|
|
274
274
|
describe "with Oga adapter" do
|
|
275
275
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
276
276
|
it_behaves_like "encoding behavior",
|
|
277
|
-
Lutaml::Xml::Adapter::
|
|
277
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
278
278
|
end
|
|
279
279
|
end
|
|
280
280
|
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require_relative "../../../lib/lutaml/model"
|
|
3
|
-
require "lutaml/xml/adapter/
|
|
4
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
3
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
4
|
require_relative "../../support/xml_mapping_namespaces"
|
|
7
5
|
|
|
8
6
|
module ExceptSpecs
|
|
@@ -213,25 +211,25 @@ RSpec.describe "Except" do
|
|
|
213
211
|
end
|
|
214
212
|
end
|
|
215
213
|
|
|
216
|
-
describe Lutaml::Xml::Adapter::
|
|
214
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
217
215
|
it_behaves_like "xml", described_class
|
|
218
216
|
end
|
|
219
217
|
|
|
220
|
-
describe Lutaml::Xml::Adapter::
|
|
218
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
221
219
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
222
220
|
it_behaves_like "xml",
|
|
223
221
|
described_class
|
|
224
222
|
end
|
|
225
223
|
end
|
|
226
224
|
|
|
227
|
-
describe Lutaml::Xml::Adapter::
|
|
225
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
228
226
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
229
227
|
it_behaves_like "xml",
|
|
230
228
|
described_class
|
|
231
229
|
end
|
|
232
230
|
end
|
|
233
231
|
|
|
234
|
-
describe Lutaml::Xml::Adapter::
|
|
232
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
235
233
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
236
234
|
it_behaves_like "xml",
|
|
237
235
|
described_class
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
require_relative "../../../lib/lutaml/model"
|
|
5
|
-
require "lutaml/xml/adapter/
|
|
6
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
7
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
8
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
5
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
9
6
|
require_relative "../../fixtures/sample_model"
|
|
10
7
|
require_relative "../../support/xml_mapping_namespaces"
|
|
11
8
|
|
|
@@ -426,7 +423,7 @@ RSpec.describe "MixedContent" do
|
|
|
426
423
|
|
|
427
424
|
# due to the difference in capturing
|
|
428
425
|
# newlines in ox and nokogiri adapters
|
|
429
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
426
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
430
427
|
expected_output = expected_output.gsub(/\n\s*/, " ")
|
|
431
428
|
end
|
|
432
429
|
|
|
@@ -437,7 +434,7 @@ RSpec.describe "MixedContent" do
|
|
|
437
434
|
|
|
438
435
|
# Ox normalizes whitespace in mixed content per XML spec (semantically equivalent)
|
|
439
436
|
# Canon can't compare whitespace-normalized XML, so we normalize both sides for Ox
|
|
440
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
437
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
441
438
|
normalize = ->(str) {
|
|
442
439
|
str.gsub(/\s+/, " ").gsub(/\s*</, "<").gsub(/>\s*/, ">").strip
|
|
443
440
|
}
|
|
@@ -487,7 +484,7 @@ RSpec.describe "MixedContent" do
|
|
|
487
484
|
|
|
488
485
|
# due to the difference in capturing
|
|
489
486
|
# newlines in ox and nokogiri adapters
|
|
490
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
487
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
491
488
|
expected_output = expected_output.gsub(/\n\s*/, " ")
|
|
492
489
|
end
|
|
493
490
|
|
|
@@ -501,7 +498,7 @@ RSpec.describe "MixedContent" do
|
|
|
501
498
|
|
|
502
499
|
# Ox normalizes whitespace in mixed content per XML spec (semantically equivalent)
|
|
503
500
|
# Canon can't compare whitespace-normalized XML, so we normalize both sides for Ox
|
|
504
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
501
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
505
502
|
normalize = ->(str) {
|
|
506
503
|
str.gsub(/\s+/, " ").gsub(/\s*</, "<").gsub(/>\s*/, ">").strip
|
|
507
504
|
}
|
|
@@ -560,7 +557,7 @@ RSpec.describe "MixedContent" do
|
|
|
560
557
|
|
|
561
558
|
# due to the difference in capturing
|
|
562
559
|
# newlines in ox and nokogiri adapters
|
|
563
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
560
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
564
561
|
expected_output = expected_output.gsub(/\n\s*/, " ")
|
|
565
562
|
end
|
|
566
563
|
|
|
@@ -573,7 +570,7 @@ RSpec.describe "MixedContent" do
|
|
|
573
570
|
|
|
574
571
|
# Ox normalizes whitespace in mixed content per XML spec (semantically equivalent)
|
|
575
572
|
# Canon can't compare whitespace-normalized XML, so we normalize both sides for Ox
|
|
576
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
573
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
577
574
|
normalize = ->(str) {
|
|
578
575
|
str.gsub(/\s+/, " ").gsub(/\s*</, "<").gsub(/>\s*/, ">").strip
|
|
579
576
|
}
|
|
@@ -643,7 +640,7 @@ RSpec.describe "MixedContent" do
|
|
|
643
640
|
|
|
644
641
|
# due to the difference in capturing
|
|
645
642
|
# newlines in ox and nokogiri adapters
|
|
646
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
643
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
647
644
|
expected_output = expected_output.gsub(/\n\s*/, " ")
|
|
648
645
|
end
|
|
649
646
|
|
|
@@ -660,7 +657,7 @@ RSpec.describe "MixedContent" do
|
|
|
660
657
|
|
|
661
658
|
# Ox normalizes whitespace in mixed content per XML spec (semantically equivalent)
|
|
662
659
|
# Canon can't compare whitespace-normalized XML, so we normalize both sides for Ox
|
|
663
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
660
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
664
661
|
normalize = ->(str) {
|
|
665
662
|
str.gsub(/\s+/, " ").gsub(/\s*</, "<").gsub(/>\s*/, ">").strip
|
|
666
663
|
}
|
|
@@ -824,7 +821,7 @@ RSpec.describe "MixedContent" do
|
|
|
824
821
|
it "deserializes special char mixed content correctly" do
|
|
825
822
|
parsed = MixedContentSpec::SpecialCharContentWithRawAndMixedOption.from_xml(xml)
|
|
826
823
|
expected_content = public_send(:"expected_#{adapter_class.type}_content")
|
|
827
|
-
parsed.special.force_encoding("UTF-8") unless adapter_class == Lutaml::Xml::Adapter::
|
|
824
|
+
parsed.special.force_encoding("UTF-8") unless adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
828
825
|
|
|
829
826
|
expect(parsed.special.strip).to eq(expected_content)
|
|
830
827
|
end
|
|
@@ -886,7 +883,7 @@ RSpec.describe "MixedContent" do
|
|
|
886
883
|
|
|
887
884
|
# Ox and Oga normalize whitespace in mixed content per XML spec (semantically equivalent)
|
|
888
885
|
# Canon can't compare whitespace-normalized XML, so we normalize both sides
|
|
889
|
-
if [Lutaml::Xml::Adapter::
|
|
886
|
+
if [Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox), Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)].include?(adapter_class)
|
|
890
887
|
normalize = ->(str) {
|
|
891
888
|
str.gsub(/\s+/, " ").gsub(/\s*</, "<").gsub(/>\s*/, ">").strip
|
|
892
889
|
}
|
|
@@ -916,7 +913,7 @@ RSpec.describe "MixedContent" do
|
|
|
916
913
|
it "deserializes special char mixed content correctly" do
|
|
917
914
|
parsed = MixedContentSpec::SpecialCharContentWithRawAndMixedOption.from_xml(xml)
|
|
918
915
|
|
|
919
|
-
expected_output = adapter_class == Lutaml::Xml::Adapter::
|
|
916
|
+
expected_output = adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) ? expected_nokogiri_content : expected_ox_content
|
|
920
917
|
expect(parsed.special.strip).to eq(expected_output)
|
|
921
918
|
end
|
|
922
919
|
end
|
|
@@ -1025,9 +1022,9 @@ RSpec.describe "MixedContent" do
|
|
|
1025
1022
|
parsed = MixedContentSpec::HexCode.from_xml(xml, encoding: nil)
|
|
1026
1023
|
serialized = parsed.to_xml(encoding: nil)
|
|
1027
1024
|
|
|
1028
|
-
expected_output = if adapter_class == Lutaml::Xml::Adapter::
|
|
1025
|
+
expected_output = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
1029
1026
|
expected_encoding_nil_nokogiri_xml
|
|
1030
|
-
elsif adapter_class == Lutaml::Xml::Adapter::
|
|
1027
|
+
elsif adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
1031
1028
|
expected_encoding_nil_ox_xml
|
|
1032
1029
|
else
|
|
1033
1030
|
expected_encoding_nil_oga_xml
|
|
@@ -1036,7 +1033,7 @@ RSpec.describe "MixedContent" do
|
|
|
1036
1033
|
expect(parsed.encoding).to be_nil
|
|
1037
1034
|
expect(serialized.strip).to include(expected_output.strip)
|
|
1038
1035
|
|
|
1039
|
-
if adapter_class == Lutaml::Xml::Adapter::
|
|
1036
|
+
if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
1040
1037
|
expect(serialized.encoding.to_s).to eq("ASCII-8BIT")
|
|
1041
1038
|
else
|
|
1042
1039
|
expect(serialized.encoding.to_s).to eq("UTF-8")
|
|
@@ -1105,9 +1102,9 @@ RSpec.describe "MixedContent" do
|
|
|
1105
1102
|
parsed = MixedContentSpec::Shift.from_xml(fixture)
|
|
1106
1103
|
serialized = parsed.to_xml(encoding: "Shift_JIS")
|
|
1107
1104
|
|
|
1108
|
-
expected_content = if adapter_class == Lutaml::Xml::Adapter::
|
|
1105
|
+
expected_content = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
1109
1106
|
"<root>\n <FieldName>手書き英字1</FieldName>\n <FieldName>123456</FieldName>\n</root>"
|
|
1110
|
-
elsif adapter_class == Lutaml::Xml::Adapter::
|
|
1107
|
+
elsif adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
1111
1108
|
"<root>\n <FieldName>手書き英字1</FieldName>\n <FieldName>123456</FieldName>\n</root>"
|
|
1112
1109
|
else
|
|
1113
1110
|
"<root><FieldName>手書き英字1</FieldName><FieldName>123456</FieldName></root>"
|
|
@@ -1158,7 +1155,7 @@ RSpec.describe "MixedContent" do
|
|
|
1158
1155
|
parsed = MixedContentSpec::Latin.from_xml(fixture,
|
|
1159
1156
|
encoding: "ISO-8859-1")
|
|
1160
1157
|
serialized = parsed.to_xml
|
|
1161
|
-
expected_xml = if adapter_class == Lutaml::Xml::Adapter::
|
|
1158
|
+
expected_xml = if adapter_class == Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
1162
1159
|
"<note><to>José</to><from>Müller</from><heading>Reminder</heading></note>"
|
|
1163
1160
|
else
|
|
1164
1161
|
"<note>\n <to>José</to>\n <from>Müller</from>\n <heading>Reminder</heading>\n</note>"
|
|
@@ -1475,7 +1472,7 @@ RSpec.describe "MixedContent" do
|
|
|
1475
1472
|
end
|
|
1476
1473
|
end
|
|
1477
1474
|
|
|
1478
|
-
describe Lutaml::Xml::Adapter::
|
|
1475
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
1479
1476
|
it_behaves_like "mixed content behavior", described_class
|
|
1480
1477
|
|
|
1481
1478
|
it "raises error when serializes special char content with false encoding: 'ABC'" do
|
|
@@ -1487,21 +1484,21 @@ RSpec.describe "MixedContent" do
|
|
|
1487
1484
|
end
|
|
1488
1485
|
end
|
|
1489
1486
|
|
|
1490
|
-
describe Lutaml::Xml::Adapter::
|
|
1487
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
1491
1488
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
1492
1489
|
it_behaves_like "mixed content behavior",
|
|
1493
1490
|
described_class
|
|
1494
1491
|
end
|
|
1495
1492
|
end
|
|
1496
1493
|
|
|
1497
|
-
describe Lutaml::Xml::Adapter::
|
|
1494
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
1498
1495
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
1499
1496
|
it_behaves_like "mixed content behavior",
|
|
1500
1497
|
described_class
|
|
1501
1498
|
end
|
|
1502
1499
|
end
|
|
1503
1500
|
|
|
1504
|
-
describe Lutaml::Xml::Adapter::
|
|
1501
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
1505
1502
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
1506
1503
|
it_behaves_like "mixed content behavior",
|
|
1507
1504
|
described_class
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require_relative "../../../lib/lutaml/model"
|
|
3
|
-
require "lutaml/xml/adapter/
|
|
4
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
5
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
3
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
4
|
|
|
7
5
|
module MultipleMapping
|
|
8
6
|
class Product < Lutaml::Model::Serializable
|
|
@@ -265,18 +263,18 @@ RSpec.describe MultipleMapping do
|
|
|
265
263
|
|
|
266
264
|
context "with Nokogiri adapter" do
|
|
267
265
|
it_behaves_like "xml adapter with multiple mappings",
|
|
268
|
-
Lutaml::Xml::Adapter::
|
|
266
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
269
267
|
end
|
|
270
268
|
|
|
271
269
|
context "with Ox adapter" do
|
|
272
270
|
it_behaves_like "xml adapter with multiple mappings",
|
|
273
|
-
Lutaml::Xml::Adapter::
|
|
271
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
274
272
|
end
|
|
275
273
|
|
|
276
274
|
context "with Rexml adapter" do
|
|
277
275
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
278
276
|
it_behaves_like "xml adapter with multiple mappings",
|
|
279
|
-
Lutaml::Xml::Adapter::
|
|
277
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml)
|
|
280
278
|
end
|
|
281
279
|
end
|
|
282
280
|
end
|
|
@@ -306,7 +304,7 @@ RSpec.describe MultipleMapping do
|
|
|
306
304
|
context "with XML format" do
|
|
307
305
|
shared_examples "xml adapter with custom methods" do |_adapter_class|
|
|
308
306
|
before do
|
|
309
|
-
Lutaml::Model::Config.xml_adapter = Lutaml::Xml::Adapter::
|
|
307
|
+
Lutaml::Model::Config.xml_adapter = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
310
308
|
end
|
|
311
309
|
|
|
312
310
|
let(:xml_with_alternate) do
|
|
@@ -352,20 +350,20 @@ RSpec.describe MultipleMapping do
|
|
|
352
350
|
|
|
353
351
|
context "with Nokogiri adapter" do
|
|
354
352
|
it_behaves_like "xml adapter with custom methods",
|
|
355
|
-
Lutaml::Xml::Adapter::
|
|
353
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
356
354
|
end
|
|
357
355
|
|
|
358
356
|
context "with Ox adapter" do
|
|
359
357
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
360
358
|
it_behaves_like "xml adapter with custom methods",
|
|
361
|
-
Lutaml::Xml::Adapter::
|
|
359
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
362
360
|
end
|
|
363
361
|
end
|
|
364
362
|
|
|
365
363
|
context "with Rexml adapter" do
|
|
366
364
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
367
365
|
it_behaves_like "xml adapter with custom methods",
|
|
368
|
-
Lutaml::Xml::Adapter::
|
|
366
|
+
Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml)
|
|
369
367
|
end
|
|
370
368
|
end
|
|
371
369
|
end
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
require_relative "../../../lib/lutaml/model"
|
|
5
|
-
require "lutaml/xml/adapter/
|
|
6
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
7
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
8
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
5
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
9
6
|
require_relative "../../fixtures/sample_model"
|
|
10
7
|
require_relative "../../support/xml_mapping_namespaces"
|
|
11
8
|
|
|
@@ -188,25 +185,25 @@ RSpec.describe "OrderedContent" do
|
|
|
188
185
|
end
|
|
189
186
|
end
|
|
190
187
|
|
|
191
|
-
describe Lutaml::Xml::Adapter::
|
|
188
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
192
189
|
it_behaves_like "ordered content behavior", described_class
|
|
193
190
|
end
|
|
194
191
|
|
|
195
|
-
describe Lutaml::Xml::Adapter::
|
|
192
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
196
193
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
197
194
|
it_behaves_like "ordered content behavior",
|
|
198
195
|
described_class
|
|
199
196
|
end
|
|
200
197
|
end
|
|
201
198
|
|
|
202
|
-
describe Lutaml::Xml::Adapter::
|
|
199
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
203
200
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
204
201
|
it_behaves_like "ordered content behavior",
|
|
205
202
|
described_class
|
|
206
203
|
end
|
|
207
204
|
end
|
|
208
205
|
|
|
209
|
-
describe Lutaml::Xml::Adapter::
|
|
206
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
210
207
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
211
208
|
it_behaves_like "ordered content behavior",
|
|
212
209
|
described_class
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
|
-
require "lutaml/xml/adapter/
|
|
5
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
6
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
7
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
4
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
8
5
|
|
|
9
6
|
RSpec.describe "Processing Instructions" do
|
|
10
7
|
describe "XmlElement data model" do
|
|
@@ -156,7 +153,7 @@ RSpec.describe "Processing Instructions" do
|
|
|
156
153
|
xml_element.add_processing_instruction("rfc", 'strict="yes"')
|
|
157
154
|
xml_element.add_processing_instruction("rfc", 'compact="yes"')
|
|
158
155
|
|
|
159
|
-
adapter = Lutaml::Xml::Adapter::
|
|
156
|
+
adapter = Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri).new(xml_element)
|
|
160
157
|
xml = adapter.to_xml(mapper_class: doc_class, declaration: true)
|
|
161
158
|
|
|
162
159
|
expect(xml).to include('<?rfc strict="yes"?>')
|
|
@@ -350,23 +347,23 @@ RSpec.describe "Processing Instructions" do
|
|
|
350
347
|
end
|
|
351
348
|
end
|
|
352
349
|
|
|
353
|
-
describe Lutaml::Xml::Adapter::
|
|
350
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
354
351
|
it_behaves_like "PI round-trip behavior", described_class
|
|
355
352
|
end
|
|
356
353
|
|
|
357
|
-
describe Lutaml::Xml::Adapter::
|
|
354
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox) do
|
|
358
355
|
if TestAdapterConfig.adapter_enabled?(:ox)
|
|
359
356
|
it_behaves_like "PI round-trip behavior", described_class
|
|
360
357
|
end
|
|
361
358
|
end
|
|
362
359
|
|
|
363
|
-
describe Lutaml::Xml::Adapter::
|
|
360
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga) do
|
|
364
361
|
if TestAdapterConfig.adapter_enabled?(:oga)
|
|
365
362
|
it_behaves_like "PI round-trip behavior", described_class
|
|
366
363
|
end
|
|
367
364
|
end
|
|
368
365
|
|
|
369
|
-
describe Lutaml::Xml::Adapter::
|
|
366
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml) do
|
|
370
367
|
if TestAdapterConfig.adapter_enabled?(:rexml)
|
|
371
368
|
it_behaves_like "PI round-trip behavior", described_class
|
|
372
369
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
require_relative "../../../../lib/lutaml/model"
|
|
5
|
-
require "lutaml/xml/adapter/
|
|
5
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
6
|
|
|
7
7
|
# Runtimes without a source compiler (Opal) define the attribute
|
|
8
8
|
# accessors and the state-defaults seed from blocks instead of a String
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
require_relative "../../../../lib/lutaml/model"
|
|
5
|
-
require "lutaml/xml/adapter/
|
|
5
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
6
|
|
|
7
7
|
# Specs for Lutaml::Model::Serialize::Builder — the module that gives
|
|
8
8
|
# Serializable the `Klass.new do |x| ... end` block syntax.
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
require "lutaml/model"
|
|
5
5
|
require "lutaml/xml"
|
|
6
|
-
require "lutaml/xml/adapter/
|
|
7
|
-
require "lutaml/xml/adapter/ox_adapter"
|
|
8
|
-
require "lutaml/xml/adapter/oga_adapter"
|
|
9
|
-
require "lutaml/xml/adapter/rexml_adapter"
|
|
6
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
10
7
|
|
|
11
8
|
# Regression tests for BaseAdapter refactoring.
|
|
12
9
|
# Each test guards a specific bug fix to prevent re-introduction.
|
|
@@ -134,18 +131,18 @@ end
|
|
|
134
131
|
|
|
135
132
|
RSpec.describe Lutaml::Xml::Adapter::BaseAdapter do
|
|
136
133
|
context "with NokogiriAdapter" do
|
|
137
|
-
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::
|
|
134
|
+
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri)
|
|
138
135
|
end
|
|
139
136
|
|
|
140
137
|
context "with OxAdapter" do
|
|
141
|
-
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::
|
|
138
|
+
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:ox)
|
|
142
139
|
end
|
|
143
140
|
|
|
144
141
|
context "with OgaAdapter" do
|
|
145
|
-
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::
|
|
142
|
+
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:oga)
|
|
146
143
|
end
|
|
147
144
|
|
|
148
145
|
context "with RexmlAdapter" do
|
|
149
|
-
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::
|
|
146
|
+
it_behaves_like "base adapter regressions", Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:rexml)
|
|
150
147
|
end
|
|
151
148
|
end
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
|
-
require "lutaml/xml/adapter/
|
|
5
|
-
require "lutaml/xml/adapter/nokogiri_adapter"
|
|
4
|
+
require "lutaml/xml/adapter/moxml_adapter"
|
|
6
5
|
|
|
7
6
|
# A failed parse reaches the empty-document guard as a document with no
|
|
8
7
|
# root, indistinguishable from genuinely empty input. The engine's parse
|
|
@@ -18,7 +17,7 @@ require "lutaml/xml/adapter/nokogiri_adapter"
|
|
|
18
17
|
# nothing to recover into (whitespace-only) still reach the guard,
|
|
19
18
|
# carrying the recovery diagnostic.
|
|
20
19
|
RSpec.describe "empty-document errors surface engine parse diagnostics" do
|
|
21
|
-
describe Lutaml::Xml::Adapter::
|
|
20
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:leptris) do
|
|
22
21
|
it "returns a recovered tree for recoverable malformations (moxml#369)" do
|
|
23
22
|
version = Gem.loaded_specs.fetch("moxml").version
|
|
24
23
|
recovered = version >= Gem::Version.new("0.5.131")
|
|
@@ -37,7 +36,7 @@ RSpec.describe "empty-document errors surface engine parse diagnostics" do
|
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
|
|
40
|
-
describe Lutaml::Xml::Adapter::
|
|
39
|
+
describe Lutaml::Xml::Adapter::MoxmlAdapter.for_engine(:nokogiri) do
|
|
41
40
|
it "keeps the plain empty-document message when the engine reported nothing" do
|
|
42
41
|
expect do
|
|
43
42
|
described_class.parse("")
|