moxml 0.6.0 → 0.6.2

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: 66a0ad64613ea6615d2876c58138a4e492bf986f6c26f73482a0848e522aef1c
4
- data.tar.gz: 89333eb6b5d1cb8f74ca6fc5858bf60c596fb364157f11e20d812305f14d7571
3
+ metadata.gz: 18abacdd26eb9008a7b56f975db89664ae24375624ff403ae7d7125516d19bff
4
+ data.tar.gz: 31830c7093c075b8258388a1c317459479ff592d00c49b3cf76a4c5ed5ae1a9b
5
5
  SHA512:
6
- metadata.gz: eb40893e92da115a23d16699e9fd520dfcf5f0d3df708da67bedc907e794b2c75074f6b1fe4f44491df7e402cbbcd0fc81ff62504e7850f98796327dd9dfcb64
7
- data.tar.gz: be8ef56d26910c2d50b8e8a29b52c2bcb3b558b5eddffc4a07382c1407b97617a2706b17d888ac48e1433034724806cd2eea69d6aedf70e20dd29b3be9749d16
6
+ metadata.gz: 89de7734c64bc40ba40f07e2bb4d79a9ff5770c875d6f6df8b2437d9829d821ecbaeb0bd9b233f53f2e9fcbc64d5c43601fb206db4a6ff7d30472f0d9a110a5e
7
+ data.tar.gz: 22c17b78b3674c465f4bba84387627fa4831542acc84d3dfcf721f48886bdca3d994ae92f42145e60f73c5ff0f3578a3f28d929314d3093b10f9604a7a3779ef
@@ -2,8 +2,9 @@
2
2
 
3
3
  # Parse-path alias: rexml expands the built-in entities at parse time,
4
4
  # so parsed references are the facade's Moxml::Entity::Reference values.
5
- # Lifecycle: the :rexml adapter is Opal-only and dies with the Opal
6
- # surface (#489 phase 4); third-party engine, no upstream ask.
5
+ # Lifecycle: the :rexml adapter's fate governs this file; the
6
+ # adapter's historical Opal role ended with #489 phase 4. Third-party
7
+ # engine, no upstream ask.
7
8
 
8
9
  module Moxml
9
10
  module Adapter
@@ -3,8 +3,8 @@
3
3
  # Custom REXML formatter that fixes indentation and wrapping issues.
4
4
  # Engine gap (upstream rexml): REXML's Formatters::Pretty cannot be
5
5
  # configured to the facade's whitespace contract. Third-party engine,
6
- # no upstream ask; the :rexml adapter is Opal-only and dies with the
7
- # Opal surface (#489 phase 4).
6
+ # no upstream ask; the :rexml adapter's fate governs this file (its
7
+ # historical Opal role ended with #489 phase 4).
8
8
 
9
9
  require "rexml/formatters/pretty"
10
10
 
data/lib/moxml/adapter.rb CHANGED
@@ -24,11 +24,6 @@ module Moxml
24
24
 
25
25
  AVAILABLE_ADAPTERS = %i[nokogiri oga rexml ox headed_ox libxml leptris].freeze
26
26
 
27
- # Adapters that work under the Opal (JavaScript) runtime.
28
- # Oga is pure Ruby and designed with Opal compatibility in mind — it is the
29
- # canonical XML parser for the JavaScript runtime. REXML is also pure Ruby
30
- # but requires extensive runtime compat shims (regex features like /n,
31
- # \u{...}, (?-mix:...) don't transpile cleanly), so it is opt-in only.
32
27
  # Registry mapping adapter names to their class name suffixes.
33
28
  # Special cases (like :headed_ox → "HeadedOx") live here instead of
34
29
  # a case statement, keeping the dispatch open for extension.
data/lib/moxml/config.rb CHANGED
@@ -11,9 +11,7 @@ module Moxml
11
11
  # when the installed leptris supports programmatic document
12
12
  # construction (Leptris::XML::Document.create); otherwise moxml
13
13
  # falls back to FALLBACK_ADAPTER so released-gem environments keep
14
- # working. Under Opal the default is oga only when the vendored
15
- # pure-Ruby fork was compiled into the bundle — stock oga requires
16
- # its C extension and cannot load there; otherwise rexml.
14
+ # working.
17
15
  PREFERRED_ADAPTER = :leptris
18
16
  FALLBACK_ADAPTER = :nokogiri
19
17
 
@@ -75,12 +73,7 @@ module Moxml
75
73
 
76
74
  @leptris_preferred_available =
77
75
  begin
78
- # Route the require through a non-literal send: Opal::Builder
79
- # resolves literal requires statically and dies on native-only
80
- # gems (leptris is FFI; lutaml/moxml#475) before this rescue
81
- # can degrade the adapter. The runtime require still raises
82
- # LoadError under Opal, which the rescue below handles.
83
- __send__(:require, "leptris")
76
+ require "leptris"
84
77
  Moxml::Adapter.load(:leptris)
85
78
  Gem::Version.new(::Leptris::VERSION) >=
86
79
  Gem::Version.new(Moxml::Adapter::Leptris::MINIMUM_BINDING_VERSION)
@@ -204,7 +197,12 @@ module Moxml
204
197
  end
205
198
 
206
199
  @adapter_name = name
207
- adapter
200
+ # Load lazily (the #adapter reader): assignment must not require
201
+ # the adapter's gem. Moxml.new(:rexml) on a nokogiri-less machine
202
+ # crashed here because Config#initialize consults Config.default,
203
+ # whose construction eagerly loaded the FALLBACK adapter. The
204
+ # load now happens at first use and raises the same AdapterError
205
+ # there.
208
206
  end
