将 V8 JavaScript 解释器嵌入到Ruby中:therubyracer
jopen
10年前
therubyracer用于将 V8 JavaScript 解释器嵌入到Ruby中。
特性:
- Evaluate JavaScript from within Ruby
- Embed your Ruby objects into the JavaScript world
- Manipulate JavaScript objects and call JavaScript functions from Ruby
- API compatible with the The Ruby Rhino (for JRuby: http://github.com/cowboyd/therubyrhino)
cxt.eval 'var val = {num: 5, fun: function isTruthy(arg) { return !!arg }}' val = cxt[:val] #=> V8::Object cxt[:val] == cxt.scope.val #=> true val.num #=> 5 val.isTruthy(1) #=> true