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/nokogiri.rb,
lib/moxml/adapter/headed_ox.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_rexml/formatter.rb,
lib/moxml/adapter/customized_oga/xml_generator.rb,
lib/moxml/adapter/customized_libxml/declaration.rb,
lib/moxml/adapter/customized_oga/xml_declaration.rb,
lib/moxml/adapter/customized_libxml/processing_instruction.rb

Defined Under Namespace

Modules: CustomizedLibxml, CustomizedOga, CustomizedOx, CustomizedRexml Classes: Base, HeadedOx, Libxml, Nokogiri, Oga, OgaSAXBridge, Ox, OxSAXBridge, REXMLSAX2Bridge, Rexml

Constant Summary collapse

AVALIABLE_ADAPTERS =
%i[nokogiri oga rexml ox headed_ox libxml].freeze

Class Method Summary collapse

Class Method Details

.load(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/moxml/adapter.rb', line 10

def load(name)
  require_adapter(name)
  # Handle special case for headed_ox -> HeadedOx
  const_name = case name
               when :headed_ox
                 "HeadedOx"
               else
                 name.to_s.capitalize
               end
  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