Introducing the Sprite-Factory Gem
But for images, where the best practice is to use css sprites, Rails does not (yet) have a best-practice solution. Many developers are using manual tools, that require uploading files to a 3rd party web service such as Sprite Cow or SpriteMe when it would be better to have a fully automated system built into a Rake task or command line script.
Introducing the sprite-factory gem.
The sprite factory is a ruby library that can be used to easily generate CSS sprites in any ruby application. It combines individual image files from a directory into a single unified sprite image and creates an appropriate CSS stylesheet for use in your web application.
The library provides:
- both a ruby API and a command line script
- many customizable options
- support for any stylesheet syntax, including CSS and Sass.
- support for any image library, including RMagick and ChunkyPNG.
- support for different layout strategies – horizontal, vertical or packed rectangles.
You can find install and usage instructions on github
This gem was originally developed as part of the LiquidPlanner online project management web app. So thanks go out to them for allowing me to open source the original version.