Created
February 9, 2012 12:10
-
-
Save mindscratch/1779565 to your computer and use it in GitHub Desktop.
Nokogiri Issue 607: JRuby - RubyStringIO#path - NoMethodError
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Linux | |
| JRuby 1.6.5 (using ruby 1.9.2p136) | |
| rubygems 1.8.9 | |
| Windows | |
| JRuby 1.6.5 (using ruby 1.9.2 p290) | |
| rubygems 1.8.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
| # | |
| # Load this file before parsing XML and everything works just great. | |
| # | |
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
| class Nokogiri::XML::Document | |
| def self.parse string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block | |
| options = Nokogiri::XML::ParseOptions.new(options) if Fixnum === options | |
| # Give the options to the user | |
| yield options if block_given? | |
| doc = if string_or_io.respond_to?(:read) | |
| path = nil | |
| if string_or_io.respond_to?(:path) | |
| begin | |
| path = string_or_io.path | |
| rescue NoMethodError | |
| end | |
| end | |
| url ||= path | |
| read_io(string_or_io, url, encoding, options.to_i) | |
| else | |
| # read_memory pukes on empty docs | |
| return new if string_or_io.nil? or string_or_io.empty? | |
| read_memory(string_or_io, url, encoding, options.to_i) | |
| end | |
| # do xinclude processing | |
| doc.do_xinclude(options) if options.xinclude? | |
| return doc | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'minitest/autorun' | |
| require 'nokogiri' # 1.5.0 (java) | |
| require 'multi_xml' # v0.4.1 | |
| class PathMissingTest < MiniTest::Unit::TestCase | |
| def setup | |
| @xml = <<XML | |
| <zoo> | |
| <city>Baltimore</city> | |
| </zoo> | |
| XML | |
| end | |
| def test_parse_with_nokogiri | |
| MultiXml.parser = :nokogiri | |
| assert_kind_of Hash, MultiXml.parse(@xml) | |
| end | |
| def test_parse_with_rexml | |
| MultiXml.parser = :rexml | |
| assert_kind_of Hash, MultiXml.parse(@xml) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment