Class: Lash::SpriteBundler

Inherits:
Object
  • Object
show all
Defined in:
lib/lash/sprite_bundler.rb

Overview

Bundles a series of loose images into a single CSS sprite and generates a corresponding CSS support files

Instance Method Summary collapse

Instance Method Details

#bundle(directory, options = nil) ⇒ Object

Bundles the images in the given directory into a single large CSS sprite image

Examples:


bundler.bundle "ui"         # => public/images/ui-sprite.png
                            # => public/sprites/sass/_ui-sprite.scss 

Parameters:

  • directory (String)

    the directory of images to bundle into a sprite

  • options (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (options):

  • :sass (Boolean)

    Generate a SASS script for importing into a master.scss script

  • :class_name (Boolean)

    The css class name, defaults to name of directory

  • :sprite_file (Boolean)

    The name of the png sprite to generate. Defaults to #{directory}-sprite.png

  • :css_file (Boolean)

    The name of the CSS file to generate



25
26
27
28
29
30
31
32
# File 'lib/lash/sprite_bundler.rb', line 25

def bundle( directory, options = nil )
  options = resolve_options( options || {}, directory )
  
  sprite = create_sprite_image( options )
  generate_css( sprite, options )      

  puts "=> bundled css at #{ Lash::Files.relative_to( options[:css_file], Rails.root )}" if options[:log]
end