ExecJS- 在 Ruby 中执行 JS 代码
Ruby 常用工具包
共0Star
详细介绍
ExecJS 可以让你在 Ruby 中运行 JavaScript 代码。它会自动选择最佳的运行环境并执行你的 JavaScript 程序,并将结果赋值给
Ruby 对象。
ExecJS 支持如下平台
-
therubyracer - Google V8 embedded within Ruby
-
therubyrhino - Mozilla Rhino embedded within JRuby
-
Apple JavaScriptCore - Included with Mac OS X
-
Microsoft Windows Script Host (JScript)
示例代码:
require "execjs"
require "open-uri"
source = open("http://coffeescript.org/extras/coffee-script.js").read
context = ExecJS.compile(source)
context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true)
# => "var square;\nsquare = function(x) {\n return x * x;\n};"
-
796 Star
-
367 Star
-
241 Star
-
0 Star
-
349 Star
-
173 Star
-
492 Star
-
321 Star