Opal Compiler for Node.js
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
npm
spec
src
.eslintrc
.gitignore
.travis.yml
LICENSE
README.adoc
appveyor.yml
package-lock.json
package.json
update.js

README.adoc

Opal Compiler for Node.js

Travis build status Appveyor build status npm version

Transpile Ruby code to JavaScript in JavaScript!

Usage

Given a Ruby file named hello.rb:

puts "Hello world"

The following code will transpile hello.rb to JavaScript:

var Builder = require('opal-compiler').Builder;
// Opal object will be available on the global scope

var builder = Builder.create();
var result = builder.build('hello.rb').toString();
console.log(result);
//(function(Opal) {
//  var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;

//  Opal.add_stubs(['$puts']);
//  return self.$puts("Hello world")
//})(Opal);