Skip to content

Commit 203e75e

Browse files
committed
sprite tests are green
1 parent c5eff2a commit 203e75e

30 files changed

+82
-86
lines changed

cli/lib/compass/sass_extensions.rb

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ module SassExtensions
88
end
99

1010
require 'compass/sass_extensions/functions'
11-
require 'compass/sass_extensions/sprites'

cli/lib/compass/sass_extensions/functions.rb

-8
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,3 @@ def declare(*args)
55
end
66
end
77
end
8-
9-
%w(sprites).each do |func|
10-
require "compass/sass_extensions/functions/#{func}"
11-
end
12-
13-
module Sass::Script::Functions
14-
include Compass::SassExtensions::Functions::Sprites
15-
end

cli/lib/compass/sass_extensions/sprites.rb

-20
This file was deleted.

sprites/Gemfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PATH
55
chunky_png (~> 1.2.9)
66

77
PATH
8-
remote: /Users/sdavis/OSS/compass/cli
8+
remote: /Volumes/SSD/oss/compass/cli
99
specs:
1010
compass (1.0.0.alpha.17)
1111
chunky_png (~> 1.2)
@@ -16,14 +16,14 @@ PATH
1616
sass (~> 3.3.0.rc.1)
1717

1818
PATH
19-
remote: /Users/sdavis/OSS/compass/core
19+
remote: /Volumes/SSD/oss/compass/core
2020
specs:
2121
compass-core (1.0.0.alpha.16)
2222
multi_json (~> 1.0)
2323
sass (>= 3.3.rc.1)
2424

2525
PATH
26-
remote: /Users/sdavis/OSS/compass/import-once
26+
remote: /Volumes/SSD/oss/compass/import-once
2727
specs:
2828
compass-import-once (1.0.1)
2929

@@ -41,7 +41,7 @@ GEM
4141
metaclass (0.0.1)
4242
mocha (0.14.0)
4343
metaclass (~> 0.0.1)
44-
multi_json (1.8.2)
44+
multi_json (1.8.4)
4545
oily_png (1.1.0)
4646
chunky_png (~> 1.2.7)
4747
rake (10.1.1)

sprites/lib/compass/sprites/importer.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'erb'
22
require 'compass'
3+
require 'compass/sprites/sass_extensions/sprites'
34
require 'compass/sprites/importer/binding'
45

56
module Compass
@@ -122,7 +123,7 @@ def self.content_for_images(uri, name, skip_overrides = false)
122123
private
123124

124125
def self.valid_extensions
125-
@valid_extensions ||= SassExtensions::Sprites::SpriteMap.sprite_engine_class::VALID_EXTENSIONS
126+
@valid_extensions ||= Compass::Sprites::SassExtensions::SpriteMap.sprite_engine_class::VALID_EXTENSIONS
126127
end
127128

128129
def self.sprite_importer_regex_with_ext

cli/lib/compass/sass_extensions/sprites/engines.rb renamed to sprites/lib/compass/sprites/sass_extensions/engines.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def save(filename)
2222
end
2323
end
2424

25-
require 'compass/sass_extensions/sprites/engines/chunky_png_engine'
25+
require 'compass/sprites/sass_extensions/engines/chunky_png_engine'

cli/lib/compass/sass_extensions/functions/sprites.rb renamed to sprites/lib/compass/sprites/sass_extensions/functions.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Compass::SassExtensions::Functions::Sprites
1+
module Compass::Sprites::SassExtensions::Functions
22

33
extend Compass::SassExtensions::Functions::SassDeclarationHelper
44
extend Sass::Script::Value::Helpers
@@ -75,7 +75,7 @@ def inline_sprite(map)
7575
# the first time it is converted to a url. Simply constructing it has no side-effects.
7676
def sprite_map(glob, kwargs = {})
7777
kwargs.extend VariableReader
78-
Compass::SassExtensions::Sprites::SpriteMap.from_uri(glob, self, kwargs)
78+
Compass::Sprites::SassExtensions::SpriteMap.from_uri(glob, self, kwargs)
7979
end
8080
declare :sprite_map, [:glob], :var_kwargs => true
8181

