Sha256: fe4fc725da67bb894966481b1bcc1da991aa9232d3de20b9c363889dfed3e3e3

Contents?: true

Size: 938 Bytes

Versions: 5

Compression:

Stored size: 938 Bytes

Contents

module ROXML
  PARSERS = %w[nokogiri libxml].freeze
  unless const_defined? 'XML_PARSER'
    parsers = PARSERS.dup
    begin
      require parsers.first
      XML_PARSER = parsers.first # :nodoc:
    rescue LoadError
      parsers.shift
      retry unless parsers.empty?
      raise "Could not load a parser. Tried #{PARSERS.to_sentence}"
    end
  end

  require File.join('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 'roxml/xml/references'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roxml-3.1.5 lib/roxml/xml.rb
roxml-3.1.4 lib/roxml/xml.rb
roxml-3.1.3 lib/roxml/xml.rb
roxml-3.1.2 lib/roxml/xml.rb
roxml-3.1.1 lib/roxml/xml.rb