closes 268 - filenames can not start with numbers the must be legal css identifiers

This commit is contained in:
Scott Davis 2011-03-28 22:39:12 -04:00
parent 7571d4af93
commit 2e8fd055ed
3 changed files with 22 additions and 4 deletions

View File

@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
compass (0.11.beta.4.29656ea)
compass (0.11.beta.5.7571d4a)
chunky_png (~> 1.1.0)
sass (>= 3.1.0.alpha.249)

View File

@ -1,7 +1,7 @@
module Compass
class SpriteMap
attr_reader :uri, :options
VAILD_FILE_NAME = /\A#{Sass::SCSS::RX::IDENT}\Z/
def find_relative(*args)
nil
@ -30,7 +30,13 @@ module Compass
# Returns an Array of image names without the file extension
def sprite_names
@sprite_names ||= files.collect { |file| File.basename(file, '.png') }
@sprite_names ||= files.collect do |file|
filename = File.basename(file, '.png')
unless VAILD_FILE_NAME =~ filename
raise Compass::Error, "Sprite file names must be legal css identifiers. Please rename #{File.basename(file)}"
end
filename
end
end
# Returns the sass options for this sprite

View File

@ -496,7 +496,7 @@ describe Compass::Sprites do
css = render <<-SCSS
@import "selectors/*.png";
a {
@include selectors_sprite(ten-by-ten)
@include selectors-sprite(ten-by-ten)
}
SCSS
css.should == <<-CSS
@ -519,4 +519,16 @@ describe Compass::Sprites do
CSS
end
it "should raise error on filenames that are not valid sass syntax" do
lambda do
render <<-SCSS
$sprite-file-prefix:'foo';
@import "prefix/*.png";
a {
@include squares-sprite(20-by-20)
}
SCSS
end.should raise_error Compass::Error
end
end