closure-compiler 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,28 +7,39 @@ The Closure Compiler's *2009-11-13* JAR-file is included with the gem, so you'll
7
7
  h2. Installation
8
8
 
9
9
  <pre>
10
- sudo gem install closure-compiler --source http://gemcutter.org
10
+ sudo gem install closure-compiler --source http://gemcutter.org
11
11
  </pre>
12
12
 
13
13
  h2. Usage
14
14
 
15
- 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. (@compile@ is aliased as @compress@, for syntactic compatibility with the @ruby-yui-compressor@ gem.)
15
+ 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.
16
16
 
17
17
  <pre>
18
- require 'rubygems'
19
- require 'closure-compiler'
20
- Closure::Compiler.new.compile(File.open('underscore.js', 'r'))
21
-
22
- => "(function(){var j=this,m=j._;function i(a){......
18
+ require 'rubygems'
19
+ require 'closure-compiler'
20
+ Closure::Compiler.new.compile(File.open('underscore.js', 'r'))
21
+
22
+ => "(function(){var j=this,m=j._;function i(a){......
23
23
  </pre>
24
24
 
25
25
  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:
26
26
 
27
27
  <pre>
28
- closure = Closure::Compiler.new(:compilation_level => 'ADVANCED_OPTIMIZATIONS')
29
- closure.compile(File.open('underscore.js', 'r'))
28
+ closure = Closure::Compiler.new(:compilation_level => 'ADVANCED_OPTIMIZATIONS')
29
+ closure.compile(File.open('underscore.js', 'r'))
30
30
 
31
- => "(function(){var j=this,m=j.h;function i(a){......
31
+ => "(function(){var j=this,m=j.h;function i(a){......
32
32
  </pre>
33
33
 
34
- The default values of all the compiler flags are identical to the command-line version. The default *compilation_level* is "SIMPLE_OPTIMIZATIONS".
34
+ The default values of all the compiler flags are identical to the command-line version. The default *compilation_level* is "SIMPLE_OPTIMIZATIONS".
35
+
36
+ h2. YUI Compressor Compatibility
37
+
38
+ 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.
39
+
40
+ <pre>
41
+ compiler = Closure::Compiler.new(
42
+ :java => '/usr/local/bin/java16',
43
+ :jar_file => '/usr/src/closure/build/latest.jar'
44
+ )
45
+ </pre>
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'closure-compiler'
3
- s.version = '0.1.0' # Keep version in sync with closure-compiler.rb
3
+ s.version = '0.1.1' # Keep version in sync with closure-compiler.rb
4
4
  s.date = '2009-11-18'
5
5
 
6
6
  s.homepage = "http://github.com/documentcloud/closure-compiler/"
@@ -1,9 +1,11 @@
1
- require File.dirname(__FILE__) + '/closure/compiler'
1
+ require File.expand_path(File.dirname(__FILE__) + '/closure/compiler')
2
2
 
3
3
  module Closure
4
4
 
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
 
7
- COMPILER_JAR = File.join(File.dirname(__FILE__), "closure-compiler-20091113.jar")
7
+ JAVA_COMMAND = 'java'
8
+
9
+ COMPILER_JAR = File.expand_path(File.dirname(__FILE__) + "/../vendor/closure-compiler-20091113.jar")
8
10
 
9
11
  end
@@ -9,7 +9,9 @@ module Closure
9
9
 
10
10
  # When you create a Compiler, pass in the flags and options.
11
11
  def initialize(options={})
12
- @options = serialize_options(options)
12
+ @java = options.delete(:java) || JAVA_COMMAND
13
+ @jar = options.delete(:jar_file) || COMPILER_JAR
14
+ @options = serialize_options(options)
13
15
  end
14
16
 
15
17
  # Can compile a JavaScript string or open IO object. Returns the compiled
@@ -39,7 +41,7 @@ module Closure
39
41
  end
40
42
 
41
43
  def command
42
- ['java', '-jar', COMPILER_JAR, @options].flatten
44
+ [@java, '-jar', @jar, @options].flatten
43
45
  end
44
46
 
45
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closure-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -23,7 +23,6 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - lib/closure/compiler.rb
26
- - lib/closure-compiler-20091113.jar
27
26
  - lib/closure-compiler.rb
28
27
  - closure-compiler.gemspec
29
28
  - README.textile