views:

338

answers:

4

i need a way to run following nokogiri script

#parser.rb
require 'nokogiri'

def parseit()
//...
end

and call the parseit() while running below main.rb in jruby

#main.rb
require 'parser'

parseit()

Of course the problem is jruby cannot find 'nokogiri' as I have not installed it aka nokogiri-java via jruby -S gem install nokogiri

The reason is there is some bug I found in nokogiri running under Jruby, so I have only installed nokogiri on Ruby not Jruby. The parser.rb runs perfectly under just Ruby.

So my objective is to be able to run parseit() without having to install nokogiri on Jruby!

+1  A: 

Nokogiri should work under FFI in JRuby. See http://www.ruby-forum.com/topic/186274

Theo
A: 

Nokogiri should just work with JRuby via FFI, so it seems to me that the best course of action is just figure out why installing nokogiri in JRuby doesn't work for you.

What kind of problems you see? What JRuby version? What platform?

VVSiz
+3  A: 

Nokogiri works just fine under JRuby (1.4.0 has issues, but the 1.4.1 version of the gem has been working perfect for me).

jruby -S gem install nokogiri

and if you have issues with platform detection you can force it:

jruby -S gem install nokogiri --platform=java

You shouldn't have any issues using it with JRuby, if you are then maybe you're stack isn't right.

Nicholas C
A: 

After running this:

require 'nokogiri'

-- fail can not find file

Nokogiri::XML ...

-- fail uninitialized constant Nokogiri

Drew