Skip to content

Commit

Permalink
fixes Compass#253
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdavis committed Mar 22, 2011
1 parent a9b6d8c commit 46eec53
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
compass (0.11.beta.3.01b9cd3)
compass (0.11.beta.3.a9b6d8c)
chunky_png (~> 1.1.0)
sass (>= 3.1.0.alpha.249)

Expand Down
1 change: 1 addition & 0 deletions lib/compass/sass_extensions/sprites/base.rb
Expand Up @@ -55,6 +55,7 @@ def init_images
image
end
end

# Calculates the overal image dimensions
# collects image sizes and input parameters for each sprite
def compute_image_positions!
Expand Down
4 changes: 4 additions & 0 deletions lib/compass/sass_extensions/sprites/image.rb
Expand Up @@ -51,6 +51,10 @@ def digest
Digest::MD5.file(file).hexdigest
end

def mtime
File.mtime(file)
end

private
def dimensions
@dimensions ||= Compass::SassExtensions::Functions::ImageSize::ImageProperties.new(file).size
Expand Down
27 changes: 27 additions & 0 deletions spec/sprites_spec.rb
Expand Up @@ -440,5 +440,32 @@ def render(scss)
}
CSS
end

it "should calculate corret sprite demsions when givin spacing via issue#253" do
css = render <<-SCSS
$squares-spacing: 10px;
@import "squares/*.png";
.foo {
@include sprite-background-position($squares-sprites, "twenty-by-twenty");
}
.bar {
@include sprite-background-position($squares-sprites, "ten-by-ten");
}
SCSS
image_size('squares-*.png').should == [20, 40]
css.should == <<-CSS
.squares-sprite {
background: url('/squares-e3c68372d9.png') no-repeat;
}
.foo {
background-position: 0 -20px;
}
.bar {
background-position: 0 0;
}
CSS
end

end

0 comments on commit 46eec53

Please sign in to comment.