0

I am looking to implement 'https://github.com/LIFX/lifx-gem' commands on a Node.js server and was wondering how to complete this task.

My basic question is more generic: how to implement or inject Ruby code in a JavaScript environment.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
RichardB
  • 97
  • 6

2 Answers2

1

There are several projects that aim to do this, but Opal seems to be actively developed. If you can't run Ruby on your target platform or you want a browser app, this is probably the best way to implement a Ruby library in a Node.js environment.

Andrew Prentice
  • 275
  • 2
  • 7
-1

To be clear, Ruby is a backend server-side language and Node.js uses JavaScript as the backend server-side language. Unfortunately, I don't believe you can run Ruby code in a JavaScript environment unless you have some sort of compiler to convert Ruby code to JavaScript code.

Your best bet would be to see if there is an equivalent implementation of that Gem as a NPM module.

wmock
  • 5,382
  • 4
  • 40
  • 62
  • So, that makes sense. There is no GEM in NPM, can this only be created by LiFX, I am assuming no. I can potentially create an 'unofficial module'? – RichardB Dec 31 '14 at 15:51
  • I believe that as long as you don't break any of their licensing stipulations, you can implement your own version of it as a NPM module – wmock Dec 31 '14 at 15:53