New Hpricot for JRuby


One of the annoying things for JRuby have been lack of recent support for Hpricot. Hopefully that will all be in the past now, or at least in a few days time. I spent some time hacking the latest version of Hpricot to work on JRuby, and as of now, my fork of it runs all tests like it should.

I first want to talk quickly about Nokogiri. Someone on Twitter mentioned that we should be using Nokogiri instead of Hpricot. That’s all good and well, except Nokogiri depends on libxml2 and libxslt2. I know I have done some crazy porting of C-libraries to Java earlier, but I won’t do those two. Ever. So the only chance Nokogiri will have is if someone reimplements the backend to use native Java XML libraries. That wouldn’t be extremely hard, but it would definitely be more time consuming than fixing Hpricot.

So, that’s why I’ve fixed Hpricot. I’ve sent a pull request to Why, and hopefully the Java stuff will all be in his repository soon. Until then you can build your own version of the gem by cloning http://github.com/olabini/hpricot, and installing that.

For those of you who have used the earlier JRuby compatible Hpricot versions, I dare say this version is much faster in many ways. I learned a bit about how to write these kind of ports when doing Yecht, and I think that shows.


4 Comments, Comment or Ping

  1. Antonio Alegria

    Doesn’t JRuby support native extentions through JNA, or is that only through FFI?

    BTW, Nokogiri *does work* on JRuby through FFI.

    July 28th, 2009

  2. Thanks a lot Ola, this work is much appreciated.

    July 28th, 2009

  3. I’m already working on a pure Java version of Nokogiri

    July 28th, 2009

  4. that’s just great news :) been waiting for this quite some time. thanks ola!

    August 2nd, 2009

Reply to “New Hpricot for JRuby”