diff --git a/lib/compass/commands/sprite.rb b/lib/compass/commands/sprite.rb index 2b33f9fc..b1c8bee9 100644 --- a/lib/compass/commands/sprite.rb +++ b/lib/compass/commands/sprite.rb @@ -39,7 +39,7 @@ module Compass def perform relative_uri = options[:uri].gsub(/^#{Compass.configuration.images_dir}\//, '') - sprites = Compass::SpriteMap.new(relative_uri, Compass.sass_engine_options) + sprites = Compass::SpriteImporter.new(relative_uri, Compass.sass_engine_options) options[:output_file] ||= File.join(Compass.configuration.sass_path, "sprites", "_#{sprites.name}.#{Compass.configuration.preferred_syntax}") options[:skip_overrides] ||= false contents = sprites.content_for_images(options[:skip_overrides]) diff --git a/lib/compass/configuration/adapters.rb b/lib/compass/configuration/adapters.rb index 6a35c91a..352eb3c4 100644 --- a/lib/compass/configuration/adapters.rb +++ b/lib/compass/configuration/adapters.rb @@ -23,7 +23,7 @@ module Compass plugin_opts[:cache_location] = cache_path unless cache_path.nil? plugin_opts.merge!(sass_options || {}) plugin_opts[:load_paths] ||= [] - plugin_opts[:load_paths] << Compass::SpriteMap.new + plugin_opts[:load_paths] << Compass::SpriteImporter.new plugin_opts end @@ -63,7 +63,7 @@ module Compass next p if p.respond_to?(:find_relative) Sass::Importers::Filesystem.new(p.to_s) end - load_paths << Compass::SpriteMap.new + load_paths << Compass::SpriteImporter.new load_paths end end diff --git a/lib/compass/sass_extensions/sprites.rb b/lib/compass/sass_extensions/sprites.rb index 12e821ed..72a00efa 100644 --- a/lib/compass/sass_extensions/sprites.rb +++ b/lib/compass/sass_extensions/sprites.rb @@ -1,5 +1,5 @@ require 'digest/md5' -require 'compass/sass_extensions/sprites/sprite_map' +require 'compass/sprite_importer' require 'compass/sass_extensions/sprites/image' require 'compass/sass_extensions/sprites/base' require 'compass/sass_extensions/sprites/engines' diff --git a/lib/compass/sass_extensions/sprites/base.rb b/lib/compass/sass_extensions/sprites/base.rb index 3051248a..bac3d821 100644 --- a/lib/compass/sass_extensions/sprites/base.rb +++ b/lib/compass/sass_extensions/sprites/base.rb @@ -4,14 +4,14 @@ module Compass class Base < Sass::Script::Literal - # Initialize a new aprite object from a relative file path + # Initialize a new sprite object from a relative file path # the path is relative to the images_path confguration option def self.from_uri(uri, context, kwargs) - sprite_map = ::Compass::SpriteMap.new(:uri => uri.value, :options => {}) - sprites = sprite_map.files.map do |sprite| + importer = ::Compass::SpriteImporter.new(:uri => uri.value, :options => {}) + sprites = importer.files.map do |sprite| sprite.gsub(Compass.configuration.images_path+"/", "") end - new(sprites, sprite_map, context, kwargs) + new(sprites, importer.path, importer.name, context, kwargs) end # Loads the sprite engine @@ -23,22 +23,21 @@ module Compass # We should do so only when the packing algorithm changes SPRITE_VERSION = "1" - attr_accessor :image_names, :path, :name, :map, :kwargs + attr_accessor :image_names, :path, :name, :kwargs attr_accessor :images, :width, :height - def initialize(sprites, sprite_map, context, kwargs) + def initialize(sprites, path, name, context, kwargs) require_engine! @image_names = sprites - @path = sprite_map.path - @name = sprite_map.name + @path = path + @name = name @kwargs = kwargs @kwargs['cleanup'] ||= Sass::Script::Bool.new(true) @images = nil @width = nil @height = nil @evaluation_context = context - @map = sprite_map validate! compute_image_metadata! end diff --git a/lib/compass/sass_extensions/sprites/sprite_map.rb b/lib/compass/sprite_importer.rb similarity index 98% rename from lib/compass/sass_extensions/sprites/sprite_map.rb rename to lib/compass/sprite_importer.rb index b89b072f..1b02ccba 100644 --- a/lib/compass/sass_extensions/sprites/sprite_map.rb +++ b/lib/compass/sprite_importer.rb @@ -1,12 +1,12 @@ module Compass - class SpriteMap < Sass::Importers::Base + class SpriteImporter < Sass::Importers::Base attr_accessor :uri, :options VAILD_FILE_NAME = /\A#{Sass::SCSS::RX::IDENT}\Z/ SPRITE_IMPORTER_REGEX = %r{((.+/)?([^\*.]+))/(.+?)\.png} def self.load(uri, options) Compass.quick_cache "Sprite_map:#{uri}#{options.inspect}", 5 do - klass = Compass::SpriteMap.new + klass = Compass::SpriteImporter.new klass.uri, klass.options = uri, options klass end diff --git a/spec/compass/sass_extensions/sprites/base_spec.rb b/spec/compass/sass_extensions/sprites/base_spec.rb index 6a086737..1d8cfedc 100644 --- a/spec/compass/sass_extensions/sprites/base_spec.rb +++ b/spec/compass/sass_extensions/sprites/base_spec.rb @@ -11,7 +11,7 @@ describe Compass::SassExtensions::Sprites::Base do Compass.configure_sass_plugin! #fix this eww options = Compass.sass_engine_options.extend Compass::SassExtensions::Functions::Sprites::VariableReader - @map = Compass::SpriteMap.new("selectors/*.png", options) + @map = Compass::SpriteImporter.new("selectors/*.png", options) @base = Compass::SassExtensions::Sprites::Base.new(@map.sprite_names.map{|n| "selectors/#{n}.png"}, @map.path, 'selectors', @map.sass_engine, @map.options) end diff --git a/spec/compass/sass_extensions/sprites/sprite_map_spec.rb b/spec/compass/sass_extensions/sprites/sprite_map_spec.rb index a6eee9ea..30a3895d 100644 --- a/spec/compass/sass_extensions/sprites/sprite_map_spec.rb +++ b/spec/compass/sass_extensions/sprites/sprite_map_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'fakefs/spec_helpers' require 'timecop' -describe Compass::SpriteMap do +describe Compass::SpriteImporter do include FakeFS::SpecHelpers let(:sprite_map) { self.class.describes.new(uri, options) } diff --git a/test/units/sprites/base_test.rb b/test/units/sprites/base_test.rb index b557bf29..f62ed0cf 100644 --- a/test/units/sprites/base_test.rb +++ b/test/units/sprites/base_test.rb @@ -16,8 +16,8 @@ class SpritesBaseTest < Test::Unit::TestCase end def setup_map - @map = Compass::SpriteMap.new(:uri => "selectors/*.png", :options => @options) - @base = Compass::SassExtensions::Sprites::Base.new(@map.sprite_names.map{|n| "selectors/#{n}.png"}, @map, @map.sass_engine, @map.options) + @importer = Compass::SpriteImporter.new(:uri => "selectors/*.png", :options => @options) + @base = Compass::SassExtensions::Sprites::Base.new(@importer.sprite_names.map{|n| "selectors/#{n}.png"}, @importer.path, @importer.name, @importer.sass_engine, @importer.options) end def teardown @@ -29,7 +29,7 @@ class SpritesBaseTest < Test::Unit::TestCase end it "should have the sprite names" do - assert_equal @map.sprite_names, @base.sprite_names + assert_equal @importer.sprite_names, @base.sprite_names end it 'should have image filenames' do diff --git a/test/units/sprites/image_test.rb b/test/units/sprites/image_test.rb index f5a11a50..ae060c35 100644 --- a/test/units/sprites/image_test.rb +++ b/test/units/sprites/image_test.rb @@ -19,8 +19,8 @@ class SpritesImageTest < Test::Unit::TestCase let(:sprite_name) { File.basename(sprite_filename, '.png') } def parent - map = Compass::SpriteMap.new(:uri => "selectors/*.png", :options => options) - @parent ||= Compass::SassExtensions::Sprites::Base.new(map.sprite_names.map{|n| "selectors/#{n}.png"}, map, map.sass_engine, map.options) + importer = Compass::SpriteImporter.new(:uri => "selectors/*.png", :options => options) + @parent ||= Compass::SassExtensions::Sprites::Base.new(importer.sprite_names.map{|n| "selectors/#{n}.png"}, importer.path, importer.name, importer.sass_engine, importer.options) end let(:options) do