Sha256: fd4d2cf53c42a4c94282392f18dd572c2543973602b966e89ba09cbe6a4fa937

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

module ROXML
  unless const_defined? 'XML_PARSER'
    PREFERRED_PARSERS = %w[nokogiri libxml].freeze
    parsers = PREFERRED_PARSERS.dup
    begin
      require parsers.first
      XML_PARSER = parsers.first # :nodoc:
    rescue LoadError
      if parsers.size > 1
        parsers.shift
        retry
      else
        raise "Could not load either nokogiri or libxml"
      end
    end
  end

  require File.join('lib/roxml/xml/parsers', XML_PARSER)

  module XML
    class Node
      def self.from(data)
        case data
        when XML::Node
          data
        when XML::Document
          data.root
        when File, IO
          Parser.parse_io(data).root
        else
          if (defined?(URI) && data.is_a?(URI::Generic)) ||
             (defined?(Pathname) && data.is_a?(Pathname))
            Parser.parse_file(data.to_s).root
          else
            Parser.parse(data).root
          end
        end
      end
    end
  end
end

require 'lib/roxml/xml/references'

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
roxml-3.1.0 lib/roxml/xml.rb
ROXML-3.0.0 lib/roxml/xml.rb