为JRuby安装hpricot

Mat*_*ell 1 hpricot ruby-on-rails jruby webrat cucumber

我正试着看看Jruby on Rails上的黄瓜.其中一个预先请求的是webrat,它具有先决条件的hpricot.

我使用hpricot安装了gem:

gem install hpricot --source http://code.whytheluckystiff.net --version 0.6.1 --platform java

这将安装java版本的hpricot.我将hpricot_scan.jar添加到CLASSPATH但是当我运行时:

cucumber features -n
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

HpricotScanService.java:931:in `hpricot_scan': java.lang.NoSuchMethodError:
org.jruby.runtime.builtin.IRubyObject.getInstanceVariable(Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;
from HpricotScanService.java:1324:in `__hpricot_scan'
from null:-1:in `call'
from InvocationCallback.java:67:in `execute'
from FullFunctionCallbackMethod.java:69:in `call'
from DynamicMethod.java:243:in `call'
from CachingCallSite.java:283:in `cacheAndCall'
from CachingCallSite.java:121:in `callBlock'
Run Code Online (Sandbox Code Playgroud)

等等

如果我编译HpricotScanService.java文件并将生成的.class文件添加到类路径中,我得到:

Then I should see "Run"
private method `scan' called for Hpricot:Module (NoMethodError)
features/step_definitions/webrat_steps.rb:94:in `/^I should see "([^\"]*)"$/'
features/manage_activity.feature:9:in `Then I should see "Run"'
Run Code Online (Sandbox Code Playgroud)

如果我尝试安装更高版本的hpricot,那么我得到:

ERROR: Failed to build gem native extension.
C:/Program Files/Ruby/jruby-1.2.0/bin/../bin/jruby.bat extconf.rb install hpricot --platform java
C:/Program Files/Ruby/jruby-1.2.0/bin/../lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (Not
ImplementedError)
from C:/Program Files/Ruby/jruby-1.2.0/bin/../lib/ruby/1.8/mkmf.rb:1:in `require'
from extconf.rb:1
Run Code Online (Sandbox Code Playgroud)

有没有人有任何关于我做错/不做/我愚蠢的地方的线索.

使用Windows XP,JRuby 1.2.0

Pan*_*rat 5

我不知道黄瓜,但Hpricot肯定可以从JRuby 1.2.0使用(虽然不是最新版本的Hpricot).你安装了哪个版本的Hpricot?也许它与其他图书馆不兼容?

以下命令对我有用:

jruby -S gem install hpricot --version '~>0.6.1'  
Run Code Online (Sandbox Code Playgroud)


Jos*_*ews 5

自上个月Ola Bini改写hpricot jruby支持以来,hpricot的git head可以安装jruby.只需下载头部,然后使用

jruby -S rake package_jruby
cd pkg
sudo jgem install ./hpricot-0.8.1-jruby.gem
Run Code Online (Sandbox Code Playgroud)

而你应该是金色的.