Ryby and javascript library

Hi there folks!

I want to use autobahn.js library in Ruby. I found out there is ruby gem
called execjs to run some javascript in ruby. The autobahn library is
pre-build. Could you tell me how to load this library to use it in Ruby?

when I do this:

require “execjs”
require “open-uri”
source = open(“http://coffeescript.org/extras/coffee-script.js”).read
context = ExecJS.compile(source)

there is no problem, but when I try this:

require “execjs”
require “open-uri”
source = open(“http://autobahn.s3.amazonaws.com/js/autobahn.js”).read
context = ExecJS.compile(source)

there is error - window is not defined (ExecJS::ProgramError) I read
official execjs site but found only this.

I’ve done some research and found similar problem here:
http://stackoverflow.com/questions/15423454/running-jquery-in-ruby

I’ve installed node.js and jsdom but can’t find any example how to put
this all together in ruby.

Perhaps you can load this via opal.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs