From 2bf3d8f453f93dafaf747470133957ad22aec293 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Fri, 25 Mar 2011 00:54:47 -0400 Subject: [PATCH] reverted chunky_png version pushed that by mistake and patched a bug that was causing callbacks to register twice --- Gemfile.lock | 6 +++--- compass.gemspec | 2 +- lib/compass/configuration/helpers.rb | 13 ++++++++----- spec/sprites_spec.rb | 28 +++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e6e7f6fb..812473f3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ PATH remote: . specs: - compass (0.11.beta.3.0fdf606) - chunky_png (~> 1.1.0) + compass (0.11.beta.3.6ff877c) + chunky_png (~> 0.12) sass (>= 3.1.0.alpha.249) GEM @@ -38,7 +38,7 @@ GEM addressable (2.2.4) arel (2.0.9) builder (2.1.2) - chunky_png (1.1.0) + chunky_png (0.12.0) compass-validator (3.0.0) css_parser (1.0.1) cucumber (0.9.4) diff --git a/compass.gemspec b/compass.gemspec index d491b294..e5758060 100644 --- a/compass.gemspec +++ b/compass.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |gemspec| gemspec.summary = %q{A Real Stylesheet Framework} gemspec.add_dependency 'sass', '>= 3.1.0.alpha.249' - gemspec.add_dependency 'chunky_png', '~> 1.1.0' + gemspec.add_dependency 'chunky_png', '~> 0.12' gemspec.files = %w(README.markdown LICENSE.markdown VERSION.yml Rakefile) gemspec.files += Dir.glob("bin/*") diff --git a/lib/compass/configuration/helpers.rb b/lib/compass/configuration/helpers.rb index 37fc478a..c10bfffa 100644 --- a/lib/compass/configuration/helpers.rb +++ b/lib/compass/configuration/helpers.rb @@ -65,11 +65,14 @@ module Compass Sass::Plugin.add_template_location sass_dir, css_dir end end - Sass::Plugin.on_updating_stylesheet do |sass_file, css_file| - Compass.configuration.run_callback(:stylesheet_saved, css_file) - end - Sass::Plugin.on_compilation_error do |e, filename, css| - Compass.configuration.run_callback(:stylesheet_error, filename, e.message) + unless defined?(CallbacksSetup) + Sass::Plugin.on_updating_stylesheet do |sass_file, css_file| + Compass.configuration.run_callback(:stylesheet_saved, css_file) + end + Sass::Plugin.on_compilation_error do |e, filename, css| + Compass.configuration.run_callback(:stylesheet_error, filename, e.message) + end + const_set('CallbacksSetup', true) end end diff --git a/spec/sprites_spec.rb b/spec/sprites_spec.rb index 3a9668d0..d8944c03 100644 --- a/spec/sprites_spec.rb +++ b/spec/sprites_spec.rb @@ -1,5 +1,4 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') -require "compass/sprites" require 'digest/md5' describe Compass::Sprites do @@ -440,5 +439,32 @@ describe Compass::Sprites do } 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 \ No newline at end of file