Module: Canon::XmlBackend
- Defined in:
- lib/canon/xml_backend.rb
Overview
Selection of the XML engine.
Two independent concerns, deliberately separated (MECE):
- XML engine — :nokogiri (raw) or :moxml (adapter-mediated). Drives DOM parsing and serialization of XML (see Canon::XmlParsing).
- HTML support — always Nokogiri on CRuby; moxml has no HTML adapter and leptris no HTML parser (see Canon::Html::NokogiriSupport).
SSOT: moxml owns adapter preference (Moxml::Config prefers leptris when installed and capable; see XmlParsing.moxml_adapter_name). Canon's default engine is Nokogiri on CRuby until leptris WINS somewhere measurably: conformance parity is complete (engine_parity_spec 12/12), but the leptris SAX driver is blocked by a data-corruption bug (leptris-ruby#95) and the record-based conversion runs ~0.55x Nokogiri (CI performance gate: -42..45% on from_xml) pending lighter record emission upstream. Flipping the default is the one-line change in #detect; CANON_XML_BACKEND=moxml opts in today. Under Opal the engine is moxml (rexml adapter).
HTML stays on Nokogiri on CRuby (Canon::Html::NokogiriSupport) and the pretty-printers keep the Nokogiri pipeline — pretty-printed bytes are canon's product (moxml#129).
Constant Summary collapse
- VALID_BACKENDS =
%i[nokogiri moxml].freeze
Class Method Summary collapse
Class Method Details
.active ⇒ Object
30 31 32 |
# File 'lib/canon/xml_backend.rb', line 30 def active @active ||= forced || detect end |
.moxml? ⇒ Boolean
38 39 40 |
# File 'lib/canon/xml_backend.rb', line 38 def moxml? active == :moxml end |
.nokogiri? ⇒ Boolean
34 35 36 |
# File 'lib/canon/xml_backend.rb', line 34 def nokogiri? active == :nokogiri end |
.reset! ⇒ Object
42 43 44 |
# File 'lib/canon/xml_backend.rb', line 42 def reset! @active = nil end |