Skip to content

Commit eff65e3

Browse files
committed
Sprite clean up move stuff from core
* Remove Imported injection from compass core * Move Sprite stylesheets into sprite gem * Updated tests
1 parent 409a7b0 commit eff65e3

File tree

11 files changed

+30
-40
lines changed

11 files changed

+30
-40
lines changed

compass-style.org/content/help/tutorials/spriting.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Each is an icon that is 32px square.
3636

3737
The simplest way to use these icon sprites is to let compass give you a class for each sprite:
3838

39-
@import "compass/utilities/sprites";
39+
@import "compass/sprites";
4040
@import "my-icons/*.png";
4141
@include all-my-icons-sprites;
4242

@@ -116,7 +116,7 @@ And your stylesheet will compile to:
116116
Getting the image dimensions of a sprite
117117

118118
You can get a unit value by using the magical dimension functions `<map>-sprite-height` and `<map>-sprite-width`
119-
If you are looking to just return the dimensions see the [docs](/reference/compass/utilities/sprites/base/#mixin-sprite-dimensions)
119+
If you are looking to just return the dimensions see the [docs](/reference/compass/sprites/base/#mixin-sprite-dimensions)
120120

121121
Example:
122122

core/lib/compass/configuration/adapters.rb

-10
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ def to_sass_plugin_options
3535
plugin_opts.merge!(sass_options || {})
3636
plugin_opts[:load_paths] ||= []
3737
plugin_opts[:load_paths] += resolve_additional_import_paths
38-
# TODO: When sprites are extracted to their own plugin, this
39-
# TODO: will need to be extracted to there.
40-
if defined?(Compass::Sprites::Importer.new)
41-
plugin_opts[:load_paths] << Compass::Sprites::Importer.new
42-
end
4338
plugin_opts[:full_exception] = (environment == :development)
4439
plugin_opts
4540
end
@@ -93,11 +88,6 @@ def sass_load_paths
9388
next p if p.respond_to?(:find_relative)
9489
importer.new(p.to_s)
9590
end
96-
# TODO: When sprites are extracted to their own plugin, this
97-
# TODO: will need to be extracted to there.
98-
if defined?(Compass::Sprites::Importer.new)
99-
load_paths << Compass::Sprites::Importer.new
100-
end
10191
load_paths
10292
end
10393

core/stylesheets/compass/_utilities.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import "utilities/color";
22
@import "utilities/general";
3-
@import "utilities/sprites";
43
@import "utilities/tables";
54

65
// deprecated

sprites/lib/compass/sprites.rb

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
require 'compass/sprites/importer'
22
require 'compass/sprites/version'
3+
stylesheet_dir = File.expand_path('../../../stylesheets', __FILE__)
34
config = Compass::Configuration::Data.new("compass-sprites")
45
config.add_import_path(Compass::Sprites::Importer.new)
6+
config.add_import_path(stylesheet_dir)
57
Compass.add_configuration(config)
8+
9+
10+
Compass::Frameworks.register('sprite-framework',
11+
:stylesheets_directory => stylesheet_dir
12+
)

sprites/lib/compass/sprites/importer/content.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "compass/utilities/sprites/base";
1+
@import "compass/sprites/base";
22

33
// General Sprite Defaults
44
// You can override them before you import this file.

sprites/test/helpers/sprite_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require "compass/sprites"
12
module Compass::Sprites::Test::SpriteHelper
23
URI = "selectors/*.png"
34

sprites/test/integrations/sprites_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ def clean(string)
939939

940940
it "should replace text with images and dimensions using sprites" do
941941
css = render <<-SCSS
942-
@import "compass/utilities/sprites/sprite-img";
942+
@import "compass/sprites/sprite-img";
943943
@import "colors/*.png";
944944
.blue {
945945
@include sprite-replace-text($colors-sprites, blue);

sprites/test/units/sprite_map_test.rb

+18-25
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class SpriteMapTest < Test::Unit::TestCase
44
include SpriteHelper
5-
5+
66
def setup
77
Hash.send(:include, Compass::Sprites::SassExtensions::Functions::VariableReader)
88
create_sprite_temp
@@ -20,40 +20,40 @@ def teardown
2020
clean_up_sprites
2121
@base = nil
2222
end
23-
23+
2424
def test_should_have_the_correct_size
2525
assert_equal [10,40], @base.size
2626
end
27-
27+
2828
def test_should_have_the_sprite_names
2929
assert_equal Compass::Sprites::Importer.sprite_names(URI), @base.sprite_names
3030
end
31-
31+
3232
def test_should_have_image_filenames
3333
assert_equal Dir["#{@images_tmp_path}/selectors/*.png"].sort, @base.image_filenames
3434
end
35-
35+
3636
def test_should_need_generation
3737
assert @base.generation_required?
3838
end
39-
40-
def test_uniqueness_hash
39+
40+
def test_uniqueness_hash
4141
assert_equal '4c703bbc05', @base.uniqueness_hash
4242
end
43-
43+
4444
def test_should_be_outdated
4545
assert @base.outdated?
4646
end
4747

4848
def test_should_have_correct_filename
4949
assert_equal File.join(@images_tmp_path, "#{@base.path}-s#{@base.uniqueness_hash}.png"), @base.filename
5050
end
51-
52-
def test_should_return_the_ten_by_ten_image
51+
52+
def test_should_return_the_ten_by_ten_image
5353
assert_equal 'ten-by-ten', @base.image_for('ten-by-ten').name
5454
assert @base.image_for('ten-by-ten').is_a?(Compass::Sprites::SassExtensions::Image)
5555
end
56-
56+
5757
def test_should_have_selectors
5858
%w(target hover active).each do |selector|
5959
assert @base.send(:"has_#{selector}?", 'ten-by-ten')
@@ -76,7 +76,7 @@ def test_should_generate_sprite
7676
assert !@base.generation_required?
7777
assert !@base.outdated?
7878
end
79-
79+
8080
def test_should_remove_old_sprite_when_generating_new
8181
@base.generate
8282
file = @base.filename
@@ -88,10 +88,8 @@ def test_should_remove_old_sprite_when_generating_new
8888
@base.generate
8989
assert !File.exists?(file), "Sprite file did not get removed"
9090
end
91-
91+
9292
def test_should_get_correct_relative_name
93-
Compass.reset_configuration!
94-
uri = 'foo/*.png'
9593
other_folder = File.join(@images_tmp_path, '../other-temp')
9694
FileUtils.mkdir_p other_folder
9795
FileUtils.mkdir_p File.join(other_folder, 'foo')
@@ -105,21 +103,19 @@ def test_should_get_correct_relative_name
105103
assert_equal 'foo/my.png', Compass::Sprites::SassExtensions::SpriteMap.relative_name(File.join(other_folder, 'foo/my.png'))
106104
FileUtils.rm_rf other_folder
107105
end
108-
106+
109107
def test_should_get_correct_relative_name_for_directories_with_similar_names
110-
Compass.reset_configuration!
111-
uri = 'foo/*.png'
112108
other_folder = File.join(@images_tmp_path, '../other-temp')
113109
other_folder2 = File.join(@images_tmp_path, '../other-temp2')
114110

115111
FileUtils.mkdir_p other_folder
116112
FileUtils.mkdir_p other_folder2
117-
113+
118114
FileUtils.mkdir_p File.join(other_folder2, 'foo')
119115
%w(my bar).each do |file|
120116
FileUtils.touch(File.join(other_folder2, "foo/#{file}.png"))
121117
end
122-
118+
123119
config = Compass::Configuration::Data.new('config')
124120
config.images_path = @images_tmp_path
125121
config.sprite_load_path = [@images_tmp_path, other_folder, other_folder2]
@@ -130,22 +126,20 @@ def test_should_get_correct_relative_name_for_directories_with_similar_names
130126
FileUtils.rm_rf other_folder
131127
FileUtils.rm_rf other_folder2
132128
end
133-
129+
134130
test "should create map for nested" do
135131
base = Compass::Sprites::SassExtensions::SpriteMap.from_uri OpenStruct.new(:value => 'nested/squares/*.png'), @base.instance_variable_get(:@evaluation_context), @options
136132
assert_equal 'squares', base.name
137133
assert_equal 'nested/squares', base.path
138134
end
139-
135+
140136
test "should have correct position on ten-by-ten" do
141137
percent = Sass::Script::Number.new(50, ['%'])
142138
base = sprite_map_test(@options.merge('selectors_ten_by_ten_position' => percent))
143139
assert_equal percent, base.image_for('ten-by-ten').position
144140
end
145141

146142
test 'gets name for sprite in search path' do
147-
Compass.reset_configuration!
148-
uri = 'foo/*.png'
149143
other_folder = File.join(@images_tmp_path, '../other-temp')
150144
FileUtils.mkdir_p other_folder
151145
FileUtils.mkdir_p File.join(other_folder, 'foo')
@@ -160,5 +154,4 @@ def test_should_get_correct_relative_name_for_directories_with_similar_names
160154
assert_equal File.expand_path(File.join(other_folder, 'foo/my.png')), image.file
161155
assert_equal 0, image.size
162156
end
163-
164157
end

0 commit comments

Comments
 (0)