THIS FORK OF ENV.JS IS MOTHBALLED
The Johnson fork of env.js is pretty much mothballed (which is already pretty much true of Johnson, given the rise of v8 and the difficulty moving Johnson to 1.9.*). The current best practices seem to be based on a headless webkit.
For now, you can install the envjs gem by installing Johnson:
gem install johnson --prerelease
and then installing the envjs gem with
gem install envjs
Using envjs interactively
mbp:env-js smparkes$ envjsrb js> this => [object Window 0] js> window.location => about:blank js> document.innerHTML => "<html><head><title></title></head><body></body></html>" js>
It's also possible to embed the envjs interpreter similar to the way it's done in Johnson, e.g.,
require 'rubygems' # if necessary require 'johnson/tracemonkey' require 'envjs/runtime' envjs = Johnson::Runtime.new envjs.extend Envjs::Runtime window = envjs.evaluate("window") puts window.location.to_s # == "about:blank" puts window.document.innerHTML # == "<html><head><title></title></head><body></body></html>" envjs.wait
You need the Runtime#wait at the end to give env.js's event loop a chance to execute queued events and timers. You may need to do this at other times as well, depending on the asynchronous nature of your application.