lib/rdf/microdata/reader.rb in rdf-microdata-1.0.3 vs lib/rdf/microdata/reader.rb in rdf-microdata-1.1.0

- old
+ new

@@ -1,11 +1,6 @@ -begin - raise LoadError, "not with java" if RUBY_PLATFORM == "java" - require 'nokogiri' -rescue LoadError => e - :rexml -end +require 'nokogiri' require 'rdf/xsd' require 'json' module RDF::Microdata ## @@ -202,12 +197,10 @@ # # @param [Nokogiri::HTML::Document, Nokogiri::XML::Document, IO, File, String] input # the input stream to read # @param [Hash{Symbol => Object}] options # any additional options - # @option options [Symbol] :library (:nokogiri) - # One of :nokogiri or :rexml. If nil/unspecified uses :nokogiri if available, :rexml otherwise. # @option options [Encoding] :encoding (Encoding::UTF_8) # the encoding of the input stream (Ruby 1.9+) # @option options [Boolean] :validate (false) # whether to validate the parsed statements and values # @option options [Boolean] :canonicalize (false) @@ -229,23 +222,13 @@ def initialize(input = $stdin, options = {}, &block) super do @debug = options[:debug] @vocab_expansion = options.fetch(:vocab_expansion, true) - @library = case options[:library] - when nil - (defined?(::Nokogiri) && RUBY_PLATFORM != 'java') ? :nokogiri : :rexml - when :nokogiri, :rexml - options[:library] - else - raise ArgumentError.new("expected :rexml or :nokogiri, but got #{options[:library].inspect}") - end + @library = :nokogiri require "rdf/microdata/reader/#{@library}" - @implementation = case @library - when :nokogiri then Nokogiri - when :rexml then REXML - end + @implementation = Nokogiri self.extend(@implementation) initialize_html(input, options) rescue raise RDF::ReaderError.new($!.message) if (root.nil? && validate?) \ No newline at end of file