简体   繁体   English

从Rails应用程序的MRI红宝石内部调用jRuby宝石

[英]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? 有没有办法在使用MRI的Rails红宝石应用程序中使用本地包装的jruby宝石?

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. gem是替补任务,在运行rake -T时看不到。

Any ideas? 有任何想法吗?

there is no such thing as a jruby gem per se. 本质上没有jruby gem这样的东西。 it's the platform that you configure your gem to run on in the gem specification. 它是您配置gem使其在gem规范中运行的platform

this is what bundler uses to split up groups so that you can include platform specific gems. 这是捆绑程序用来拆分组的方法,以便您可以包括平台特定的gem。

in the case of jruby, the platform is the JVM. 对于jruby,平台是JVM。 so if you want to invoke tasks that require a java integration you need to run them with jruby. 因此,如果要调用需要Java集成的任务,则需要使用jruby运行它们。

so the short answer is: NO 所以简短的答案是:否

the long answer is that there are several ways to invoke stuff from MRI. 长的答案是,有几种方法可以从MRI调用内容。

you could shell out and run jruby via the commandline to issue a command on that gem. 您可以通过命令行进行操作并运行jruby,以在该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. 您可以使用ruby java桥直接与java进行交互,甚至可以通过ScriptContainer以某种奇怪的方式加载gem。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM