Project

sprites

0.01
No commit activity in last 3 years
No release in over 3 years
Sprites generator for ruby applications or from cli
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Sprites

Sprites is a library that let's you define the sprites for your application with configuration or convention. Sprites will generate your sprites, and a corresponding stylesheet for each using either the cli or from within a Rails application.

The DSL for sprites.rb

sprite :bas

sprite :buttons, :path => "buttons.png", :stylesheet_path => "buttons.css", :autoload => false do
  sprite_piece 'buttons/btn-black-default-28.png', 'a.black.button > span, button.black.submit span'
  sprite_piece 'buttons/btn-black-default-cap-28.png', 'a.black.button, button.black.submit', :x => 'right'
  ...
end

For the cli

Project Structure

|
|\_config
|   \_sprites.rb
 \_public
    \_images
      \_sprite_images
        |\_sprite_name1
        | |\_blue_icon.png
        |  \_green_icon.png
         \_sprite_name2
           |\_blue_icon.png
            \_green_icon.png

gem install sprites

execute:

cd PROJECT_ROOT
sprites

For usage

sprites --help

In your Rails app

Gemfile

gem 'sprites'

application.rb

config.uses_sprites = true

Optionally include a config/sprites.rb (see above). Otherwise Sprites will use it's auto-load feature. Example, if you have app/assets/images/sprite_images/foo/bar.png and app/assets/images/sprite_images/foo/bas.png, Sprites will create app/assets/stylesheets/sprites/foo.css and app/assets/images/sprites/foo.png. The class for bar.png will be .bar and for bas.png, .bas, etc.

rake sprites

to generate.

In your Rails Engine

engine.rb

module MyGem
  class Engine < Rails::Engine
    config.uses_sprites = true
  end
end

Use app/assets in your gem like you would your rails app and use the asset pipeline.

From your rails root

ENGINES=true rake sprites

Note: this will generate your sprites for your Sprites enabled Engines and your Sprites enabled Rails app.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request