forked from heapsource/dart-compiler
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17eb474
commit 935ba21
Showing
21 changed files
with
67 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,30 @@ | ||
h1. The Closure Compiler (as a Ruby Gem) | ||
h1. The Dart Compiler (as a Ruby Gem) | ||
|
||
The *closure-compiler* gem is a svelte wrapper around the "Google Closure Compiler":http://code.google.com/closure/compiler/ for JavaScript compression. | ||
The *dart-compiler* gem is a svelte wrapper around the "Dart Compiler":http://www.dartlang.org/ (Dart to JavaScript compiler) | ||
|
||
Latest Version: *"1.1.4":http://gemcutter.org/gems/closure-compiler* | ||
The Dart Compiler's *2011-10-12* JAR-files are included with the gem. | ||
|
||
The Closure Compiler's *2011-10-03* JAR-file is included with the gem. | ||
This wrapper is largelly based in "Closure Compiler":https://github.com/documentcloud/closure-compiler by Jeremy Ashkenas | ||
|
||
h2. Installation | ||
|
||
<pre> | ||
sudo gem install closure-compiler | ||
sudo gem install dart-compiler | ||
</pre> | ||
|
||
h2. Usage | ||
|
||
The @Closure::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, or, if a block is passed, yields as an @IO@ object for streaming writes. | ||
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. | ||
|
||
<pre> | ||
require 'rubygems' | ||
require 'closure-compiler' | ||
Closure::Compiler.new.compile(File.open('underscore.js', 'r')) | ||
require 'dart-compiler' | ||
Dart::Compiler.new.compile(File.open('hello.dart', 'r')) | ||
|
||
=> "(function(){var j=this,m=j._;function i(a){...... | ||
=> "function native_ArrayFactory__new(typeToken, length) {...... | ||
</pre> | ||
|
||
When creating a @Closure::Compiler@, you can pass "any options that the command-line compiler accepts":http://code.google.com/closure/compiler/docs/gettingstarted_app.html to the initializer and they'll be forwarded. For example, to raise the compilation level up a notch: | ||
When creating a @Dart::Compiler@, you can pass any options that the command-line compiler accepts to the initializer and they'll be forwarded. | ||
|
||
<pre> | ||
closure = Closure::Compiler.new(:compilation_level => 'ADVANCED_OPTIMIZATIONS') | ||
closure.compile(File.open('underscore.js', 'r')) | ||
|
||
=> "(function(){var j=this,m=j.h;function i(a){...... | ||
</pre> | ||
|
||
The default values of all the compiler flags are identical to the command-line version. The default *compilation_level* is "SIMPLE_OPTIMIZATIONS". | ||
|
||
A @Closure::Error@ exception will be raised, explaining the JavaScript syntax error, if compilation fails for any reason. | ||
|
||
h2. YUI Compressor Compatibility | ||
|
||
Effort has been made to make the "closure-compiler" gem a drop-in alternative to the "ruby-yui-compressor". To that end, @Closure::Compiler#compile@ has been aliased as @compress@, and can take the same string or IO argument that a @YUI::JavaScriptCompressor#compress@ can. In addition, the @Closure::Compiler@ initializer can take @java@ and @jar_file@ options, overriding the location of the Java command and the Closure Compiler JAR file, respectively. | ||
|
||
<pre> | ||
compiler = Closure::Compiler.new( | ||
:java => '/usr/local/bin/java16', | ||
:jar_file => '/usr/src/closure/build/latest.jar' | ||
) | ||
</pre> | ||
A @Dart::Error@ exception will be raised, explaining the Dart syntax error, if compilation fails for any reason. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
require "rake/testtask" | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs += ["lib", "test"] | ||
t.test_files = FileList["test/**/*_test.rb"] | ||
t.verbose = true | ||
end | ||
|
||
namespace :gem do | ||
|
||
desc 'Build and install the closure-compiler gem' | ||
desc 'Build and install the dart-compiler gem' | ||
task :install do | ||
sh "gem build closure-compiler.gemspec" | ||
sh "gem build dart-compiler.gemspec" | ||
sh "sudo gem install #{Dir['*.gem'].join(' ')} --local --no-ri --no-rdoc" | ||
end | ||
|
||
desc 'Uninstall the closure-compiler gem' | ||
desc 'Uninstall the dart-compiler gem' | ||
task :uninstall do | ||
sh "sudo gem uninstall -x closure-compiler" | ||
sh "sudo gem uninstall -x dart-compiler" | ||
end | ||
|
||
end | ||
|
||
task :default => :test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'dart-compiler' | ||
s.version = '0.0.1' # Keep version in sync with dart-compiler.rb | ||
s.date = '2011-10-13' | ||
|
||
s.homepage = "http://github.com/guilleiguaran/dart-compiler/" | ||
s.summary = "Ruby Wrapper for the Dart Compiler" | ||
s.description = <<-EOS | ||
A Ruby Wrapper for the Dart Compiler. | ||
EOS | ||
|
||
s.authors = ['Guillermo Iguaran'] | ||
s.email = 'guilleiguaran@gmail.com' | ||
|
||
s.require_paths = ['lib'] | ||
|
||
s.rdoc_options << '--title' << 'Ruby Dart Compiler' << | ||
'--all' | ||
|
||
s.files = Dir['lib/**/*', 'dart-compiler.gemspec', 'README.textile', 'LICENSE', 'COPYING'] | ||
|
||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Dart | ||
|
||
VERSION = "0.0.1" | ||
|
||
COMPILER_VERSION = "20111013" | ||
|
||
JAVA_COMMAND = 'java' | ||
|
||
COMPILER_ROOT = File.expand_path(File.dirname(__FILE__)) | ||
|
||
COMPILER_JAR_PATH = File.join(COMPILER_ROOT, "java") | ||
|
||
end | ||
|
||
require 'dart/compiler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file renamed
BIN
+4.75 MB
lib/closure-compiler-20111003.jar → lib/java/closure-compiler.jar
100755 → 100644
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.