- Full method_missing support for all objects and classes
- Debug mode to provide stack traces and arg checking
- Private and public method support
- Full operator overloading (
- In browser loading of
- Generated code is clean and maintains line numbers to ease debugging
- super(), metaclasses, eigenclasses, blocks, yield, block_given?, ranges, arg count errors, lambda, singletons, etc....
Opal is distributes as a gem, so to install run:
$ gem install opal
Then to run the repl (similar to IRB), run:
$ opal irb
therubyracer, so you will need to have that installed
Try without installing
Browser can be used inside a repl on the http://opalscript.org homepage which gives an IRB style interface for running ruby code which is compiled and evaluated within the browser (no plugins!).
Alternatively the opal runtime and opal parser can be downloaded
directly from the
extras directory in this repository.
Opal can be used within in the browser, or on the command line using the build tools. A Nodejs environment is also partially implemented.
To run within the browser, you can either use the latest build version on the opal website, or clone the build tools as above, and then run the following task in this directory:
$ rake opal
This will place a non minified version ready to run within the browser
Compiling ruby sources
To run ruby code in the browser, ruby must either be precompiled to
opal_dev.js file can parse
and compile ruby code referenced in html
script tags that use the
Opal is bundled with a set of build tools available in the
directory. These are available when running opal from the command line
or including it from ruby sources.
To run the repl, clone this repo as directed above and run:
$ bin/opal irb
This will act like any other repl to try out commands. The repl relies
Opal uses a subset of the
rubyspec specs for ruby until it reaches a
mature enough state to just use rubyspec directly. These tests are found
spec/ folder. They can be run either through the command line,
or built ready to open in the browser.
Running in the browser
To run in the browser, first build the specs (compile into js ready):
$ rake opal_spec
This will build the specs into
extras/ so open
in any browser to see how the specs run.
Running on command line
The opal binary has a
spec flag which can be passed one or any number
of specs. For example, to run the
&& specs from this repo,
$ bin/opal spec spec/language/and_spec.rb
Between gem releases every spec will pass. The master branch in this repo may contain broken specs, but these will be fixed before the next gem release and version bump.
Examples can be found in the
examples/ directory in this repo, and
extras/opal.js being created using the above commands.