Fixed problem with globs only going one directoy deep from now on imports like foo/*.png will get mapped to foo/**/*.png

Please enter the commit message for your changes. Lines starting
This commit is contained in:
Scott Davis 2011-05-10 22:44:10 -04:00
parent 369c8d636e
commit 753ad37df7
3 changed files with 31 additions and 4 deletions

View File

@ -25,7 +25,7 @@ module Compass
# Returns the Glob of image files for this sprite
def files
@files ||= Dir[File.join(Compass.configuration.images_path, uri)].sort
@files ||= Dir[File.join(Compass.configuration.images_path, uri).gsub('/*', '/**/*')].sort
end
# Returns an Array of image names without the file extension
@ -50,7 +50,18 @@ module Compass
end
def ensure_path_and_name!
@path, @name = Compass::Sprites.path_and_name(uri)
@path ||= get_path
@name ||= get_name
end
def get_name
_, name = Compass::Sprites.path_and_name(uri)
name
end
def get_path
path, _ = Compass::Sprites.path_and_name(uri)
path
end
def key(uri, options)
@ -130,7 +141,7 @@ $#{name}-#{sprite_name}-repeat: $#{name}-repeat !default;
SCSS
end.join
content += "\n$#{name}-sprites: sprite-map(\"#{uri}\",\n$cleanup: $#{name}-clean-up,\n"
content += "\n$#{name}-sprites: sprite-map(\"#{uri}\", \n$cleanup: $#{name}-clean-up,\n"
content += sprite_names.map do |sprite_name|
%Q{ $#{sprite_name}-position: $#{name}-#{sprite_name}-position,
$#{sprite_name}-spacing: $#{name}-#{sprite_name}-spacing,

View File

@ -7,7 +7,7 @@ module Compass
[$1, $3, $4]
end
end
def self.discover_sprites(uri)
self.load_map(uri, {}).files
end

View File

@ -587,5 +587,21 @@ class SpritesTest < Test::Unit::TestCase
SCSS
assert !css.empty?
end
it "should generate a sprite from nested folders" do
css = render <<-SCSS
@import "nested/*.png";
@include all-nested-sprites;
SCSS
assert_correct css, <<-CSS
.nested-sprite, .nested-ten-by-ten {
background: url('/nested-55a8935544.png') no-repeat;
}
.nested-ten-by-ten {
background-position: 0 0;
}
CSS
end
end