Builds, bundles, and minifies CSS and CoffeeScript files.

Building CSS

> require ‘css-reader’ > css = CSSReader.new(“test.css”,“secondary.css”) > css.save(“production.css”, :compress => true)

The above commands will generate new file that merges the files passed to the class in order. Also, and “@import” statement is processed inline and is also inserted in the order it is encountered recursively throughout the CSS. In this example the file has also been yui-compressed.

Alternatively, you can pass in additional css files at later point with the append method:

> css = CSSReader.new(“test.css”) > # do stuff… > css.append(“secondary.css”)

You could also run this from the command line:

> buildcss public/stylesheets/main.css -c

Which will recursively process all imported files and then write a single minified CSS file to: public/stylesheets/main.build.min.css

Building CoffeeScript

> require ‘coffee-bundler’ > js = CoffeeBundler.new(“path/to/coffee/bundle”) > js.save(“public/javascripts/bundle.min.js”, :compress => true)

This will effectively bundle files that match: path/to/coffee/bundle/*.coffee

…into a single minified JS file located at: public/javascripts/bundle.min.js

No, this will not work unless you have coffee-script installed on your system!

Dependencies

Requires the yui-compressor gem:

> gem install -r yui-compressor

More info: github.com/sstephenson/ruby-yui-compressor

Specs

A simple but comprehensive rSpec suite is provided for quality assurance purposes.

> spec css_reader_spec.rb

Disclaimer

This is really crude but useful. You could easily crash it if you placed an @import statement in a fashion to create an infinite loop. Don’t do that! :)