Skip to content

Commit 822d5b3

Browse files
committed
closure-compiler 0.3.2 ... now tested and running on Ruby 1.8.7 and Ruby 1.9.1, on both Mac and Windows machines.
1 parent 63a66fc commit 822d5b3

7 files changed

Lines changed: 20 additions & 16 deletions

File tree

README.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ h1. The Closure Compiler (as a Ruby Gem)
22

33
The *closure-compiler* gem is a svelte wrapper around the "Google Closure Compiler":http://code.google.com/closure/compiler/ for JavaScript compression.
44

5-
Latest Version: *"0.3.1":http://gemcutter.org/gems/closure-compiler*
5+
Latest Version: *"0.3.2":http://gemcutter.org/gems/closure-compiler*
66

77
The Closure Compiler's *2010-05-15* JAR-file is included with the gem, so you'll need *Java 6* installed in order to run the compiler.
88

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ desc 'Run all tests'
33
task :default => :test
44
task :test do
55
$LOAD_PATH.unshift(File.expand_path('test'))
6-
require 'redgreen' if Gem.available?('redgreen')
6+
require 'redgreen' if Gem.available?('redgreen') and RUBY_VERSION < "1.9"
77
require 'test/unit'
88
Dir['test/**/test_*.rb'].each {|test| require test }
99
end

closure-compiler.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22
s.name = 'closure-compiler'
3-
s.version = '0.3.1' # Keep version in sync with closure-compiler.rb
4-
s.date = '2010-6-11'
3+
s.version = '0.3.2' # Keep version in sync with closure-compiler.rb
4+
s.date = '2010-6-14'
55

66
s.homepage = "http://github.com/documentcloud/closure-compiler/"
77
s.summary = "Ruby Wrapper for the Google Closure Compiler"

lib/closure-compiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Closure
22

3-
VERSION = "0.3.1"
3+
VERSION = "0.3.2"
44

55
COMPILER_VERSION = "20100514"
66

lib/closure/compiler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(options={})
1919
# block, for streaming.
2020
def compile(io)
2121
result, error = nil, nil
22-
Closure::Popen.popen(command) do |stdin, stdout, stderr|
22+
status = Closure::Popen.popen(command) do |stdin, stdout, stderr|
2323
if io.respond_to? :read
2424
while buffer = io.read(4096) do
2525
stdin.write(buffer)
@@ -39,7 +39,7 @@ def compile(io)
3939
end
4040
yield(StringIO.new(result)) if block_given?
4141
end
42-
raise Error, error unless $?.success?
42+
raise Error, error unless status.success?
4343
result
4444
end
4545
alias_method :compress, :compile

lib/closure/popen.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@ module Closure
44
# grandchild process, and returns the pid of the external process.
55
module Popen
66

7-
WINDOWS = RUBY_PLATFORM.match(/(win|w)32$/)
7+
WINDOWS = RUBY_PLATFORM.match(/(win|w)32$/)
8+
ONE_NINE = RUBY_VERSION >= "1.9"
89
if WINDOWS
9-
require 'rubygems'
10-
require 'win32/open3'
10+
if ONE_NINE
11+
require 'open3'
12+
else
13+
require 'rubygems'
14+
require 'win32/open3'
15+
end
1116
end
1217

1318
def self.popen(cmd)
14-
pid = nil
1519
if WINDOWS
16-
error, pid = nil, nil
17-
Open4.popen4(cmd) do |stdin, stdout, stderr, win_pid|
20+
error = nil
21+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thread|
1822
yield(stdin, stdout, stderr) if block_given?
1923
stdout.read unless stdout.closed? or stdout.eof?
2024
unless stderr.closed?
2125
stderr.rewind
2226
error = stderr.read
2327
end
24-
pid = win_pid
28+
return wait_thread.value if wait_thread.is_a? Thread
2529
end
2630
else
2731
# pipe[0] for read, pipe[1] for write
@@ -55,7 +59,7 @@ def self.popen(cmd)
5559
end
5660
Process.waitpid pid
5761
end
58-
pid
62+
$?
5963
end
6064

6165
end

test/unit/test_closure_compiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_block_syntax
3434
end
3535

3636
def test_jar_and_java_specifiation
37-
if !RUBY_PLATFORM.match(/mswin32/)
37+
if !Closure::Popen::WINDOWS
3838
jar = Dir['vendor/closure-compiler-*.jar'].first
3939
java = `which java`.strip
4040
compiler = Compiler.new(:java => java, :jar_file => jar)

0 commit comments

Comments
 (0)