diff --git a/Gemfile.lock b/Gemfile.lock index 152232a4..ee5d990d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT PATH remote: . specs: - compass (0.11.1.d9ca08f) + compass (0.11.1.cc26b98) chunky_png (~> 1.1) fssm (>= 0.2.7) sass (~> 3.1) diff --git a/lib/compass/sass_extensions/sprites/base.rb b/lib/compass/sass_extensions/sprites/base.rb index f734118a..4710c615 100644 --- a/lib/compass/sass_extensions/sprites/base.rb +++ b/lib/compass/sass_extensions/sprites/base.rb @@ -71,16 +71,10 @@ module Compass # collects image sizes and input parameters for each sprite def compute_image_positions! imgs = @images.sort { |a,b| a.width <=> b.width } - rows = [::Compass::SassExtensions::Sprites::ImageRow.new(@width)] - imgs.each do |image| - next if rows.last.add(image) - - rows << ::Compass::SassExtensions::Sprites::ImageRow.new(@width) - unless rows.last.add(image) - raise "Image failed to be added" - end - - end + + fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(imgs) + rows = fitter.fit! + current_y = 0 rows.each do |row| current_x = 0 diff --git a/lib/compass/sass_extensions/sprites/image_group.rb b/lib/compass/sass_extensions/sprites/image_group.rb deleted file mode 100644 index 0b251805..00000000 --- a/lib/compass/sass_extensions/sprites/image_group.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Compass - module SassExtensions - module Sprites - class ImageGroup - attr_reader :images - - def initialize(images = []) - @images = images - end - - def best_fitting_rows - - end - end - end - end -end - diff --git a/lib/compass/sass_extensions/sprites/row_fitter.rb b/lib/compass/sass_extensions/sprites/row_fitter.rb index eaa81bd8..b48f3c23 100644 --- a/lib/compass/sass_extensions/sprites/row_fitter.rb +++ b/lib/compass/sass_extensions/sprites/row_fitter.rb @@ -8,6 +8,7 @@ module Compass attr_reader :images, :rows def_delegators :rows, :[] + def initialize(images) @images = images @rows = [] @@ -15,6 +16,7 @@ module Compass def fit!(style = :scan) send("#{style}_fit") + @rows end def width diff --git a/test/units/sprites/image_group_test.rb b/test/units/sprites/image_group_test.rb deleted file mode 100644 index 842b11eb..00000000 --- a/test/units/sprites/image_group_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'compass/sass_extensions/sprites/image_group' - -class ImageGroupTest < Test::Unit::TestCase - def setup - end - -end -