可以在不安装nokogiri-java的情况下在jruby中加载nokogiri? [英] possible to load nokogiri in jruby without installing nokogiri-java?

查看:52
本文介绍了可以在不安装nokogiri-java的情况下在jruby中加载nokogiri?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种遵循nokogiri脚本运行的方法

i need a way to run following nokogiri script

#parser.rb
require 'nokogiri'

def parseit()
//...
end

并在jruby中的main.rb下运行时调用parseit()

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

#main.rb
require 'parser'

parseit()

当然问题是jruby找不到'nokogiri',因为我还没有通过jruby -S gem install nokogiri

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

原因是我在Jruby下运行的nokogiri中发现了一些错误,因此我仅在Ruby上安装了nokogiri,而没有在Jruby上安装. parser.rb可以在Ruby下完美运行.

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.

所以我的目标是能够运行parseit()而不必在Jruby上安装nokogiri!

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

推荐答案

Nokogiri在JRuby下工作得很好(1.4.0有问题,但是1.4.1版本的gem对我来说是完美的).

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

如果将JRuby与JRuby一起使用,应该不会有任何问题.

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

这篇关于可以在不安装nokogiri-java的情况下在jruby中加载nokogiri?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