209
207
 
210
208
  def default_adapter=(name)
@@ -4,8 +4,7 @@ module Moxml
4
4
  module Reference
5
5
  # A small, total XML reader for the model's input taxonomy. No
6
6
  # recovery: malformed input raises a named ParseError. The only
7
- # dependencies are Ruby's String and Regexp, so the reference
8
- # transpiles to the Opal lane.
7
+ # dependencies are Ruby's String and Regexp alone.
9
8
  class Parser
10
9
  NAME = /[A-Za-z_:][-A-Za-z0-9_:.]*/
11
10
  XML_WHITESPACE = /[ \t\n\r]/
@@ -9,8 +9,8 @@ module Moxml
9
9
  # declaration).
10
10
  #
11
11
  # Output is assembled as an array of parts and joined: the
12
- # reference must run under Opal, where mutable String#<< is
13
- # unsupported.
12
+ # reference stays off mutable String#<< by design (cheap total
13
+ # behavior, no per-call buffer semantics).
14
14
  class Writer
15
15
  VOID_ELEMENTS = %w[
16
16
  area base br col embed hr img input link meta param source
@@ -5,7 +5,7 @@ module Moxml
5
5
  # reader, writer, and normalizer that answer the processing model
6
6
  # without any native engine. Adapters are differentially tested
7
7
  # against these answers; the reference is also the lane for
8
- # engine-free environments (the Opal line generalized).
8
+ # engine-free environments.
9
9
  #
10
10
  # The reference is deliberately small and total over the model's
11
11
  # declared input taxonomy — every well-formed document the model
data/lib/moxml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.2"
5
5
  end
@@ -87,7 +87,7 @@ module Moxml
87
87
  if defined?(URI::RFC3986_PARSER)
88
88
  URI::RFC3986_PARSER.split(uri)
89
89
  elsif uri.match?(/\A[a-zA-Z][a-zA-Z0-9+\-.]*:[^\x00-\x20]*\z/)
90
- # Minimal URI validation for Opal (no RFC3986_PARSER available)
90
+ # Minimal validation where URI::RFC3986_PARSER is unavailable
91
91
  else
92
92
  # Accept relative references and bare paths
93
93
  return unless uri.match?(/[\x00-\x08\x0B\x0C\x0E-\x1F]/)
data/lib/moxml.rb CHANGED
@@ -89,8 +89,6 @@ module Moxml
89
89
  autoload :Builder, "moxml/builder"
90
90
  autoload :Entity, "moxml/entity"
91
91
  autoload :EntityRegistry, "moxml/entity_registry"
92
- # Opal has no autoload; the compat boot file requires this eagerly
93
- # alongside the registry.
94
92
  autoload :NativeAttachment, "moxml/native_attachment"
95
93
  autoload :XmlUtils, "moxml/xml_utils"
96
94
  autoload :XmlEmitter, "moxml/xml_emitter"
@@ -131,15 +131,16 @@ RSpec.describe Moxml::Config do
131
131
  expect { config.adapter = :invalid }.to raise_error(Moxml::AdapterError)
132
132
  end
133
133
 
134
- it "requires adapter gem" do
135
- expect { config.adapter = :oga }.not_to raise_error
136
-
134
+ it "loads the adapter gem at first use" do
135
+ config.adapter = :oga
136
+ config.adapter
137
137
  expect(defined?(Oga)).to be_truthy
138
138
  end
139
139
 
140
- it "handles missing gems" do
140
+ it "delays missing-gem errors from assignment to first use" do
141
141
  allow(Moxml::Adapter).to receive(:require).and_raise(LoadError)
142
- expect { config.adapter = :nokogiri }.to raise_error(Moxml::AdapterError)
142
+ config.adapter = :nokogiri
143
+ expect { config.adapter }.to raise_error(Moxml::AdapterError)
143
144
  end
144
145
  end
145
146
 
@@ -159,4 +160,29 @@ RSpec.describe Moxml::Config do
159
160
  expect(config.adapter).not_to eq(original)
160
161
  end
161
162
  end
163
+
164
+ describe "non-default context construction (moxml#518)" do
165
+ it "does not load the fallback adapter when a named adapter is given" do
166
+ script = <<~'RUBY'
167
+ require "moxml"
168
+ ctx = Moxml.new(:rexml)
169
+ xml = ctx.parse('<person xmlns:x="urn:x" x:id="7"><name>A</name></person>').to_xml
170
+ loaded = $LOADED_FEATURES.map { |f| File.basename(f, ".rb") }
171
+ if loaded.include?("moxml/adapter/nokogiri")
172
+ abort "FAIL: fallback adapter (nokogiri) loaded for a :rexml context"
173
+ end
174
+ unless xml.include?("person")
175
+ abort "FAIL: rexml serialize produced no output: #{xml.inspect}"
176
+ end
177
+ puts "OK"
178
+ RUBY
179
+ out = IO.popen(
180
+ [RbConfig.ruby, "-e", script],
181
+ err: ["/dev/null", "w"],
182
+ "RUBYOPT" => "-rbundler/setup",
183
+ &:read
184
+ )
185
+ expect(out.strip).to eq("OK")
186
+ end
187
+ end
162
188
  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.6.0
4
+ version: 0.6.2
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-31 00:00:00.000000000 Z
11
+ date: 2026-11-02 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