Ticket #131 (closed enhancement: fixed)

Opened 5 months ago

Last modified 4 weeks ago

Hpricot 0.6 patch for JRuby, includes Java fast_xs support

Reported by: nicksieger Owned by: why
Priority: blocker Milestone: 0.6
Component: ext/hpricot_scan Version:
Keywords: jruby Cc:

Description

Hi, with the new JRuby 1.0.3 release, some api changes happened, and so previous versions of Hpricot are broken. Here is a patch that brings it up-to-date, as well as providing Java support for fast_xs.

http://caldersphere.net/hpricot-0.6.157-jruby-trunk.patch

A pre-built version of hpricot-0.6.157-jruby.gem with this patch applied is available at

http://caldersphere.net/gems/hpricot-0.6.157-jruby.gem

(installable via gem with 'gem install hpricot --source http://caldersphere.net')

Change History

Changed 8 weeks ago by stepheneb

  • keywords jruby added
  • priority changed from major to blocker

It would really be great to apply Nick's patch to trunk Hpricot.

Hpricot trunk (as well as the 0.6 gem) doesn't work for anybody using the RC candidates for JRuby 1.1, JRuby trunk or the latest release of the 1.0 series 1.03.

This patch still applies cleanly to r161.

After applying the patch there were no changes in the test results when the tests were run in C Ruby.

Here are the identical test results from both C Ruby, Hpricot r161, with and without Nick's patch:

..........F..................................................F....
Finished in 2.735861 seconds.

  1) Failure:
test_escaping_text(TestBuilder) [./test/test_builder.rb:9]:
<"<b>&lt;a&quot;b&gt;</b>"> expected but was
<"<b>&lt;a\"b&gt;</b>">.

  2) Failure:
test_escaping_of_attrs(TestPreserved) [./test/test_preserved.rb:64]:
<"<a href=\"javascript:alert(&quot;AGGA-KA-BOO!&quot;)\">Google</a>"> expected but was
<"<a href=\"javascript:alert(\\\"AGGA-KA-BOO!\\\")\">Google</a>">.

66 tests, 6154 assertions, 2 failures, 0 errors

When run in trunk JRuby (r6180) there is only one failure reported:

$ jruby -S rake hpricot_java
$ jruby -S rake test                 
(in /Users/stephen/dev/jruby_trunk/jruby/external-gems/hpricot)
/Users/stephen/dev/jruby_trunk/jruby/bin/jruby -Ilib:test:lib/universal-java1.5 "/Users/stephen/dev/jruby_trunk/jruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb"
"test/test_alter.rb" "test/test_builder.rb" "test/test_parser.rb" "test/test_paths.rb" 
"test/test_preserved.rb" "test/test_xml.rb"
Loaded suite /Users/stephen/dev/jruby_trunk/jruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader
Started
............F......................................................
Finished in 7.2410000000000005 seconds.

  1) Failure:
test_latin1_entities(TestBuilder) [/Users/stephen/dev/jruby_trunk/jruby/external-gems/hpricot/./test/test_builder.rb:21]:
<"<b>&#8364;&#8226;</b>"> expected but was
<"<b>&#65533;&#65533;</b>">.

67 tests, 6155 assertions, 1 failures, 0 errors

Note: If you build the jruby package with this command

$ jruby -S rake package_jruby

All the tests will fail without running because the ARCHLIB for jruby: lib/universal-java1.5 is cleaned up during the package_jruby task.

So run this task first before running the tests:

$ jruby -S rake hpricot_java

Changed 4 weeks ago by why

  • status changed from new to closed
  • resolution set to fixed

Great patch, thankyou! Now, you need not be shy, you can just commit straight to the repo, if you like. The commit rights are open to any Trac user. Anyway, I will be moving to github very soon.

Note: See TracTickets for help on using tickets.