module MARC::MagicReader

The MagicReader will try to use the best available XML Parser at the time of initialization.

The order is currently:

* Nokogiri
* jrexml (JRuby only)
* rexml

With the idea that other parsers could be added as their modules are added. Realistically, this list should be limited to stream-based parsers. The magic should be used selectively, however. After all, one project's definition of 'best' might not apply universally. It is arguable which is “best” on JRuby: Nokogiri or jrexml.

Public Class Methods

extended(receiver) click to toggle source
# File lib/marc/xml_parsers.rb, line 15
def self.extended(receiver)
  magic = MARC::XMLReader.best_available
  case magic
  when 'nokogiri' then receiver.extend(NokogiriReader)
  when 'libxml' then receiver.extend(LibXMLReader)
  when 'jstax' then receiver.extend(JRubySTAXReader)
  when 'jrexml' then receiver.extend(JREXMLReader)
  else receiver.extend(REXMLReader)
  end
end