moxml 0.5.177 → 0.6.0
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/workflows/nightly-fuzz.yml +0 -14
- data/.github/workflows/performance-release.yml +0 -13
- data/.github/workflows/performance.yml +0 -17
- data/.github/workflows/rake.yml +0 -38
- data/.github/workflows/round-trip.yml +0 -45
- data/.github/workflows/windows.yml +0 -12
- data/Gemfile +4 -14
- data/README.adoc +5 -388
- data/Rakefile +2 -179
- data/docs/_references/processing-model.adoc +3 -2
- data/lib/moxml/adapter/customized_oga.rb +6 -4
- data/lib/moxml/adapter/customized_rexml.rb +5 -3
- data/lib/moxml/adapter/headed_ox.rb +0 -2
- data/lib/moxml/adapter/leptris.rb +43 -7
- data/lib/moxml/adapter/libxml.rb +0 -2
- data/lib/moxml/adapter/nokogiri.rb +0 -2
- data/lib/moxml/adapter/ox.rb +0 -2
- data/lib/moxml/adapter/rexml.rb +1 -3
- data/lib/moxml/adapter.rb +1 -6
- data/lib/moxml/config.rb +0 -17
- data/lib/moxml/entity_registry.rb +1 -5
- data/lib/moxml/native_attachment.rb +1 -3
- data/lib/moxml/version.rb +1 -1
- data/lib/moxml.rb +1 -2
- data/spec/moxml/adapter/platform_spec.rb +2 -47
- data/spec/moxml/adapter_capabilities_spec.rb +25 -0
- data/spec/moxml/native_attachment_spec.rb +4 -50
- data/spec/moxml/signature/edge_cases_spec.rb +0 -1
- data/spec/spec_helper.rb +13 -31
- metadata +2 -22
- data/.github/workflows/opal.yml +0 -61
- data/.gitmodules +0 -6
- data/lib/compat/opal/moxml_boot.rb +0 -68
- 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 -77
- data/lib/moxml/entity_registry_opal_data.rb +0 -2138
- data/lib/moxml/native_attachment/opal.rb +0 -38
- data/spec/moxml/native_attachment/opal_spec.rb +0 -66
- data/spec/moxml/opal_oga_adapter_spec.rb +0 -20
- data/spec/moxml/opal_oga_features_spec.rb +0 -212
- data/spec/moxml/opal_oga_smoke_spec.rb +0 -35
- data/spec/moxml/opal_rexml_adapter_spec.rb +0 -14
- data/spec/moxml/opal_smoke_spec.rb +0 -61
- data/spec/moxml/reference_opal_spec.rb +0 -29
- data/spec/moxml/signature_autoload_spec.rb +0 -52
- data/spec/support/opal.rb +0 -16
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require "ffi"
|
|
4
4
|
|
|
5
|
-
return if RUBY_ENGINE == "opal"
|
|
6
|
-
|
|
7
5
|
require "stringio"
|
|
8
6
|
require "leptris"
|
|
9
7
|
|
|
@@ -341,6 +339,17 @@ module Moxml
|
|
|
341
339
|
# (Leptris::VERSION), +engine_version+ is libleptris's own
|
|
342
340
|
# (the leptris_version() C face, face-probed — nil on a
|
|
343
341
|
# binding without it).
|
|
342
|
+
#
|
|
343
|
+
# Support faces are DESCRIPTOR-AUTHORITATIVE (leptris-ruby#572
|
|
344
|
+
# bridge, engine leptris#1905): a face answers true only when
|
|
345
|
+
# the ENGINE's capability bitset serves it AND the binding
|
|
346
|
+
# exposes it — a face the engine serves but the binding has
|
|
347
|
+
# not bridged is indistinguishable from absent without the
|
|
348
|
+
# bitset. On a binding without the bridge the probe answer
|
|
349
|
+
# stands alone (never narrowed by missing data). The bit
|
|
350
|
+
# values decode the engine's LEPTRIS_CAP_* layout (bits
|
|
351
|
+
# append per the engine's contract; the binding re-encodes
|
|
352
|
+
# nothing, the model names them).
|
|
344
353
|
def capabilities
|
|
345
354
|
@capabilities ||= {
|
|
346
355
|
binding_version: ::Leptris::VERSION,
|
|
@@ -353,17 +362,44 @@ module Moxml
|
|
|
353
362
|
add_element_full: ADD_ELEMENT_FULL,
|
|
354
363
|
native_strings_utf8: !NATIVE_STRINGS_UTF8.nil?,
|
|
355
364
|
native_mutations_coherent: !NATIVE_MUTATIONS_COHERENT.nil?,
|
|
356
|
-
native_entity_refs:
|
|
365
|
+
native_entity_refs:
|
|
366
|
+
!NATIVE_ENTITY_REFS.nil? && engine_serves?(:entity_ref_nodes),
|
|
357
367
|
native_bulk_fixed: !NATIVE_BULK_FIXED.nil?,
|
|
358
368
|
native_plan_structs: NATIVE_PLAN_STRUCTS,
|
|
359
369
|
native_plan_typed: NATIVE_PLAN_TYPED,
|
|
360
|
-
digest: DIGEST_SUPPORTED,
|
|
361
|
-
xsd: XSD_SUPPORTED,
|
|
362
|
-
relaxng: RELAXNG_SUPPORTED,
|
|
363
|
-
xslt: XSLT_SUPPORTED,
|
|
370
|
+
digest: DIGEST_SUPPORTED && engine_serves?(:digest),
|
|
371
|
+
xsd: XSD_SUPPORTED && engine_serves?(:xsd),
|
|
372
|
+
relaxng: RELAXNG_SUPPORTED && engine_serves?(:relaxng),
|
|
373
|
+
xslt: XSLT_SUPPORTED && engine_serves?(:xslt),
|
|
364
374
|
}.freeze
|
|
365
375
|
end
|
|
366
376
|
|
|
377
|
+
# The engine's capability descriptor (raw bitset), or nil on
|
|
378
|
+
# a binding without the bridge. The bit values are the
|
|
379
|
+
# engine's LEPTRIS_CAP_* layout at descriptor version 1 —
|
|
380
|
+
# bits append, so the decode stays valid on later sets.
|
|
381
|
+
ENGINE_CAPS_BITS = {
|
|
382
|
+
digest: 1 << 9,
|
|
383
|
+
xsd: 1 << 10,
|
|
384
|
+
relaxng: 1 << 12,
|
|
385
|
+
xslt: 1 << 14,
|
|
386
|
+
entity_ref_nodes: 1 << 24,
|
|
387
|
+
}.freeze
|
|
388
|
+
|
|
389
|
+
def engine_serves?(face)
|
|
390
|
+
descriptor = engine_descriptor
|
|
391
|
+
return true unless descriptor
|
|
392
|
+
|
|
393
|
+
descriptor[:caps].anybits?(ENGINE_CAPS_BITS.fetch(face))
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def engine_descriptor
|
|
397
|
+
@engine_descriptor ||=
|
|
398
|
+
if defined?(::Leptris::XML.capabilities)
|
|
399
|
+
::Leptris::XML.capabilities
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
367
403
|
# WeakMap has no #clear — 0.5.100's valve crashed every parse
|
|
368
404
|
# crossing the cap on 3.4+ (NoMethodError). Replace the
|
|
369
405
|
# registry wholesale, type-preserving: the WeakMap flavor
|
data/lib/moxml/adapter/libxml.rb
CHANGED
data/lib/moxml/adapter/ox.rb
CHANGED
data/lib/moxml/adapter/rexml.rb
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
require "rexml/document"
|
|
4
4
|
require "rexml/xpath"
|
|
5
5
|
require "rexml/streamlistener"
|
|
6
|
-
require "set"
|
|
7
|
-
require "stringio" if RUBY_ENGINE == "opal"
|
|
6
|
+
require "set"
|
|
8
7
|
|
|
9
8
|
module Moxml
|
|
10
9
|
module Adapter
|
|
@@ -697,7 +696,6 @@ module Moxml
|
|
|
697
696
|
end
|
|
698
697
|
|
|
699
698
|
def serialize(node, options = {})
|
|
700
|
-
output = StringIO.new("") if RUBY_ENGINE == "opal"
|
|
701
699
|
output ||= +""
|
|
702
700
|
|
|
703
701
|
if node.is_a?(::REXML::Document)
|
data/lib/moxml/adapter.rb
CHANGED
|
@@ -29,8 +29,6 @@ module Moxml
|
|
|
29
29
|
# canonical XML parser for the JavaScript runtime. REXML is also pure Ruby
|
|
30
30
|
# but requires extensive runtime compat shims (regex features like /n,
|
|
31
31
|
# \u{...}, (?-mix:...) don't transpile cleanly), so it is opt-in only.
|
|
32
|
-
OPAL_AVAILABLE_ADAPTERS = %i[oga rexml].freeze
|
|
33
|
-
|
|
34
32
|
# Registry mapping adapter names to their class name suffixes.
|
|
35
33
|
# Special cases (like :headed_ox → "HeadedOx") live here instead of
|
|
36
34
|
# a case statement, keeping the dispatch open for extension.
|
|
@@ -78,7 +76,7 @@ module Moxml
|
|
|
78
76
|
end
|
|
79
77
|
|
|
80
78
|
def platform_adapters
|
|
81
|
-
|
|
79
|
+
AVAILABLE_ADAPTERS
|
|
82
80
|
end
|
|
83
81
|
|
|
84
82
|
private
|
|
@@ -99,9 +97,6 @@ module Moxml
|
|
|
99
97
|
end
|
|
100
98
|
|
|
101
99
|
def require_adapter(name)
|
|
102
|
-
# Opal pre-loads all dependencies via the Rakefile; skip runtime require.
|
|
103
|
-
return if RUBY_ENGINE == "opal"
|
|
104
|
-
|
|
105
100
|
require "moxml/adapter/base"
|
|
106
101
|
require "moxml/adapter/#{name}"
|
|
107
102
|
rescue LoadError
|
data/lib/moxml/config.rb
CHANGED
|
@@ -16,8 +16,6 @@ module Moxml
|
|
|
16
16
|
# its C extension and cannot load there; otherwise rexml.
|
|
17
17
|
PREFERRED_ADAPTER = :leptris
|
|
18
18
|
FALLBACK_ADAPTER = :nokogiri
|
|
19
|
-
OPAL_DEFAULT_ADAPTER = :oga
|
|
20
|
-
OPAL_FALLBACK_ADAPTER = :rexml
|
|
21
19
|
|
|
22
20
|
# Entity loading modes:
|
|
23
21
|
# - :required - Must load entities, raise error if unavailable (default)
|
|
@@ -45,8 +43,6 @@ module Moxml
|
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
def runtime_default_adapter
|
|
48
|
-
return opal_runtime_adapter if RUBY_ENGINE == "opal"
|
|
49
|
-
|
|
50
46
|
preferred = leptris_preferred_available?
|
|
51
47
|
return PREFERRED_ADAPTER if preferred == true
|
|
52
48
|
|
|
@@ -68,19 +64,6 @@ module Moxml
|
|
|
68
64
|
detect_loaded_adapter || FALLBACK_ADAPTER
|
|
69
65
|
end
|
|
70
66
|
|
|
71
|
-
# Stock oga requires its C extension, so under Opal the oga
|
|
72
|
-
# adapter can only come from the vendored pure-Ruby fork — a
|
|
73
|
-
# repo-only artifact the released gem does not ship. Bundles
|
|
74
|
-
# that compiled it in (moxml's own harness) keep oga; everyone
|
|
75
|
-
# else gets the rexml adapter, whose Opal compat ships in-gem.
|
|
76
|
-
# `defined?` is safe here: this branch never runs under MRI,
|
|
77
|
-
# where it would trigger autoload resolution.
|
|
78
|
-
def opal_runtime_adapter
|
|
79
|
-
return OPAL_DEFAULT_ADAPTER if defined?(Moxml::Adapter::Oga)
|
|
80
|
-
|
|
81
|
-
OPAL_FALLBACK_ADAPTER
|
|
82
|
-
end
|
|
83
|
-
|
|
84
67
|
# True when the leptris gem is installed AND meets the adapter's
|
|
85
68
|
# binding floor (issue #149; 1.9.32 — traverse bounding #89,
|
|
86
69
|
# built-docs parts #91, and every capability surface the adapter
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "json"
|
|
3
|
+
require "json"
|
|
4
4
|
require "set"
|
|
5
5
|
|
|
6
6
|
module Moxml
|
|
@@ -107,10 +107,6 @@ module Moxml
|
|
|
107
107
|
# Load entity data from bundled gem data or local file
|
|
108
108
|
# @return [Hash{String => String}]
|
|
109
109
|
def load_entity_data
|
|
110
|
-
if RUBY_ENGINE == "opal"
|
|
111
|
-
return OPAL_ENTITY_DATA
|
|
112
|
-
end
|
|
113
|
-
|
|
114
110
|
# Try multiple paths in order of priority
|
|
115
111
|
paths_to_try = []
|
|
116
112
|
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Moxml
|
|
4
4
|
class NativeAttachment
|
|
5
|
-
autoload :Opal, "moxml/native_attachment/opal"
|
|
6
5
|
autoload :Native, "moxml/native_attachment/native"
|
|
7
6
|
|
|
8
7
|
def self.default_backend
|
|
9
|
-
|
|
10
|
-
const_get(constant).new
|
|
8
|
+
const_get(:Native).new
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
attr_reader :backend
|
data/lib/moxml/version.rb
CHANGED
data/lib/moxml.rb
CHANGED
|
@@ -91,7 +91,6 @@ module Moxml
|
|
|
91
91
|
autoload :EntityRegistry, "moxml/entity_registry"
|
|
92
92
|
# Opal has no autoload; the compat boot file requires this eagerly
|
|
93
93
|
# alongside the registry.
|
|
94
|
-
autoload :EntityRegistryOpalData, "moxml/entity_registry_opal_data"
|
|
95
94
|
autoload :NativeAttachment, "moxml/native_attachment"
|
|
96
95
|
autoload :XmlUtils, "moxml/xml_utils"
|
|
97
96
|
autoload :XmlEmitter, "moxml/xml_emitter"
|
|
@@ -101,7 +100,7 @@ module Moxml
|
|
|
101
100
|
autoload :Adapter, "moxml/adapter"
|
|
102
101
|
autoload :XPath, "moxml/xpath"
|
|
103
102
|
autoload :SAX, "moxml/sax"
|
|
104
|
-
autoload :Signature, "moxml/signature"
|
|
103
|
+
autoload :Signature, "moxml/signature"
|
|
105
104
|
autoload :C14n, "moxml/c14n"
|
|
106
105
|
autoload :Reference, "moxml/reference"
|
|
107
106
|
autoload :XSLT, "moxml/xslt"
|
|
@@ -9,7 +9,7 @@ RSpec.describe Moxml::Adapter do
|
|
|
9
9
|
:rexml, :ox)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
it "uses the AVAILABLE_ADAPTERS constant
|
|
12
|
+
it "uses the AVAILABLE_ADAPTERS constant" do
|
|
13
13
|
expect(described_class.platform_adapters).to eq(Moxml::Adapter::AVAILABLE_ADAPTERS)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -19,49 +19,9 @@ RSpec.describe Moxml::Adapter do
|
|
|
19
19
|
expect(described_class.available?(:oga)).to be true
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
it "returns true for :nokogiri
|
|
22
|
+
it "returns true for :nokogiri" do
|
|
23
23
|
expect(described_class.available?(:nokogiri)).to be true
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
context "when Opal platform adapters are in effect" do
|
|
27
|
-
before do
|
|
28
|
-
allow(described_class).to receive(:platform_adapters)
|
|
29
|
-
.and_return(Moxml::Adapter::OPAL_AVAILABLE_ADAPTERS)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "returns false for :nokogiri" do
|
|
33
|
-
expect(described_class.available?(:nokogiri)).to be false
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "returns true for :oga" do
|
|
37
|
-
expect(described_class.available?(:oga)).to be true
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "returns true for :rexml" do
|
|
41
|
-
expect(described_class.available?(:rexml)).to be true
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe ".load" do
|
|
47
|
-
context "when Opal platform adapters are in effect" do
|
|
48
|
-
before do
|
|
49
|
-
allow(described_class).to receive(:platform_adapters)
|
|
50
|
-
.and_return(Moxml::Adapter::OPAL_AVAILABLE_ADAPTERS)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "raises AdapterError for :nokogiri" do
|
|
54
|
-
expect { described_class.load(:nokogiri) }.to raise_error(
|
|
55
|
-
Moxml::AdapterError, /not available on this platform/
|
|
56
|
-
)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "OPAL_AVAILABLE_ADAPTERS" do
|
|
62
|
-
it "lists :oga as the primary Opal adapter, with :rexml as opt-in" do
|
|
63
|
-
expect(Moxml::Adapter::OPAL_AVAILABLE_ADAPTERS).to eq(%i[oga rexml])
|
|
64
|
-
end
|
|
65
25
|
end
|
|
66
26
|
|
|
67
27
|
describe "CONST_NAME_MAP" do
|
|
@@ -101,10 +61,5 @@ RSpec.describe Moxml::Adapter do
|
|
|
101
61
|
expect(Gem::Version.new(Leptris::VERSION))
|
|
102
62
|
.to be >= Gem::Version.new(adapter::MINIMUM_BINDING_VERSION)
|
|
103
63
|
end
|
|
104
|
-
|
|
105
|
-
it "OPAL_DEFAULT_ADAPTER is a member of OPAL_AVAILABLE_ADAPTERS" do
|
|
106
|
-
expect(Moxml::Adapter::OPAL_AVAILABLE_ADAPTERS)
|
|
107
|
-
.to include(Moxml::Config::OPAL_DEFAULT_ADAPTER)
|
|
108
|
-
end
|
|
109
64
|
end
|
|
110
65
|
end
|
|
@@ -52,6 +52,31 @@ RSpec.describe "engine capability report" do
|
|
|
52
52
|
expect(caps[:xslt]).to be(true)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# leptris-ruby#572: the binding bridges the engine's capability
|
|
56
|
+
# descriptor, and the support faces answer its verdict ANDed with
|
|
57
|
+
# the binding probe — a face the engine serves but the binding has
|
|
58
|
+
# not bridged is not "true" (the half-face trap the version-gate
|
|
59
|
+
# class could not see).
|
|
60
|
+
it "answers the support faces from the engine descriptor bitset" do
|
|
61
|
+
skip "requires the binding's descriptor bridge (leptris 1.9.396+)" unless
|
|
62
|
+
defined?(Leptris::XML.capabilities)
|
|
63
|
+
|
|
64
|
+
caps = Moxml::Adapter::Leptris.capabilities
|
|
65
|
+
descriptor = Leptris::XML.capabilities
|
|
66
|
+
expect(descriptor[:descriptor_version]).to be(1)
|
|
67
|
+
{
|
|
68
|
+
digest: 1 << 9,
|
|
69
|
+
xsd: 1 << 10,
|
|
70
|
+
relaxng: 1 << 12,
|
|
71
|
+
xslt: 1 << 14,
|
|
72
|
+
}.each do |face, bit|
|
|
73
|
+
served = descriptor[:caps].anybits?(bit)
|
|
74
|
+
expect(caps[face]).to eql(served),
|
|
75
|
+
"#{face} must answer the engine bitset's verdict " \
|
|
76
|
+
"(ANDed with the binding probe)"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
55
80
|
it "is memoized — repeated queries answer the same frozen object" do
|
|
56
81
|
expect(Moxml::Adapter::Leptris.capabilities)
|
|
57
82
|
.to equal(Moxml::Adapter::Leptris.capabilities)
|
|
@@ -6,15 +6,7 @@ require "spec_helper"
|
|
|
6
6
|
|
|
7
7
|
RSpec.describe Moxml::NativeAttachment do
|
|
8
8
|
describe ".default_backend" do
|
|
9
|
-
it "uses the
|
|
10
|
-
stub_const("RUBY_ENGINE", "opal")
|
|
11
|
-
|
|
12
|
-
expect(described_class.default_backend).to be_a(described_class::Opal)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "uses the native backend under non-Opal Ruby engines" do
|
|
16
|
-
stub_const("RUBY_ENGINE", "ruby")
|
|
17
|
-
|
|
9
|
+
it "uses the native backend" do
|
|
18
10
|
expect(described_class.default_backend).to be_a(described_class::Native)
|
|
19
11
|
end
|
|
20
12
|
end
|
|
@@ -69,13 +61,7 @@ RSpec.describe Moxml::NativeAttachment do
|
|
|
69
61
|
end
|
|
70
62
|
|
|
71
63
|
it "uses the selected runtime backend" do
|
|
72
|
-
|
|
73
|
-
described_class::Opal
|
|
74
|
-
else
|
|
75
|
-
described_class::Native
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
expect(attachments.backend).to be_a(expected_class)
|
|
64
|
+
expect(attachments.backend).to be_a(described_class::Native)
|
|
79
65
|
end
|
|
80
66
|
end
|
|
81
67
|
|
|
@@ -109,7 +95,7 @@ RSpec.describe Moxml::NativeAttachment do
|
|
|
109
95
|
expect(stdout).to eq("true\n")
|
|
110
96
|
end
|
|
111
97
|
|
|
112
|
-
it "registers backend
|
|
98
|
+
it "registers the backend implementation with a require-style autoload path" do
|
|
113
99
|
stdout, stderr, status = Open3.capture3(
|
|
114
100
|
ruby,
|
|
115
101
|
"-I",
|
|
@@ -118,16 +104,12 @@ RSpec.describe Moxml::NativeAttachment do
|
|
|
118
104
|
<<~RUBY,
|
|
119
105
|
require "moxml/native_attachment"
|
|
120
106
|
|
|
121
|
-
puts Moxml::NativeAttachment.autoload?(:Opal)
|
|
122
107
|
puts Moxml::NativeAttachment.autoload?(:Native)
|
|
123
108
|
RUBY
|
|
124
109
|
)
|
|
125
110
|
|
|
126
111
|
expect(status.success?).to be(true), stderr
|
|
127
|
-
expect(stdout).to eq(
|
|
128
|
-
"moxml/native_attachment/opal\n" \
|
|
129
|
-
"moxml/native_attachment/native\n",
|
|
130
|
-
)
|
|
112
|
+
expect(stdout).to eq("moxml/native_attachment/native\n")
|
|
131
113
|
end
|
|
132
114
|
|
|
133
115
|
it "loads the native backend lazily when selected" do
|
|
@@ -142,7 +124,6 @@ RSpec.describe Moxml::NativeAttachment do
|
|
|
142
124
|
puts $LOADED_FEATURES.grep(%r{/native_attachment/native\.rb\z}).empty?
|
|
143
125
|
puts Moxml::NativeAttachment.new.backend.class
|
|
144
126
|
puts !$LOADED_FEATURES.grep(%r{/native_attachment/native\.rb\z}).empty?
|
|
145
|
-
puts $LOADED_FEATURES.grep(%r{/native_attachment/opal\.rb\z}).empty?
|
|
146
127
|
RUBY
|
|
147
128
|
)
|
|
148
129
|
|
|
@@ -150,33 +131,6 @@ RSpec.describe Moxml::NativeAttachment do
|
|
|
150
131
|
expect(stdout).to eq(
|
|
151
132
|
"true\n" \
|
|
152
133
|
"Moxml::NativeAttachment::Native\n" \
|
|
153
|
-
"true\n" \
|
|
154
|
-
"true\n",
|
|
155
|
-
)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "does not load the native backend when Opal is selected" do
|
|
159
|
-
stdout, stderr, status = Open3.capture3(
|
|
160
|
-
ruby,
|
|
161
|
-
"-I",
|
|
162
|
-
lib_dir,
|
|
163
|
-
"-e",
|
|
164
|
-
<<~'RUBY',
|
|
165
|
-
Object.send(:remove_const, :RUBY_ENGINE)
|
|
166
|
-
RUBY_ENGINE = "opal"
|
|
167
|
-
|
|
168
|
-
require "moxml/native_attachment"
|
|
169
|
-
|
|
170
|
-
puts Moxml::NativeAttachment.autoload?(:Native)
|
|
171
|
-
puts Moxml::NativeAttachment.new.backend.class
|
|
172
|
-
puts $LOADED_FEATURES.grep(%r{/native_attachment/native\.rb\z}).empty?
|
|
173
|
-
RUBY
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
expect(status.success?).to be(true), stderr
|
|
177
|
-
expect(stdout).to eq(
|
|
178
|
-
"moxml/native_attachment/native\n" \
|
|
179
|
-
"Moxml::NativeAttachment::Opal\n" \
|
|
180
134
|
"true\n",
|
|
181
135
|
)
|
|
182
136
|
end
|
|
@@ -253,7 +253,6 @@ RSpec.describe "Moxml::Signature edge cases and defense" do
|
|
|
253
253
|
end
|
|
254
254
|
|
|
255
255
|
describe "adapter portability" do
|
|
256
|
-
# Skip on Opal — adapter switching is the whole point of moxml.
|
|
257
256
|
it "verifies a signature produced under one adapter with another", :adapter_portability do
|
|
258
257
|
skip "Only Nokogiri available in CI" unless defined?(Nokogiri)
|
|
259
258
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# SimpleCov must be loaded before application code
|
|
4
|
-
if ENV.fetch("COVERAGE", nil) == "true"
|
|
4
|
+
if ENV.fetch("COVERAGE", nil) == "true"
|
|
5
5
|
require "simplecov"
|
|
6
6
|
|
|
7
7
|
SimpleCov.start do
|
|
@@ -25,25 +25,21 @@ if ENV.fetch("COVERAGE", nil) == "true" && RUBY_ENGINE != "opal"
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
require "moxml"
|
|
28
|
-
require "nokogiri"
|
|
28
|
+
require "nokogiri"
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
require f
|
|
39
|
-
end
|
|
30
|
+
# Load shared examples from new locations
|
|
31
|
+
Dir[File.expand_path("integration/shared_examples/**/*.rb",
|
|
32
|
+
__dir__)].each do |f|
|
|
33
|
+
require f
|
|
34
|
+
end
|
|
35
|
+
Dir[File.expand_path("moxml/adapter/shared_examples/**/*.rb",
|
|
36
|
+
__dir__)].each do |f|
|
|
37
|
+
require f
|
|
40
38
|
end
|
|
41
39
|
Dir[File.expand_path("support/**/*.rb", __dir__)].each { |f| require f }
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Dir[File.expand_path("examples/*.rb", __dir__)].each { |f| require f }
|
|
46
|
-
end
|
|
41
|
+
Dir[File.expand_path("performance/*.rb", __dir__)].each { |f| require f }
|
|
42
|
+
Dir[File.expand_path("examples/*.rb", __dir__)].each { |f| require f }
|
|
47
43
|
|
|
48
44
|
# Clear XPath caches immediately to ensure fresh compilation
|
|
49
45
|
# This is critical when code changes affect compiled XPath expressions
|
|
@@ -83,19 +79,6 @@ RSpec.configure do |config|
|
|
|
83
79
|
# Configure to skip examples unless explicitly run
|
|
84
80
|
config.filter_run_excluding examples: true unless ENV["RUN_EXAMPLES"]
|
|
85
81
|
|
|
86
|
-
# Under Opal, exclude specs that require native-only adapters or filesystem
|
|
87
|
-
if RUBY_ENGINE == "opal"
|
|
88
|
-
config.filter_run_excluding(
|
|
89
|
-
:native_adapter,
|
|
90
|
-
:native_fs,
|
|
91
|
-
:subprocess,
|
|
92
|
-
:xpath_native,
|
|
93
|
-
:performance,
|
|
94
|
-
:examples,
|
|
95
|
-
:consistency,
|
|
96
|
-
)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
82
|
config.order = :random
|
|
100
83
|
Kernel.srand config.seed
|
|
101
84
|
end
|
|
@@ -105,8 +88,7 @@ Moxml.configure do |config|
|
|
|
105
88
|
# reproducible regardless of whether the local environment has a
|
|
106
89
|
# leptris new enough to win the runtime-default probe. Leptris gets
|
|
107
90
|
# full coverage through its explicit adapter/integration matrices.
|
|
108
|
-
config.adapter =
|
|
91
|
+
config.adapter = Moxml::Config::FALLBACK_ADAPTER
|
|
109
92
|
config.strict_parsing = true
|
|
110
93
|
config.default_encoding = "UTF-8"
|
|
111
|
-
config.entity_load_mode = :optional if RUBY_ENGINE == "opal"
|
|
112
94
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: moxml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
Moxml is a unified XML manipulation library that provides a common API
|
|
@@ -25,7 +25,6 @@ files:
|
|
|
25
25
|
- ".github/workflows/dependent-tests.yml"
|
|
26
26
|
- ".github/workflows/docs.yml"
|
|
27
27
|
- ".github/workflows/nightly-fuzz.yml"
|
|
28
|
-
- ".github/workflows/opal.yml"
|
|
29
28
|
- ".github/workflows/performance-release.yml"
|
|
30
29
|
- ".github/workflows/performance.yml"
|
|
31
30
|
- ".github/workflows/rake.yml"
|
|
@@ -33,7 +32,6 @@ files:
|
|
|
33
32
|
- ".github/workflows/round-trip.yml"
|
|
34
33
|
- ".github/workflows/windows.yml"
|
|
35
34
|
- ".gitignore"
|
|
36
|
-
- ".gitmodules"
|
|
37
35
|
- ".rspec"
|
|
38
36
|
- ".rspec-opal"
|
|
39
37
|
- ".rubocop.yml"
|
|
@@ -134,13 +132,6 @@ files:
|
|
|
134
132
|
- examples/web_scraper/README.md
|
|
135
133
|
- examples/web_scraper/example_page.html
|
|
136
134
|
- examples/web_scraper/web_scraper.rb
|
|
137
|
-
- lib/compat/opal/moxml_boot.rb
|
|
138
|
-
- lib/compat/opal/rexml/namespace.rb
|
|
139
|
-
- lib/compat/opal/rexml/parsers/baseparser.rb
|
|
140
|
-
- lib/compat/opal/rexml/source.rb
|
|
141
|
-
- lib/compat/opal/rexml/text.rb
|
|
142
|
-
- lib/compat/opal/rexml/xmltokens.rb
|
|
143
|
-
- lib/compat/opal/rexml_compat.rb
|
|
144
135
|
- lib/moxml.rb
|
|
145
136
|
- lib/moxml/adapter.rb
|
|
146
137
|
- lib/moxml/adapter/base.rb
|
|
@@ -225,7 +216,6 @@ files:
|
|
|
225
216
|
- lib/moxml/entity/restorer.rb
|
|
226
217
|
- lib/moxml/entity_reference.rb
|
|
227
218
|
- lib/moxml/entity_registry.rb
|
|
228
|
-
- lib/moxml/entity_registry_opal_data.rb
|
|
229
219
|
- lib/moxml/error.rb
|
|
230
220
|
- lib/moxml/html_fragment.rb
|
|
231
221
|
- lib/moxml/lazy_bulk_rows.rb
|
|
@@ -234,7 +224,6 @@ files:
|
|
|
234
224
|
- lib/moxml/namespace.rb
|
|
235
225
|
- lib/moxml/native_attachment.rb
|
|
236
226
|
- lib/moxml/native_attachment/native.rb
|
|
237
|
-
- lib/moxml/native_attachment/opal.rb
|
|
238
227
|
- lib/moxml/node.rb
|
|
239
228
|
- lib/moxml/node_set.rb
|
|
240
229
|
- lib/moxml/plan.rb
|
|
@@ -569,7 +558,6 @@ files:
|
|
|
569
558
|
- spec/moxml/namespace_spec.rb
|
|
570
559
|
- spec/moxml/namespace_uri_validation_spec.rb
|
|
571
560
|
- spec/moxml/native_attachment/native_spec.rb
|
|
572
|
-
- spec/moxml/native_attachment/opal_spec.rb
|
|
573
561
|
- spec/moxml/native_attachment/shared_examples.rb
|
|
574
562
|
- spec/moxml/native_attachment_spec.rb
|
|
575
563
|
- spec/moxml/node_cache_spec.rb
|
|
@@ -577,17 +565,11 @@ files:
|
|
|
577
565
|
- spec/moxml/node_set_spec.rb
|
|
578
566
|
- spec/moxml/node_spec.rb
|
|
579
567
|
- spec/moxml/node_type_map_spec.rb
|
|
580
|
-
- spec/moxml/opal_oga_adapter_spec.rb
|
|
581
|
-
- spec/moxml/opal_oga_features_spec.rb
|
|
582
|
-
- spec/moxml/opal_oga_smoke_spec.rb
|
|
583
|
-
- spec/moxml/opal_rexml_adapter_spec.rb
|
|
584
|
-
- spec/moxml/opal_smoke_spec.rb
|
|
585
568
|
- spec/moxml/plan_conformance_spec.rb
|
|
586
569
|
- spec/moxml/plan_spec.rb
|
|
587
570
|
- spec/moxml/processing_instruction_spec.rb
|
|
588
571
|
- spec/moxml/readonly_parse_spec.rb
|
|
589
572
|
- spec/moxml/recover_mode_spec.rb
|
|
590
|
-
- spec/moxml/reference_opal_spec.rb
|
|
591
573
|
- spec/moxml/reference_spec.rb
|
|
592
574
|
- spec/moxml/relax_ng_spec.rb
|
|
593
575
|
- spec/moxml/sax/namespace_splitter_spec.rb
|
|
@@ -607,7 +589,6 @@ files:
|
|
|
607
589
|
- spec/moxml/signature/key_extractor_spec.rb
|
|
608
590
|
- spec/moxml/signature/model_spec.rb
|
|
609
591
|
- spec/moxml/signature/round_trip_spec.rb
|
|
610
|
-
- spec/moxml/signature_autoload_spec.rb
|
|
611
592
|
- spec/moxml/struct_plan_spec.rb
|
|
612
593
|
- spec/moxml/struct_plan_typed_spec.rb
|
|
613
594
|
- spec/moxml/text_spec.rb
|
|
@@ -665,7 +646,6 @@ files:
|
|
|
665
646
|
- spec/support/input_generator.rb
|
|
666
647
|
- spec/support/input_taxonomy.rb
|
|
667
648
|
- spec/support/model_coverage.rb
|
|
668
|
-
- spec/support/opal.rb
|
|
669
649
|
- spec/support/w3c_namespace_helpers.rb
|
|
670
650
|
- spec/support/xml_generator.rb
|
|
671
651
|
- spec/support/xml_matchers.rb
|