Project

envjs

0.04
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A browser environment for javascript interpreters. This is a fork of the env.js project (http://github.com/thatcher/env-js/). See that link for env.js details. This fork is based on the Johnson Ruby gem (http://github.com/jbarnette/johnson).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
 Dependencies

Development

>= 2.6.1

Runtime

>= 2.0.0.pre3
 Project Readme

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.

env.js¶ ↑

Description¶ ↑

A browser environment for javascript interpreters.

This is a fork of the env.js project (github.com/thatcher/env-js/). See that link for env.js details. This fork is based on the Johnson Ruby gem (github.com/jbarnette/johnson).

Installation¶ ↑

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¶ ↑

The envjs gem provides the envjsrb command, which functions as an extended version of the Johnson javascript shell. For example:

 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>

Embedding envjs¶ ↑

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.

License¶ ↑

See github.com/smparkes/env-js/blob/envjsrb/licenses/MIT-LICENSE.txt and github.com/smparkes/env-js/blob/envjsrb/licenses/GPL-LICENSE.txt.