def initialize(file, options = {})
if file.is_a?(String)
handle = File.new(file)
elsif file.respond_to?("read", 5)
handle = file
else
throw "must pass in path or File"
end
@handle = handle
if options[:parser]
parser = self.class.choose_parser(options[:parser].to_s)
else
parser = @@parser
end
case parser
when 'magic' then extend MagicReader
when 'rexml' then extend REXMLReader
when 'jrexml' then
raise ArgumentError, "jrexml only available under jruby" unless defined? JRUBY_VERSION
extend JREXMLReader
when 'nokogiri' then extend NokogiriReader
when 'jstax' then
raise ArgumentError, "jstax only available under jruby" unless defined? JRUBY_VERSION
extend JRubySTAXReader
when 'libxml' then extend LibXMLReader
end
end