class Closure::Compiler

def compile(io)

block, for streaming.
JavaScript as a string or yields an IO object containing the response to a
Can compile a JavaScript string or open IO object. Returns the compiled
def compile(io)
  tempfile = Tempfile.new('closure_compiler')
  if io.respond_to? :read
    while buffer = io.read(4096) do
      tempfile.write(buffer)
    end
  else
    tempfile.write(io.to_s)
  end
  tempfile.flush
  begin
    result = `#{command} --js #{tempfile.path} 2>&1`
  rescue Exception
    raise Error, "compression failed: #{result}"
  ensure
    tempfile.close!
  end
  unless $?.exitstatus.zero?
    raise Error, result
  end
  yield(StringIO.new(result)) if block_given?
  result
end