Question

I'm writing a node module to be open sourced and there's a dependency on some Ruby code (see Can I include a Ruby Gem in a Node.js project? for details). I made a Ruby project that requires some gems and all of that works well. In my node_module, I want to interface it via exec to the Ruby code.

But now there's Ruby dependencies as well. So can I somehow specify the Ruby version, and the gemset required to run my node package?

Ambiguous question perhaps. I can clarify if anything is unclear.

Était-ce utile?

La solution

I don't think you can/should specify the Ruby version to use when executing your code. That should be up the library consumer so choose. Since you want to execute your code with exec, the library consumer will have the added responsbility of making ruby accessible to the node process. How that happens is not up to you as the library developer.

As for dependencies/gemsets, just use bundler.

Autres conseils

Maybe you could do something like this - without more information it's hard to say.

  1. On the ruby side, build your gem to do whatever it needs to do and then add a rake task to it. How you build this rake task is obviously up to the demands of the project and how it will be used, but it will provide a way for you to interface from the outside.

  2. In the 'middle' build a bash script that includes RVM - this way you can require a specific gemset/do specifc things before running the rake task. Another benefit is that if you want to change the gemset or other implementation details, you just change the bash script.

  3. On the node side, call the bash script. More info on that in this answer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top