You need the following before you can install node.rb:
Ruby 1.8.7 or newer (including all flavors of Ruby 1.9)
Python 2.4 for compiling (but Node needs this too so it probably isn't an issue)
Node.js currently only runs on Linux and Mac machines, so I don't think this will go well for you if you're on Windows. But hey, I've been wrong before…
gem install node.rb
To create a Ruby context within your node.js application, do so like this:
var ruby = require('ruby'); ruby.eval('p 1+1');
For your convenience, the node.rb gem ships with an executable so that you can just:
To execute with the stock node.js executable:
NODE_PATH=$NODE_PATH:path/to/node.rb node filename.js
NODE_PATH is a standard option in node.js and is a simple environment variable. That means you can do this:
export NODE_PATH=$NODE_PATH:path/to/node.rb node filename.js
And finally, though I'm not sure why you'd want to do this, you can invoke Node from within Ruby:
That's roughly equivalent to running the node-rb command directly.
There are plans to expose Node to Ruby and vice versa so that objects can travel between the two contexts, but that's not available at this time.
I've tested this gem on various combinations of the following platforms:
Ruby 1.8.7 on Mac
Ruby 1.9.2 on Mac
Ruby 1.8.7 on Ubuntu 10.4
Ruby 1.9.1 on Ubuntu 10.4
Ruby 1.9.2 on Ubuntu 10.4
Note on Patches/Pull Requests
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so I don't break it in a future version unintentionally.
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Colin MacKenzie IV. See LICENSE for details.