Sha256: 187acd5790da943b282937f5bf0eabb54c54f46fe5d31b37feda3560aaa1957a

Contents?: true

Size: 936 Bytes

Versions: 11

Compression:

Stored size: 936 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
          XML.parse_io(data).root
        else
          if (defined?(URI) && data.is_a?(URI::Generic)) ||
             (defined?(Pathname) && data.is_a?(Pathname))
            XML.parse_file(data.to_s).root
          else
            XML.parse_string(data).root
          end
        end
      end
    end
  end
end

require 'roxml/xml/references'

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
roxml-4.2.0 lib/roxml/xml.rb
roxml-4.1.1 lib/roxml/xml.rb
roxml-4.1.0 lib/roxml/xml.rb
roxml-4.0.0 lib/roxml/xml.rb
roxml-3.3.1 lib/roxml/xml.rb
roxml-3.3.0 lib/roxml/xml.rb
roxml-3.2.2 lib/roxml/xml.rb
roxml-3.2.1 lib/roxml/xml.rb
roxml-3.2.0 lib/roxml/xml.rb
roxml-3.1.6 lib/roxml/xml.rb
yob-roxml-3.1.6 lib/roxml/xml.rb