Module: Moxml::Adapter
- Defined in:
- lib/moxml/adapter.rb,
lib/moxml/adapter/ox.rb,
lib/moxml/adapter/oga.rb,
lib/moxml/adapter/base.rb,
lib/moxml/adapter/rexml.rb,
lib/moxml/adapter/libxml.rb,
lib/moxml/adapter/leptris.rb,
lib/moxml/adapter/nokogiri.rb,
lib/moxml/adapter/headed_ox.rb,
lib/moxml/adapter/customized_ox.rb,
lib/moxml/adapter/customized_oga.rb,
lib/moxml/adapter/customized_rexml.rb,
lib/moxml/adapter/customized_libxml.rb,
lib/moxml/adapter/customized_leptris.rb,
lib/moxml/adapter/customized_ox/text.rb,
lib/moxml/adapter/customized_libxml/node.rb,
lib/moxml/adapter/customized_libxml/text.rb,
lib/moxml/adapter/customized_libxml/cdata.rb,
lib/moxml/adapter/customized_ox/attribute.rb,
lib/moxml/adapter/customized_ox/namespace.rb,
lib/moxml/adapter/customized_libxml/comment.rb,
lib/moxml/adapter/customized_libxml/element.rb,
lib/moxml/adapter/customized_leptris/doctype.rb,
lib/moxml/adapter/customized_rexml/formatter.rb,
lib/moxml/adapter/libxml/entity_ref_registry.rb,
lib/moxml/adapter/customized_oga/xml_generator.rb,
lib/moxml/adapter/customized_libxml/declaration.rb,
lib/moxml/adapter/customized_oga/entity_decoder.rb,
lib/moxml/adapter/customized_leptris/declaration.rb,
lib/moxml/adapter/customized_leptris/document_pi.rb,
lib/moxml/adapter/customized_oga/xml_declaration.rb,
lib/moxml/adapter/customized_ox/entity_reference.rb,
lib/moxml/adapter/customized_leptris/text_segment.rb,
lib/moxml/adapter/customized_oga/raw_value_override.rb,
lib/moxml/adapter/customized_rexml/entity_reference.rb,
lib/moxml/adapter/customized_libxml/entity_reference.rb,
lib/moxml/adapter/customized_leptris/entity_reference.rb,
lib/moxml/adapter/customized_libxml/processing_instruction.rb
Defined Under Namespace
Modules: CustomizedLeptris, CustomizedLibxml, CustomizedOga, CustomizedOx, CustomizedRexml Classes: Base, HeadedOx, Leptris, Libxml, Nokogiri, Oga, Ox, OxSAXBridge, REXMLStreamBridge, Rexml
Constant Summary collapse
- AVAILABLE_ADAPTERS =
%i[nokogiri oga rexml ox headed_ox libxml leptris].freeze
- OPAL_AVAILABLE_ADAPTERS =
Adapters that work under the Opal (JavaScript) runtime. Oga is pure Ruby and designed with Opal compatibility in mind — it is the canonical XML parser for the JavaScript runtime. REXML is also pure Ruby but requires extensive runtime compat shims (regex features like /n, \u..., (?-mix:...) don't transpile cleanly), so it is opt-in only.
%i[oga rexml].freeze
- CONST_NAME_MAP =
Registry mapping adapter names to their class name suffixes. Special cases (like :headed_ox → "HeadedOx") live here instead of a case statement, keeping the dispatch open for extension.
{ headed_ox: "HeadedOx", }.freeze
Class Method Summary collapse
Class Method Details
.available?(name) ⇒ Boolean
43 44 45 |
# File 'lib/moxml/adapter.rb', line 43 def available?(name) platform_adapters.include?(name.to_sym) end |
.load(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/moxml/adapter.rb', line 29 def load(name) validate_platform!(name) require_adapter(name) const_name = const_name_for(name) const_get(const_name) rescue LoadError => e raise Moxml::AdapterError.new( "Could not load #{name} adapter. Please ensure the #{name} gem is installed", adapter: name, operation: "load", native_error: e, ) end |
.platform_adapters ⇒ Object
47 48 49 |
# File 'lib/moxml/adapter.rb', line 47 def platform_adapters RUBY_ENGINE == "opal" ? OPAL_AVAILABLE_ADAPTERS : AVAILABLE_ADAPTERS end |