Ruby port of YUI compressor's CSS engine.
Based on the original YUI compressor Java code and the Javascript port by Stoyan Stefanov. The Ruby port is complete and passes all test cases that are included in the Java version. However, code and performance improvements are always welcome.
The motivation for this port was to have a native Ruby version without a Java or Javascript dependency.
require 'path/to/lib/cssmin.rb'
CssCompressor.compress('/* a comment */ .test { display: block; }')
# => minified CSS
CssCompressor.compress(File.read('path/to/styles.css'))
# => minified CSS
CssCompressor.compress(File.open('path/to/styles.css'))
# => minified CSS
Files or strings are acceptable as input.
You can pass in a second argument to control the maximum output line length (default 5000 characters):
CssCompressor.compress(File.read('path/to/styles.css'), 200)
Note: in most cases line length will only be approximated.
See CHANGES.
See LICENSE for details.