The project is fairly young. Right now it suffers from a memory leak due to a bug in the emscripting of the Ruby garbage collector. The performance is also a problem, as so far we've enabled runtime checking of all signing and overflow issues. Switching to just the needed sign/overflow corrections should boost performance significantly.
The build script is licensed under the MIT license. The modifications follow Ruby's GNU GPL2 license.
The latest pre-built files are found in the
ruby.jsis the raw human-readable compiled source produced by Emscripten.
ruby.opt.jsis the human-readable compiled source after being passed through the redundant variable elimination script.
ruby.opt.jsafter being passed through the Closure Compiler. This is what you will likely want to use.
If you want to build it manually, run
./makeruby. If you want to use the
Closure Compiler, you will need to check out and build a recent version, then
provide the path to it in
makeruby. That script also contains a few
configurable options. You might need to tweak
RUN_CLOSURE until you get optimal performance in all your target browsers.
For the manual build, you will need to have Emscripten and Emmaken configured as per the Emscripten documentation.
dist to a place accessible to your
web page, along with the whole
file you copied. This will provide a global variable called
Ruby. All your
interactions with Emscripted Ruby goes through that. The functions it offers are
initialize(input, output, error): This will initialize the Ruby engine and should be called once before any calls to
stringify(). The arguments are 3 optional callbacks:
input: Will be called when Ruby asks for something on
stdin. Should return an ASCII character code or
nullif no more input is available. Defaults to
readline()in a command-line engine and
window.prompt()in a browser.
output: Will be called when Ruby prints something to
stdoutand passed a byte value which might be an ASCII character code or part of a UTF8 character. Its return value is ignored.
error: Same as
output, but for
stringify(object): Converts an object returned by
eval()to a human-readable string representation (equivalent of