closure-compiler 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,9 +2,9 @@ h1. The Closure Compiler (as a Ruby Gem)
2
2
 
3
3
  The *closure-compiler* gem is a svelte wrapper around the "Google Closure Compiler":http://code.google.com/closure/compiler/ for JavaScript compression.
4
4
 
5
- Latest Version: *"0.2.2":http://gemcutter.org/gems/closure-compiler*
5
+ Latest Version: *"0.3.0":http://gemcutter.org/gems/closure-compiler*
6
6
 
7
- The Closure Compiler's *2010-02-01* JAR-file is included with the gem, so you'll need *Java 6* installed in order to run the compiler.
7
+ 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.
8
8
 
9
9
  h2. Installation
10
10
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'closure-compiler'
3
- s.version = '0.2.2' # Keep version in sync with closure-compiler.rb
4
- s.date = '2010-4-1'
3
+ s.version = '0.3.0' # Keep version in sync with closure-compiler.rb
4
+ s.date = '2010-6-10'
5
5
 
6
6
  s.homepage = "http://github.com/documentcloud/closure-compiler/"
7
7
  s.summary = "Ruby Wrapper for the Google Closure Compiler"
@@ -20,8 +20,6 @@ Gem::Specification.new do |s|
20
20
  '--exclude' << 'test' <<
21
21
  '--all'
22
22
 
23
- s.add_dependency 'POpen4', ['>= 0.1.4']
24
-
25
23
  s.files = Dir['lib/**/*', 'vendor/**/*', 'closure-compiler.gemspec', 'README.textile', 'LICENSE', 'COPYING']
26
24
 
27
25
  end
@@ -1,13 +1,17 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/closure/compiler')
2
-
3
1
  module Closure
4
2
 
5
- VERSION = "0.2.2"
3
+ VERSION = "0.3.0"
6
4
 
7
- COMPILER_VERSION = "20100201"
5
+ COMPILER_VERSION = "20100514"
8
6
 
9
7
  JAVA_COMMAND = 'java'
10
8
 
11
- COMPILER_JAR = File.expand_path(File.dirname(__FILE__) + "/../vendor/closure-compiler-#{COMPILER_VERSION}.jar")
9
+ COMPILER_ROOT = File.expand_path(File.dirname(__FILE__))
10
+
11
+ COMPILER_JAR = COMPILER_ROOT + "/../vendor/closure-compiler-#{COMPILER_VERSION}.jar"
12
+
13
+ end
12
14
 
13
- end
15
+ require 'stringio'
16
+ require Closure::COMPILER_ROOT + '/closure/popen'
17
+ require Closure::COMPILER_ROOT + '/closure/compiler'
@@ -1,7 +1,3 @@
1
- require 'rubygems'
2
- require 'popen4'
3
- require 'stringio'
4
-
5
1
  module Closure
6
2
 
7
3
  # We raise a Closure::Error when compilation fails for any reason.
@@ -23,7 +19,7 @@ module Closure
23
19
  # block, for streaming.
24
20
  def compile(io)
25
21
  result, error = nil, nil
26
- status = POpen4.popen4(*command) do |stdout, stderr, stdin, pid|
22
+ pid = Closure::Popen.popen(*command) do |stdin, stdout, stderr|
27
23
  if io.respond_to? :read
28
24
  while buffer = io.read(4096) do
29
25
  stdin.write(buffer)
@@ -37,7 +33,8 @@ module Closure
37
33
  out_thread.join and err_thread.join
38
34
  yield(StringIO.new(result)) if block_given?
39
35
  end
40
- raise Error, error unless status.success?
36
+ Process.waitpid pid
37
+ raise Error, error unless $?.success?
41
38
  result
42
39
  end
43
40
  alias_method :compress, :compile
@@ -0,0 +1,43 @@
1
+ module Closure
2
+
3
+ # A slightly modified version of Ruby 1.8's Open3, that doesn't use a
4
+ # grandchild process, and returns the pid of the external process.
5
+ module Popen
6
+
7
+ def self.popen(*cmd)
8
+ # pipe[0] for read, pipe[1] for write
9
+ pw, pr, pe = IO.pipe, IO.pipe, IO.pipe
10
+
11
+ pid = fork {
12
+ pw[1].close
13
+ STDIN.reopen(pw[0])
14
+ pw[0].close
15
+
16
+ pr[0].close
17
+ STDOUT.reopen(pr[1])
18
+ pr[1].close
19
+
20
+ pe[0].close
21
+ STDERR.reopen(pe[1])
22
+ pe[1].close
23
+
24
+ exec(*cmd)
25
+ }
26
+
27
+ pw[0].close
28
+ pr[1].close
29
+ pe[1].close
30
+ pi = [pw[1], pr[0], pe[0]]
31
+ pw[1].sync = true
32
+ begin
33
+ if block_given?
34
+ yield(*pi)
35
+ end
36
+ ensure
37
+ pi.each{|p| p.close unless p.closed?}
38
+ end
39
+ pid
40
+ end
41
+
42
+ end
43
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 2
9
- version: 0.2.2
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Ashkenas
@@ -15,23 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-01 00:00:00 -04:00
18
+ date: 2010-06-10 00:00:00 -04:00
19
19
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: POpen4
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 1
31
- - 4
32
- version: 0.1.4
33
- type: :runtime
34
- version_requirements: *id001
20
+ dependencies: []
21
+
35
22
  description: " A Ruby Wrapper for the Google Closure Compiler.\n"
36
23
  email: jeremy@documentcloud.org
37
24
  executables: []
@@ -42,8 +29,9 @@ extra_rdoc_files: []
42
29
 
43
30
  files:
44
31
  - lib/closure/compiler.rb
32
+ - lib/closure/popen.rb
45
33
  - lib/closure-compiler.rb
46
- - vendor/closure-compiler-20100201.jar
34
+ - vendor/closure-compiler-20100514.jar
47
35
  - closure-compiler.gemspec
48
36
  - README.textile
49
37
  - LICENSE