1

Jruby on Railsのキュウリを見ようとしています。前提条件の 1 つは、前提条件として hpricot を持つ webrat です。

以下を使用して hpricot で gem をインストールしました。

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

これにより、hpricot の Java バージョンがインストールされます。hpricot_scan.jar を CLASSPATH に追加しますが、実行すると:

cucumber features -n

次の出力が得られます。

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'

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"'

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

私が間違っている/していない/どこで私が愚かであるかについて、誰かの手がかりはありますか?

Windows XP、JRuby 1.2.0 を使用

4

4 に答える 4

5

きゅうりについてはわかりませんが、JRuby 1.2.0からは間違いなくHpricotを使用できます(ただし、Hpricotの最新バージョンではありません)。どのバージョンのHpricotをインストールしましたか?多分それは他のライブラリと互換性がありませんか?

次のコマンドが機能しました。

jruby -S gem install hpricot --version '~>0.6.1'  
于 2009-04-08T20:40:14.123 に答える
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

そしてあなたは黄金であるべきです。

于 2009-08-24T17:13:14.453 に答える
1

参考までに、JRubyのバージョン1.4はHPricotのバージョン0.7をサポートするようになりました。

http://jruby.org/2009/11/02/jruby-1-4-0.html

于 2009-11-19T18:48:29.027 に答える
0

HPricot はネイティブの C 拡張機能を使用しており、FFI に準拠していません。したがって、JRuby では使用できません。

于 2009-04-08T01:51:26.227 に答える