Invoking a jRuby gem from inside an MRI ruby on rails application

Is there a way to use a locally packaged jruby gem inside a ruby on rails application that uses MRI?

I currently use the following:

platform :jruby do gem 'my_gem', path: "path_to_my_gem" end

and I am not sure if it works. The gem is a bench of rake tasks, which I can't see when I run rake -T.

Any ideas?


there is no such thing as a jruby gem per se. it's the platform that you configure your gem to run on in the gem specification.

this is what bundler uses to split up groups so that you can include platform specific gems.

in the case of jruby, the platform is the JVM. so if you want to invoke tasks that require a java integration you need to run them with jruby.

so the short answer is: NO

the long answer is that there are several ways to invoke stuff from MRI.

you could shell out and run jruby via the commandline to issue a command on that gem.

you could use the ruby java bridge to interact with java directly, maybe even load the gem in some weird kind of way through a ScriptContainer.

链接地址: http://www.djcxy.com/p/61718.html

上一篇: 我怎样才能优雅地关闭Rserve?

下一篇: 在轨道应用程序中从MRI红宝石内部调用jRuby宝石