From c72eebdf42e3f8bf7aa86510a70834117801ee1b Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Fri, 25 Mar 2011 17:28:38 -0400 Subject: [PATCH] added support for sprite-selector formats --- Gemfile.lock | 4 ++-- lib/compass/sass_extensions/sprites/image.rb | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 09e8eb4c..46f8736d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/lib/compass/sass_extensions/sprites/image.rb b/lib/compass/sass_extensions/sprites/image.rb index 43a40394..9ad43235 100644 --- a/lib/compass/sass_extensions/sprites/image.rb +++ b/lib/compass/sass_extensions/sprites/image.rb @@ -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