@@ -283,7 +283,7 @@ def convert_sprite_name(sprite)
283283
end
284284

285285
def verify_map(map, error = "sprite")
286-
unless map.is_a?(Compass::SassExtensions::Sprites::SpriteMap)
286+
unless map.is_a?(Compass::Sprites::SassExtensions::SpriteMap)
287287
missing_sprite!(error)
288288
end
289289
end

cli/lib/compass/sass_extensions/sprites/image.rb renamed to sprites/lib/compass/sprites/sass_extensions/image.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
class Image
55
include Sass::Script::Value::Helpers
66
ACTIVE = %r{[_-]active$}

cli/lib/compass/sass_extensions/sprites/image_methods.rb renamed to sprites/lib/compass/sprites/sass_extensions/image_methods.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module ImageMethods
55
# Fetches the Sprite::Image object for the supplied name
66
def image_for(name)

cli/lib/compass/sass_extensions/sprites/image_row.rb renamed to sprites/lib/compass/sprites/sass_extensions/image_row.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require 'forwardable'
22

33
module Compass
4-
module SassExtensions
5-
module Sprites
4+
module Sprites
5+
module SassExtensions
66
class ImageRow
77
extend Forwardable
88

cli/lib/compass/sass_extensions/sprites/images.rb renamed to sprites/lib/compass/sprites/sass_extensions/images.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
class Images < Array
55

66
def sort_by!(method)

cli/lib/compass/sass_extensions/sprites/layout.rb renamed to sprites/lib/compass/sprites/sass_extensions/layout.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'rational'
22
module Compass
3-
module SassExtensions
4-
module Sprites
3+
module Sprites
4+
module SassExtensions
55
module Layout
66
class SpriteLayout
77

cli/lib/compass/sass_extensions/sprites/layout/diagonal.rb renamed to sprites/lib/compass/sprites/sass_extensions/layout/diagonal.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module Layout
55
class Diagonal < SpriteLayout
66

cli/lib/compass/sass_extensions/sprites/layout/horizontal.rb renamed to sprites/lib/compass/sprites/sass_extensions/layout/horizontal.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module Layout
55
class Horizontal < SpriteLayout
66

cli/lib/compass/sass_extensions/sprites/layout/smart.rb renamed to sprites/lib/compass/sprites/sass_extensions/layout/smart.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module Layout
55
class Smart < SpriteLayout
66

cli/lib/compass/sass_extensions/sprites/layout/vertical.rb renamed to sprites/lib/compass/sprites/sass_extensions/layout/vertical.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module Layout
55
class Vertical < SpriteLayout
66

cli/lib/compass/sass_extensions/sprites/layout_methods.rb renamed to sprites/lib/compass/sprites/sass_extensions/layout_methods.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module LayoutMethods
55
HORIZONTAL = 'horizontal'
66
DIAGONAL = 'diagonal'
@@ -32,16 +32,16 @@ def layout
3232
def compute_image_positions!
3333
case layout
3434
when SMART
35-
require 'compass/sass_extensions/sprites/layout/smart'
35+
require 'compass/sprites/sass_extensions/layout/smart'
3636
@images, @width, @height = Layout::Smart.new(@images, @kwargs).properties
3737
when DIAGONAL
38-
require 'compass/sass_extensions/sprites/layout/diagonal'
38+
require 'compass/sprites/sass_extensions/layout/diagonal'
3939
@images, @width, @height = Layout::Diagonal.new(@images, @kwargs).properties
4040
when HORIZONTAL
41-
require 'compass/sass_extensions/sprites/layout/horizontal'
41+
require 'compass/sprites/sass_extensions/layout/horizontal'
4242
@images, @width, @height = Layout::Horizontal.new(@images, @kwargs).properties
4343
else
44-
require 'compass/sass_extensions/sprites/layout/vertical'
44+
require 'compass/sprites/sass_extensions/layout/vertical'
4545
@images, @width, @height = Layout::Vertical.new(@images, @kwargs).properties
4646
end
4747
end

