On Jan 9, 2013, at 12:54 AM, Hassan Schroeder =
<hassan.schroeder / gmail.com> wrote:

> On Tue, Jan 8, 2013 at 3:19 PM, Jeremy Bopp <jeremy / bopp.net> wrote:
>=20
>>> Is there a way to include .js functions within my ruby script?
>>=20
>> The Ruby interpreter can only directly run Ruby code.  Javascript is =
not
>> Ruby, obviously, so the only possible solution would be to find a way =
to
>> load a Javascript interpreter
>=20
> e.g. `gem install johnson`  -- https://github.com/jbarnette/johnson
>=20
> Note: haven't used this in a long time, so can't vouch for suitability
> for whatever particular purpose the OP has in mind.  :-)

There are multiple mature ways to embed a JS interpreter in Ruby:

  gem install therubyracer # V8 embedded in Ruby
  gem install therubyrhino # the same for JRuby, using Rhino

See https://github.com/cowboyd/therubyracer for the README

Be aware that this only gives you the javascript interpreter, not access =
to DOM manipulations etc.