The dart-compiler gem is a svelte wrapper around the Dart Compiler (Dart to JavaScript compiler)
The Dart Compiler’s 2011-10-12 JAR-files are included with the gem.
This wrapper is largelly based in Closure Compiler by DocumentCloud
sudo gem install dart-compiler
The Dart::Compiler
has a single method, compile
, which can be passed a string or an open IO
object, and returns the compiled JavaScript. The result is returned as a string.
require 'rubygems' require 'dart-compiler' Dart::Compiler.new.compile(File.open('hello.dart', 'r')) => "function native_ArrayFactory__new(typeToken, length) {......
When creating a Dart::Compiler
, you can pass any options that the command-line compiler accepts to the initializer and they’ll be forwarded.
A Dart::Error
exception will be raised, explaining the Dart syntax error, if compilation fails for any reason.