cli/lib/compass/sass_extensions/sprites/row_fitter.rb renamed to sprites/lib/compass/sprites/sass_extensions/row_fitter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def efficiency
3939

4040
private
4141
def new_row(image = nil)
42-
row = Compass::SassExtensions::Sprites::ImageRow.new(width)
42+
row = Compass::Sprites::SassExtensions::ImageRow.new(width)
4343
row.add(image) if image
4444
row
4545
end

cli/lib/compass/sass_extensions/sprites/sprite_map.rb renamed to sprites/lib/compass/sprites/sass_extensions/sprite_map.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
class SpriteMap < Sass::Script::Value::Base
55
attr_accessor :image_names, :path, :name, :map, :kwargs
66
attr_accessor :images, :width, :height, :engine

cli/lib/compass/sass_extensions/sprites/sprite_methods.rb renamed to sprites/lib/compass/sprites/sass_extensions/sprite_methods.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Compass
2-
module SassExtensions
3-
module Sprites
2+
module Sprites
3+
module SassExtensions
44
module SpriteMethods
55

66
# Changing this string will invalidate all previously generated sprite images.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Compass
2+
module Sprites
3+
module SassExtensions
4+
end
5+
end
6+
end
7+
8+
require 'digest/md5'
9+
require 'compass/sprites/sass_extensions/functions'
10+
require 'compass/sprites/sass_extensions/images'
11+
require 'compass/sprites/sass_extensions/layout'
12+
require 'compass/sprites/sass_extensions/image_row'
13+
require 'compass/sprites/sass_extensions/row_fitter'
14+
require 'compass/sprites/sass_extensions/image'
15+
require 'compass/sprites/sass_extensions/layout_methods'
16+
require 'compass/sprites/sass_extensions/sprite_methods'
17+
require 'compass/sprites/sass_extensions/image_methods'
18+
require 'compass/sprites/sass_extensions/sprite_map'
19+
require 'compass/sprites/sass_extensions/engines'
20+
require 'compass/sprites/importer'
21+
22+
module Sass::Script::Functions
23+
include Compass::Sprites::SassExtensions::Functions
24+
end

sprites/test/helpers/sprite_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def sprite_map_test(options, uri = URI)
1414
path, name = Compass::Sprites::Importer.path_and_name(uri)
1515
sprite_names = Compass::Sprites::Importer.sprite_names(uri)
1616
sass_engine = Compass::Sprites::Importer.sass_engine(uri, name, importer, options)
17-
map = Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map{|n| uri.gsub('*', n)}, path, name, sass_engine, options)
17+
map = Compass::Sprites::SassExtensions::SpriteMap.new(sprite_names.map{|n| uri.gsub('*', n)}, path, name, sass_engine, options)
1818
map.options = {:compass => {:logger => Compass::NullLogger.new}}
1919
map
2020
end

sprites/test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def sprite_map_test(options, uri = URI)
5050
path, name = Compass::Sprites::Importer.path_and_name(uri)
5151
sprite_names = Compass::Sprites::Importer.sprite_names(uri)
5252
sass_engine = Compass::Sprites::Importer.sass_engine(uri, name, importer, options)
53-
map = Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map{|n| uri.gsub('*', n)}, path, name, sass_engine, options)
53+
map = Compass::Sprites::SassExtensions::SpriteMap.new(sprite_names.map{|n| uri.gsub('*', n)}, path, name, sass_engine, options)
5454
map.options = {:compass => {:logger => Compass::NullLogger.new}}
5555
map
5656
end

sprites/test/units/engine_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def setup
66
create_sprite_temp
77
sprite_filename = 'squares/ten-by-ten.png'
88
@images = [
9-
Compass::SassExtensions::Sprites::Image.new(nil, File.join(sprite_filename), {})
9+
Compass::Sprites::SassExtensions::Image.new(nil, File.join(sprite_filename), {})
1010
]
1111
@engine = Compass::SassExtensions::Sprites::Engine.new(100, 100, @images)
1212
end

