added support for sprite-selector formats

This commit is contained in:
Scott Davis 2011-03-25 17:28:38 -04:00
parent 4d7dc7ad30
commit c72eebdf42
2 changed files with 11 additions and 6 deletions

View File

@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
compass (0.11.beta.4.9962a37)
compass (0.11.beta.4.4d7dc7a)
chunky_png (~> 1.1.0)
sass (>= 3.1.0.alpha.249)
@ -88,7 +88,7 @@ GEM
mocha (0.9.12)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.6.13)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)

View File

@ -2,6 +2,11 @@ module Compass
module SassExtensions
module Sprites
class Image
ACTIVE = %r{[_-]active$}
TARGET = %r{[_-]target$}
HOVER = %r{[_-]hover$}
PARENT = %r{(.+)_(.+)$}
attr_reader :relative_file, :options, :base
attr_accessor :top, :left
@ -67,7 +72,7 @@ module Compass
# Has hover selector
def hover?
name[-6..-1] == '_hover'
name =~ HOVER
end
# Hover selector Image object if exsists
@ -77,7 +82,7 @@ module Compass
# Has target selector
def target?
name[-7..-1] == '_target'
name =~ TARGET
end
# Target selector Image object if exsists
@ -87,7 +92,7 @@ module Compass
# Has active selector
def active?
name[-7..-1] == '_active'
name =~ ACTIVE
end
# Active selector Image object if exsists
@ -98,7 +103,7 @@ module Compass
def parent
if [hover?, target?, active?].any?
%r{(.+)_(.+)$}.match name
PARENT.match name
base.image_for($1)
end
end