closure-compiler 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -1
- data/closure-compiler.gemspec +4 -2
- data/lib/closure-compiler.rb +1 -1
- data/lib/closure/compiler.rb +12 -4
- metadata +13 -4
data/README.textile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
h1. The Closure Compiler (as a Ruby Gem)
|
2
2
|
|
3
|
-
The *closure-compiler* gem is a
|
3
|
+
The *closure-compiler* gem is a svelte wrapper around the "Google Closure Compiler":http://code.google.com/closure/compiler/ for JavaScript compression.
|
4
|
+
|
5
|
+
Latest Version: *"0.1.7":http://gemcutter.org/gems/closure-compiler*
|
4
6
|
|
5
7
|
The Closure Compiler's *2009-12-17* JAR-file is included with the gem, so you'll need *Java 6* installed in order to run the compiler.
|
6
8
|
|
data/closure-compiler.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'closure-compiler'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2010-1-
|
3
|
+
s.version = '0.1.7' # Keep version in sync with closure-compiler.rb
|
4
|
+
s.date = '2010-1-23'
|
5
5
|
|
6
6
|
s.homepage = "http://github.com/documentcloud/closure-compiler/"
|
7
7
|
s.summary = "Ruby Wrapper for the Google Closure Compiler"
|
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
'--exclude' << 'test' <<
|
21
21
|
'--all'
|
22
22
|
|
23
|
+
s.add_dependency 'popen4', ['>= 0.1.2']
|
24
|
+
|
23
25
|
s.files = Dir['lib/**/*', 'vendor/**/*', 'closure-compiler.gemspec', 'README.textile', 'LICENSE', 'COPYING']
|
24
26
|
|
25
27
|
end
|
data/lib/closure-compiler.rb
CHANGED
data/lib/closure/compiler.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'popen4'
|
2
3
|
require 'stringio'
|
3
4
|
|
4
5
|
module Closure
|
5
6
|
|
7
|
+
# We raise a Closure::Error when compilation fails for any reason.
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
6
10
|
# The Closure::Compiler is a basic wrapper around the actual JAR. There's not
|
7
11
|
# much to see here.
|
8
12
|
class Compiler
|
@@ -18,7 +22,8 @@ module Closure
|
|
18
22
|
# JavaScript as a string or yields an IO object containing the response to a
|
19
23
|
# block, for streaming.
|
20
24
|
def compile(io)
|
21
|
-
|
25
|
+
result, error = nil, nil
|
26
|
+
status = POpen4.popen4(*command) do |stdout, stderr, stdin, pid|
|
22
27
|
if io.respond_to? :read
|
23
28
|
while buffer = io.read(4096) do
|
24
29
|
stdin.write(buffer)
|
@@ -27,8 +32,11 @@ module Closure
|
|
27
32
|
stdin.write(io.to_s)
|
28
33
|
end
|
29
34
|
stdin.close
|
30
|
-
block_given? ? yield(stdout) : stdout.read
|
35
|
+
result = block_given? ? yield(stdout) : stdout.read
|
36
|
+
error = stderr.read
|
31
37
|
end
|
38
|
+
raise Error, error unless status.success?
|
39
|
+
result
|
32
40
|
end
|
33
41
|
alias_method :compress, :compile
|
34
42
|
|
@@ -41,7 +49,7 @@ module Closure
|
|
41
49
|
end
|
42
50
|
|
43
51
|
def command
|
44
|
-
[@java, '-jar', @jar, @options].flatten
|
52
|
+
[@java, '-jar', @jar, @options].flatten.join(' ')
|
45
53
|
end
|
46
54
|
|
47
55
|
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.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
@@ -9,10 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-23 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: popen4
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.2
|
24
|
+
version:
|
16
25
|
description: " A Ruby Wrapper for the Google Closure Compiler.\n"
|
17
26
|
email: jeremy@documentcloud.org
|
18
27
|
executables: []
|