Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top