Method: MARC::XMLReader.best_available
- Defined in:
- lib/marc/xmlreader.rb
.best_available ⇒ Object
Returns the value of the best available parser
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/marc/xmlreader.rb', line 117 def best_available parser = nil if defined? JRUBY_VERSION unless parser begin require "nokogiri" parser = USE_NOKOGIRI rescue LoadError end end unless parser begin # try to find the class, so we throw an error if not found java.lang.Class.forName("javax.xml.stream.XMLInputFactory") parser = USE_JSTAX rescue java.lang.ClassNotFoundException end end unless parser begin require "jrexml" parser = USE_JREXML rescue LoadError end end else begin require "nokogiri" parser = USE_NOKOGIRI rescue LoadError end unless defined? JRUBY_VERSION unless parser begin require "xml" parser = USE_LIBXML rescue LoadError end end end end parser ||= USE_REXML parser end |