class YUI::Compressor

def compress(stream_or_string)


end
end
end
end
gzip.write(buffer)
while buffer = compressed.read(4096)
compressor.compress(source) do |compressed|
Zlib::GzipWriter.open("my.js.gz", "w") do |gzip|
File.open("my.js", "r") do |source|
==== Example: Compress and gzip a file on disk

# => "(function(){var foo={};foo.bar=\"baz\"})();"
compressor.compress('(function () { var foo = {}; foo["bar"] = "baz"; })()')
compressor = YUI::JavaScriptCompressor.new
==== Example: Compress JavaScript

# => "div.error{color:red;}div.warning{display:none;}"
END_CSS
}
display: none;
div.warning {
}
color: red;
div.error {
compressor.compress(<<-END_CSS)
compressor = YUI::CssCompressor.new
==== Example: Compress CSS

Otherwise, +compress+ returns a string of compressed code.
is given, you can read the compressed code from the block's argument.
any object that responds to +read+ and +close+ like an IO.) If a block
Compress a stream or string of code with YUI Compressor. (A stream is
def compress(stream_or_string)
  streamify(stream_or_string) do |stream|
    tempfile = Tempfile.new('yui_compress')
    tempfile.write stream.read
    tempfile.flush
    full_command = "%s %s" % [command, tempfile.path]
    begin
      output = `#{full_command}`
    rescue Exception => e
      # windows shells tend to blow up here when the command fails
      raise RuntimeError, "compression failed: %s" % e.message
    ensure
      tempfile.close!
    end
    if $?.exitstatus.zero?
      output
    else
      # Bourne shells tend to blow up here when the command fails, usually
      # because java is missing
      raise RuntimeError, "Command '%s' returned non-zero exit status" %
        full_command
    end
  end
end