sprites/test/units/image_row_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup
1111
@image_files = Dir["#{@images_src_path}/image_row/*.png"].sort
1212
@images = @image_files.map do |img|
1313
img.gsub!("#{@images_src_path}/", '')
14-
Compass::SassExtensions::Sprites::Image.new(nil, img, {})
14+
Compass::Sprites::SassExtensions::Image.new(nil, img, {})
1515
end
1616
image_row(1000)
1717
end
@@ -21,7 +21,7 @@ def teardown
2121
end
2222

2323
def image_row(max)
24-
@image_row = Compass::SassExtensions::Sprites::ImageRow.new(max)
24+
@image_row = Compass::Sprites::SassExtensions::ImageRow.new(max)
2525
end
2626

2727
def populate_row
@@ -32,7 +32,7 @@ def populate_row
3232

3333
def test_should_return_false_if_image_will_not_fit_in_row
3434
image_row(100)
35-
img = Compass::SassExtensions::Sprites::Image.new(nil, File.join('image_row', 'large.png'), {})
35+
img = Compass::Sprites::SassExtensions::Image.new(nil, File.join('image_row', 'large.png'), {})
3636
assert !@image_row.add(img)
3737
end
3838

sprites/test/units/images_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require 'test_helper'
2-
require 'compass/sass_extensions/sprites/images'
2+
require 'compass/sprites/sass_extensions/images'
33

44
class ImagesTest < Test::Unit::TestCase
55

66
def setup
7-
@images = Compass::SassExtensions::Sprites::Images.new
7+
@images = Compass::Sprites::SassExtensions::Images.new
88
@images << OpenStruct.new(:foo => 1, :name => 'bob', :size => 1200, :width => 10)
99
@images << OpenStruct.new(:foo => 2, :name => 'bob', :size => 300, :width => 100)
1010
@images << OpenStruct.new(:foo => 3, :name => 'aob', :size => 120, :width => 50)

sprites/test/units/layout_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class LayoutTest < Test::Unit::TestCase
44
include SpriteHelper
55

66
def setup
7-
Hash.send(:include, Compass::SassExtensions::Functions::Sprites::VariableReader)
7+
Hash.send(:include, Compass::Sprites::SassExtensions::Functions::VariableReader)
88
clean_up_sprites
99
create_sprite_temp
1010
file = StringIO.new("images_path = #{@images_tmp_path.inspect}\n")
@@ -32,7 +32,7 @@ def smart
3232
path, name = Compass::Sprites::Importer.path_and_name(uri)
3333
sprite_names = Compass::Sprites::Importer.sprite_names(uri)
3434
sass_engine = Compass::Sprites::Importer.sass_engine(uri, name, importer, options)
35-
map = Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map {|n| "image_row/#{n}.png"}, path, name, sass_engine, options)
35+
map = Compass::Sprites::SassExtensions::SpriteMap.new(sprite_names.map {|n| "image_row/#{n}.png"}, path, name, sass_engine, options)
3636
map.options = {:compass => {:logger => Compass::NullLogger.new}}
3737

3838
map
@@ -177,4 +177,4 @@ def test_should_generate_a_horrizontal_sprite
177177
FileUtils.rm base.filename
178178
end
179179

180-
end
180+
end

sprites/test/units/row_fitter_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'test_helper'
2-
require 'compass/sass_extensions/sprites/row_fitter'
2+
require 'compass/sprites/sass_extensions/row_fitter'
33

44
class RowFitterTest < Test::Unit::TestCase
55
include SpriteHelper
@@ -18,7 +18,7 @@ def teardown
1818

1919
def create_images(dims)
2020
dims.collect { |width, height|
21-
image = Compass::SassExtensions::Sprites::Image.new('blah', 'blah', {})
21+
image = Compass::Sprites::SassExtensions::Image.new('blah', 'blah', {})
2222
image.stubs(:width => width, :height => height)
2323
image
2424
}

0 commit comments

Comments
 (0)