Merge branch 'master' into rails31
* master: Prepare the next release version Fix CSS3 background attribute Version Bump & Prepare for v0.11.2 Strong tags in the docs should be bold. Fixes sprites file names with sprockets, modifies tests accordingly to new structure. removed all cacheing from importer class it causes more problems then it was worth gemfile removed another instance cache in the importer that could be problematic updated importer to validate that sprites are png files run bundle exec when running tests cleaned up some over zelious cacheing that was causing inconsistancy problems added test for sprite importer removed unneeded cache readded mtime to importer class typo: appliction Update test case for flexible box. Enable IE 10 support for flexible box with the -ms prefix.
This commit is contained in:
commit
ba5bec3e09
@ -4,3 +4,4 @@ rvm:
|
||||
- jruby
|
||||
- rbx
|
||||
- ree
|
||||
script: "bundle exec rake test"
|
||||
|
@ -7,7 +7,7 @@ GIT
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
compass (0.11.1.d9e4054)
|
||||
compass (0.11.1.f248c22)
|
||||
chunky_png (~> 1.1)
|
||||
fssm (>= 0.2.7)
|
||||
sass (~> 3.1)
|
||||
@ -50,7 +50,7 @@ GEM
|
||||
autotest-fsevent (0.2.5)
|
||||
sys-uname
|
||||
builder (2.1.2)
|
||||
chunky_png (1.1.1)
|
||||
chunky_png (1.2.0)
|
||||
compass-validator (3.0.0)
|
||||
css_parser (1.0.1)
|
||||
cucumber (0.9.4)
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
:major: 0
|
||||
:minor: 11
|
||||
:build: 1
|
||||
:patch: 3
|
||||
:state: rc
|
||||
:build: 0
|
||||
:name: Antares
|
||||
|
@ -14,16 +14,13 @@ The Documentation for the [latest stable release](http://compass-style.org/docs/
|
||||
|
||||
The Documentation for the [latest preview release](http://beta.compass-style.org/)
|
||||
|
||||
0.11.3 (PENDING)
|
||||
0.11.2 (06/10/2011)
|
||||
-------------------
|
||||
* Sprites will now by default remove any old versions of the sprite a new variable has been created to override this.
|
||||
* Sprites will now by default remove any old versions of the sprite. A new configuration
|
||||
variable has been created to override this.
|
||||
* Nested sprites are now supported using globs `@import 'nested/**/*.png';`.
|
||||
* Fixed a bug that was causing sprite variable options to not get passed to the image classes.
|
||||
* Sass Colors will no longer cause an error if you use them as sprite names.
|
||||
|
||||
0.11.2 (05/01/2011)
|
||||
-------------------
|
||||
|
||||
* Added support for -ms gradients in background-image and background properties
|
||||
* Give a better error if Sass::Script::Functions.declare does not exist.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Application Integration
|
||||
layout: tutorial
|
||||
crumb: Appliction Integration
|
||||
crumb: Application Integration
|
||||
classnames:
|
||||
- tutorial
|
||||
---
|
||||
|
@ -25,7 +25,7 @@ classnames:
|
||||
Example (more examples are available by following the links below):
|
||||
|
||||
<pre><code class="source-code scss">.in-css3 {
|
||||
background: image-url("foo.png"),
|
||||
background: url(foo.png),
|
||||
linear-gradient(top left, #333, #0c0),
|
||||
radial-gradient(#c00, #fff 100px);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
// display:box; must be used for any of the other flexbox mixins to work properly
|
||||
@mixin display-box {
|
||||
@include experimental-value(display, box,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ $default-box-orient: horizontal !default;
|
||||
) {
|
||||
$orientation : unquote($orientation);
|
||||
@include experimental(box-orient, $orientation,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ $default-box-align: stretch !default;
|
||||
) {
|
||||
$alignment : unquote($alignment);
|
||||
@include experimental(box-align, $alignment,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ $default-box-flex: 0 !default;
|
||||
$flex: $default-box-flex
|
||||
) {
|
||||
@include experimental(box-flex, $flex,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ $default-box-flex-group: 1 !default;
|
||||
$group: $default-box-flex-group
|
||||
) {
|
||||
@include experimental(box-flex-group, $group,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ $default-box-ordinal-group: 1 !default;
|
||||
$group: $default-ordinal-flex-group
|
||||
) {
|
||||
@include experimental(box-ordinal-group, $group,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ $default-box-direction: normal !default;
|
||||
) {
|
||||
$direction: unquote($direction);
|
||||
@include experimental(box-direction, $direction,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ $default-box-lines: single !default;
|
||||
) {
|
||||
$lines: unquote($lines);
|
||||
@include experimental(box-lines, $lines,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
||||
|
||||
@ -106,6 +106,6 @@ $default-box-pack: start !default;
|
||||
) {
|
||||
$pack: unquote($pack);
|
||||
@include experimental(box-pack, $pack,
|
||||
-moz, -webkit, not -o, not -ms, not -khtml, official
|
||||
-moz, -webkit, not -o, -ms, not -khtml, official
|
||||
);
|
||||
}
|
@ -96,7 +96,7 @@ module Compass::SassExtensions::Functions::Sprites
|
||||
def sprite_url(map)
|
||||
verify_map(map, "sprite-url")
|
||||
map.generate
|
||||
image_url(Sass::Script::String.new("#{map.path}-#{map.uniqueness_hash}.png"),
|
||||
image_url(Sass::Script::String.new("#{map.path}-s#{map.uniqueness_hash}.png"),
|
||||
Sass::Script::Bool.new(false),
|
||||
Sass::Script::Bool.new(false))
|
||||
end
|
||||
|
@ -114,7 +114,7 @@ module Compass
|
||||
|
||||
# The on-the-disk filename of the sprite
|
||||
def filename
|
||||
File.join(Compass.configuration.images_path, "#{path}-#{uniqueness_hash}.png")
|
||||
File.join(Compass.configuration.images_path, "#{path}-s#{uniqueness_hash}.png")
|
||||
end
|
||||
|
||||
# Generate a sprite image if necessary
|
||||
|
@ -3,14 +3,13 @@ module Compass
|
||||
attr_accessor :uri, :options
|
||||
VAILD_FILE_NAME = /\A#{Sass::SCSS::RX::IDENT}\Z/
|
||||
SPRITE_IMPORTER_REGEX = %r{((.+/)?([^\*.]+))/(.+?)\.png}
|
||||
VALID_EXTENSIONS = ['.png']
|
||||
|
||||
def self.load(uri, options)
|
||||
Compass.quick_cache "Sprite_map:#{uri}#{options.inspect}", 5 do
|
||||
klass = Compass::SpriteImporter.new
|
||||
klass.uri, klass.options = uri, options
|
||||
klass
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options ={})
|
||||
@uri, @options = '', {}
|
||||
@ -43,7 +42,12 @@ module Compass
|
||||
other.class == self.class
|
||||
end
|
||||
|
||||
|
||||
def mtime(uri, options)
|
||||
@uri, @options = uri, options
|
||||
files.sort.inject(Time.at(0)) do |max_time, file|
|
||||
(t = File.mtime(file)) > max_time ? t : max_time
|
||||
end
|
||||
end
|
||||
|
||||
def key(uri, options={})
|
||||
@uri, @options = uri, options
|
||||
@ -51,12 +55,10 @@ module Compass
|
||||
end
|
||||
|
||||
def self.path_and_name(uri)
|
||||
Compass.quick_cache "Sprite_map_name:#{uri}", 5 do
|
||||
if uri =~ SPRITE_IMPORTER_REGEX
|
||||
[$1, $3]
|
||||
else
|
||||
[nil, nil]
|
||||
end
|
||||
raise Compass::Error "invalid sprite path"
|
||||
end
|
||||
end
|
||||
|
||||
@ -74,12 +76,12 @@ module Compass
|
||||
|
||||
# Returns the Glob of image files for this sprite
|
||||
def files
|
||||
@files ||= Dir[File.join(Compass.configuration.images_path, uri)].sort
|
||||
Dir[File.join(Compass.configuration.images_path, uri)].sort
|
||||
end
|
||||
|
||||
# Returns an Array of image names without the file extension
|
||||
def sprite_names
|
||||
@sprite_names ||= files.collect do |file|
|
||||
files.collect do |file|
|
||||
filename = File.basename(file, '.png')
|
||||
unless VAILD_FILE_NAME =~ filename
|
||||
raise Compass::Error, "Sprite file names must be legal css identifiers. Please rename #{File.basename(file)}"
|
||||
@ -88,13 +90,22 @@ module Compass
|
||||
end
|
||||
end
|
||||
|
||||
def validate_sprites!
|
||||
files.each do |file|
|
||||
unless VALID_EXTENSIONS.include? File.extname(file)
|
||||
raise Compass::Error, "Invalid sprite extension only: #{VALID_EXTENSIONS.join(',')} images are allowed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the sass options for this sprite
|
||||
def sass_options
|
||||
@sass_options ||= options.merge(:filename => name, :syntax => :scss, :importer => self)
|
||||
options.merge(:filename => name, :syntax => :scss, :importer => self)
|
||||
end
|
||||
|
||||
# Returns a Sass::Engine for this sprite object
|
||||
def sass_engine
|
||||
validate_sprites!
|
||||
Sass::Engine.new(content_for_images, sass_options)
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ describe Compass::SassExtensions::Sprites::Base do
|
||||
its(:generation_required?) { should be_true }
|
||||
its(:uniqueness_hash) { should == 'ef52c5c63a'}
|
||||
its(:outdated?) { should be_true }
|
||||
its(:filename) { should == File.join(@images_tmp_path, "#{@base.path}-#{@base.uniqueness_hash}.png")}
|
||||
its(:filename) { should == File.join(@images_tmp_path, "#{@base.path}-s#{@base.uniqueness_hash}.png")}
|
||||
|
||||
it "should return the 'ten-by-ten' image" do
|
||||
subject.image_for('ten-by-ten').name.should == 'ten-by-ten'
|
||||
|
BIN
test/fixtures/sprites/public/images/bad_extensions/ten-by-ten.gif
vendored
Normal file
BIN
test/fixtures/sprites/public/images/bad_extensions/ten-by-ten.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/bad_extensions/twenty-by-twenty.jpg
vendored
Normal file
BIN
test/fixtures/sprites/public/images/bad_extensions/twenty-by-twenty.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
19
test/fixtures/stylesheets/compass/css/box.css
vendored
19
test/fixtures/stylesheets/compass/css/box.css
vendored
@ -1,84 +1,103 @@
|
||||
.hbox {
|
||||
display: -moz-box;
|
||||
display: -webkit-box;
|
||||
display: -ms-box;
|
||||
display: box;
|
||||
-moz-box-orient: horizontal;
|
||||
-webkit-box-orient: horizontal;
|
||||
-ms-box-orient: horizontal;
|
||||
box-orient: horizontal;
|
||||
-moz-box-align: stretch;
|
||||
-webkit-box-align: stretch;
|
||||
-ms-box-align: stretch;
|
||||
box-align: stretch; }
|
||||
.hbox > * {
|
||||
-moz-box-flex: 0;
|
||||
-webkit-box-flex: 0;
|
||||
-ms-box-flex: 0;
|
||||
box-flex: 0; }
|
||||
|
||||
.vbox {
|
||||
display: -moz-box;
|
||||
display: -webkit-box;
|
||||
display: -ms-box;
|
||||
display: box;
|
||||
-moz-box-orient: vertical;
|
||||
-webkit-box-orient: vertical;
|
||||
-ms-box-orient: vertical;
|
||||
box-orient: vertical;
|
||||
-moz-box-align: stretch;
|
||||
-webkit-box-align: stretch;
|
||||
-ms-box-align: stretch;
|
||||
box-align: stretch; }
|
||||
.vbox > * {
|
||||
-moz-box-flex: 0;
|
||||
-webkit-box-flex: 0;
|
||||
-ms-box-flex: 0;
|
||||
box-flex: 0; }
|
||||
|
||||
.spacer {
|
||||
-moz-box-flex: 1;
|
||||
-webkit-box-flex: 1;
|
||||
-ms-box-flex: 1;
|
||||
box-flex: 1; }
|
||||
|
||||
.reverse {
|
||||
-moz-box-direction: reverse;
|
||||
-webkit-box-direction: reverse;
|
||||
-ms-box-direction: reverse;
|
||||
box-direction: reverse; }
|
||||
|
||||
.box-flex-0 {
|
||||
-moz-box-flex: 0;
|
||||
-webkit-box-flex: 0;
|
||||
-ms-box-flex: 0;
|
||||
box-flex: 0; }
|
||||
|
||||
.box-flex-1 {
|
||||
-moz-box-flex: 1;
|
||||
-webkit-box-flex: 1;
|
||||
-ms-box-flex: 1;
|
||||
box-flex: 1; }
|
||||
|
||||
.box-flex-2 {
|
||||
-moz-box-flex: 2;
|
||||
-webkit-box-flex: 2;
|
||||
-ms-box-flex: 2;
|
||||
box-flex: 2; }
|
||||
|
||||
.box-flex-group-0 {
|
||||
-moz-box-flex-group: 0;
|
||||
-webkit-box-flex-group: 0;
|
||||
-ms-box-flex-group: 0;
|
||||
box-flex-group: 0; }
|
||||
|
||||
.box-flex-group-1 {
|
||||
-moz-box-flex-group: 1;
|
||||
-webkit-box-flex-group: 1;
|
||||
-ms-box-flex-group: 1;
|
||||
box-flex-group: 1; }
|
||||
|
||||
.box-flex-group-2 {
|
||||
-moz-box-flex-group: 2;
|
||||
-webkit-box-flex-group: 2;
|
||||
-ms-box-flex-group: 2;
|
||||
box-flex-group: 2; }
|
||||
|
||||
.start {
|
||||
-moz-box-pack: start;
|
||||
-webkit-box-pack: start;
|
||||
-ms-box-pack: start;
|
||||
box-pack: start; }
|
||||
|
||||
.end {
|
||||
-moz-box-pack: end;
|
||||
-webkit-box-pack: end;
|
||||
-ms-box-pack: end;
|
||||
box-pack: end; }
|
||||
|
||||
.center {
|
||||
-moz-box-pack: center;
|
||||
-webkit-box-pack: center;
|
||||
-ms-box-pack: center;
|
||||
box-pack: center; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
.flag-sprite, #flags .us, #flags .au, #flags .ca, #flags .es, #flags .eg, #flags .ly, .flag-ad, .flag-ae, .flag-af, .flag-ag, .flag-ai, .flag-al, .flag-am, .flag-an, .flag-ao, .flag-ar, .flag-as, .flag-at, .flag-au, .flag-aw, .flag-ax, .flag-az, .flag-ba, .flag-bb, .flag-bd, .flag-be, .flag-bf, .flag-bg, .flag-bh, .flag-bi, .flag-bj, .flag-bm, .flag-bn, .flag-bo, .flag-br, .flag-bs, .flag-bt, .flag-bv, .flag-bw, .flag-by, .flag-bz, .flag-ca, .flag-catalonia, .flag-cc, .flag-cd, .flag-cf, .flag-cg, .flag-ch, .flag-ci, .flag-ck, .flag-cl, .flag-cm, .flag-cn, .flag-co, .flag-cr, .flag-cs, .flag-cu, .flag-cv, .flag-cx, .flag-cy, .flag-cz, .flag-de, .flag-dj, .flag-dk, .flag-dm, .flag-do, .flag-dz, .flag-ec, .flag-ee, .flag-eg, .flag-eh, .flag-england, .flag-er, .flag-es, .flag-et, .flag-europeanunion, .flag-fam, .flag-fi, .flag-fj, .flag-fk, .flag-fm, .flag-fo, .flag-fr, .flag-ga, .flag-gb, .flag-gd, .flag-ge, .flag-gf, .flag-gh, .flag-gi, .flag-gl, .flag-gm, .flag-gn, .flag-gp, .flag-gq, .flag-gr, .flag-gs, .flag-gt, .flag-gu, .flag-gw, .flag-gy, .flag-hk, .flag-hm, .flag-hn, .flag-hr, .flag-ht, .flag-hu, .flag-id-2, .flag-ie, .flag-il, .flag-in, .flag-io, .flag-iq, .flag-ir, .flag-is, .flag-it, .flag-jm, .flag-jo, .flag-jp, .flag-ke, .flag-kg, .flag-kh, .flag-ki, .flag-km, .flag-kn, .flag-kp, .flag-kr, .flag-kw, .flag-ky, .flag-kz, .flag-la, .flag-lb, .flag-lc, .flag-li, .flag-lk, .flag-lr, .flag-ls, .flag-lt, .flag-lu, .flag-lv, .flag-ly, .flag-ma, .flag-mc, .flag-md, .flag-me, .flag-mg, .flag-mh, .flag-mk, .flag-ml, .flag-mm, .flag-mn, .flag-mo, .flag-mp, .flag-mq, .flag-mr, .flag-ms, .flag-mt, .flag-mu, .flag-mv, .flag-mw, .flag-mx, .flag-my, .flag-mz, .flag-na, .flag-nc, .flag-ne, .flag-nf, .flag-ng, .flag-ni, .flag-nl, .flag-no, .flag-np, .flag-nr, .flag-nu, .flag-nz, .flag-om, .flag-pa, .flag-pe, .flag-pf, .flag-pg, .flag-ph, .flag-pk, .flag-pl, .flag-pm, .flag-pn, .flag-pr, .flag-ps, .flag-pt, .flag-pw, .flag-py, .flag-qa, .flag-re, .flag-ro, .flag-rs, .flag-ru, .flag-rw, .flag-sa, .flag-sb, .flag-sc, .flag-scotland, .flag-sd, .flag-se, .flag-sg, .flag-sh, .flag-si, .flag-sj, .flag-sk, .flag-sl, .flag-sm, .flag-sn, .flag-so, .flag-sr, .flag-st, .flag-sv, .flag-sy, .flag-sz, .flag-tc, .flag-td, .flag-tf, .flag-tg, .flag-th, .flag-tj, .flag-tk, .flag-tl, .flag-tm, .flag-tn, .flag-to, .flag-tr, .flag-tt, .flag-tv, .flag-tw, .flag-tz, .flag-ua, .flag-ug, .flag-um, .flag-us, .flag-uy, .flag-uz, .flag-va, .flag-vc, .flag-ve, .flag-vg, .flag-vi, .flag-vn, .flag-vu, .flag-wales, .flag-wf, .flag-ws, .flag-ye, .flag-yt, .flag-za, .flag-zm, .flag-zw {
|
||||
background: url('/images/flag-03c3b29b35.png') no-repeat; }
|
||||
background: url('/images/flag-s03c3b29b35.png') no-repeat; }
|
||||
|
||||
#flags .us {
|
||||
background-position: 0 -2520px;
|
||||
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
@ -59,7 +59,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
background: url('/squares-s161c60ad78.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -70,8 +70,8 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), 'fcc93d7b279c2ad6898fbca49cbd01e1'
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-s*.png'), 'fcc93d7b279c2ad6898fbca49cbd01e1'
|
||||
end
|
||||
|
||||
it "should generate sprite classes with dimensions" do
|
||||
@ -82,7 +82,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
background: url('/squares-s161c60ad78.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -97,7 +97,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
width: 20px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
end
|
||||
|
||||
it "should provide sprite mixin" do
|
||||
@ -114,7 +114,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .cubicle, .large-cube {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
background: url('/squares-s161c60ad78.png') no-repeat;
|
||||
}
|
||||
|
||||
.cubicle {
|
||||
@ -127,7 +127,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
width: 20px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
end
|
||||
|
||||
# CUSTOMIZATIONS:
|
||||
@ -139,10 +139,10 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.circles {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
background: url('/squares-s161c60ad78.png') no-repeat;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
end
|
||||
|
||||
it "should calculate the spacing between images but not before first image" do
|
||||
@ -153,7 +153,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-89450808af.png') no-repeat;
|
||||
background: url('/squares-s89450808af.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -164,7 +164,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -43px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 63]
|
||||
assert_equal image_size('squares-s*.png'), [20, 63]
|
||||
end
|
||||
|
||||
it "should calculate the spacing between images" do
|
||||
@ -175,7 +175,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-673837183a.png') no-repeat;
|
||||
background: url('/squares-s673837183a.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -186,7 +186,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -43px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 63]
|
||||
assert_equal image_size('squares-s*.png'), [20, 63]
|
||||
end
|
||||
|
||||
it "should calculate the maximum spacing between images" do
|
||||
@ -198,7 +198,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-1cd84c9068.png') no-repeat;
|
||||
background: url('/squares-s1cd84c9068.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -209,7 +209,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -54px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 74]
|
||||
assert_equal image_size('squares-s*.png'), [20, 74]
|
||||
end
|
||||
|
||||
it "should calculate the maximum spacing between images in reversed order" do
|
||||
@ -221,7 +221,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-f25b7090ca.png') no-repeat;
|
||||
background: url('/squares-sf25b7090ca.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -232,7 +232,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -54px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 74]
|
||||
assert_equal image_size('squares-s*.png'), [20, 74]
|
||||
end
|
||||
|
||||
it "should calculate the default spacing between images" do
|
||||
@ -243,7 +243,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-d66bf24bab.png') no-repeat;
|
||||
background: url('/squares-sd66bf24bab.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -254,7 +254,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -32px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 52]
|
||||
assert_equal image_size('squares-s*.png'), [20, 52]
|
||||
end
|
||||
|
||||
it "should use position adjustments in functions" do
|
||||
@ -278,7 +278,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite {
|
||||
background: url('/squares-8e490168dd.png') no-repeat;
|
||||
background: url('/squares-s8e490168dd.png') no-repeat;
|
||||
}
|
||||
|
||||
.adjusted-percentage {
|
||||
@ -293,8 +293,8 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: -3px -8px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), '652b67f5e9092520d6f26caae7e18012'
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-s*.png'), '652b67f5e9092520d6f26caae7e18012'
|
||||
end
|
||||
|
||||
it "should use position adjustments in mixins" do
|
||||
@ -316,7 +316,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .adjusted-percentage, .adjusted-px-1, .adjusted-px-2 {
|
||||
background: url('/squares-8e490168dd.png') no-repeat;
|
||||
background: url('/squares-s8e490168dd.png') no-repeat;
|
||||
}
|
||||
|
||||
.adjusted-percentage {
|
||||
@ -331,8 +331,8 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: -3px -8px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), '652b67f5e9092520d6f26caae7e18012'
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-s*.png'), '652b67f5e9092520d6f26caae7e18012'
|
||||
end
|
||||
|
||||
it "should repeat the image" do
|
||||
@ -343,7 +343,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-a5550fd132.png') no-repeat;
|
||||
background: url('/squares-sa5550fd132.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -354,8 +354,8 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), '94abae8440f1b58617f52920b70aaed2'
|
||||
assert_equal image_size('squares-s*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-s*.png'), '94abae8440f1b58617f52920b70aaed2'
|
||||
end
|
||||
|
||||
it "should allow the position of a sprite to be specified in absolute pixels" do
|
||||
@ -367,7 +367,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-89a274044e.png') no-repeat;
|
||||
background: url('/squares-s89a274044e.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
@ -378,8 +378,8 @@ class SpritesTest < Test::Unit::TestCase
|
||||
background-position: -10px -10px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [30, 30]
|
||||
assert_equal image_md5('squares-*.png'), '2fb19ef9c83018c93c6f147af3a56cb2'
|
||||
assert_equal image_size('squares-s*.png'), [30, 30]
|
||||
assert_equal image_md5('squares-s*.png'), '2fb19ef9c83018c93c6f147af3a56cb2'
|
||||
end
|
||||
|
||||
it "should provide a nice errors for lemonade's old users" do
|
||||
@ -416,7 +416,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares {
|
||||
background: url('/squares-145869726f.png') 0 -10px no-repeat;
|
||||
background: url('/squares-s145869726f.png') 0 -10px no-repeat;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
@ -432,10 +432,10 @@ class SpritesTest < Test::Unit::TestCase
|
||||
@include sprite-background-position($squares-sprites, "ten-by-ten");
|
||||
}
|
||||
SCSS
|
||||
assert_equal image_size('squares-*.png'), [20, 40]
|
||||
assert_equal image_size('squares-s*.png'), [20, 40]
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite {
|
||||
background: url('/squares-e3c68372d9.png') no-repeat;
|
||||
background: url('/squares-se3c68372d9.png') no-repeat;
|
||||
}
|
||||
|
||||
.foo {
|
||||
@ -455,7 +455,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, .selectors-ten-by-ten {
|
||||
background: url('/selectors-edfef809e2.png') no-repeat;
|
||||
background: url('/selectors-sedfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
.selectors-ten-by-ten {
|
||||
@ -482,7 +482,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, a {
|
||||
background: url('/selectors-edfef809e2.png') no-repeat;
|
||||
background: url('/selectors-sedfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
a {
|
||||
@ -510,7 +510,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, a {
|
||||
background: url('/selectors-edfef809e2.png') no-repeat;
|
||||
background: url('/selectors-sedfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
a {
|
||||
@ -538,7 +538,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.ko-sprite, .ko-default_background, .ko-starbg26x27 {
|
||||
background: url('/ko-cc3f80660d.png') no-repeat;
|
||||
background: url('/ko-scc3f80660d.png') no-repeat;
|
||||
}
|
||||
|
||||
.ko-default_background {
|
||||
@ -552,8 +552,8 @@ class SpritesTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
it "should generate a sprite and remove the old file" do
|
||||
FileUtils.touch File.join(@images_tmp_path, "selectors-cc8834Fdd.png")
|
||||
assert_equal 1, map_files('selectors-*.png').size
|
||||
FileUtils.touch File.join(@images_tmp_path, "selectors-scc8834Fdd.png")
|
||||
assert_equal 1, map_files('selectors-s*.png').size
|
||||
css = render <<-SCSS
|
||||
@import "selectors/*.png";
|
||||
a {
|
||||
@ -561,12 +561,12 @@ class SpritesTest < Test::Unit::TestCase
|
||||
@include selectors-sprite(ten-by-ten)
|
||||
}
|
||||
SCSS
|
||||
assert_equal 1, map_files('selectors-*.png').size, "File was not removed"
|
||||
assert_equal 1, map_files('selectors-s*.png').size, "File was not removed"
|
||||
end
|
||||
|
||||
it "should generate a sprite and NOT remove the old file" do
|
||||
FileUtils.touch File.join(@images_tmp_path, "selectors-cc8834Ftest.png")
|
||||
assert_equal 1, map_files('selectors-*.png').size
|
||||
FileUtils.touch File.join(@images_tmp_path, "selectors-scc8834Ftest.png")
|
||||
assert_equal 1, map_files('selectors-s*.png').size
|
||||
css = render <<-SCSS
|
||||
$selectors-clean-up: false;
|
||||
@import "selectors/*.png";
|
||||
@ -575,7 +575,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
@include selectors-sprite(ten-by-ten)
|
||||
}
|
||||
SCSS
|
||||
assert_equal 2, map_files('selectors-*.png').size, "File was removed"
|
||||
assert_equal 2, map_files('selectors-s*.png').size, "File was removed"
|
||||
end
|
||||
|
||||
it "should generate a sprite if the sprite is a colorname" do
|
||||
@ -595,7 +595,7 @@ class SpritesTest < Test::Unit::TestCase
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.nested-sprite, .nested-ten-by-ten {
|
||||
background: url('/nested-55a8935544.png') no-repeat;
|
||||
background: url('/nested-s55a8935544.png') no-repeat;
|
||||
}
|
||||
|
||||
.nested-ten-by-ten {
|
||||
|
66
test/units/sprites/importer_test.rb
Normal file
66
test/units/sprites/importer_test.rb
Normal file
@ -0,0 +1,66 @@
|
||||
require 'test_helper'
|
||||
require 'timecop'
|
||||
class ImporterTest < Test::Unit::TestCase
|
||||
URI = "selectors/*.png"
|
||||
|
||||
def setup
|
||||
@images_src_path = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'sprites', 'public', 'images')
|
||||
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
||||
Compass.add_configuration(file, "sprite_config")
|
||||
@importer = Compass::SpriteImporter.new(:uri => URI, :options => options)
|
||||
end
|
||||
|
||||
def options
|
||||
{:foo => 'bar'}
|
||||
end
|
||||
|
||||
test "load should return an instance of SpriteImporter" do
|
||||
assert Compass::SpriteImporter.load(URI, options).is_a?(Compass::SpriteImporter)
|
||||
end
|
||||
|
||||
test "name should return the sprite name" do
|
||||
assert_equal 'selectors', @importer.name
|
||||
end
|
||||
|
||||
test "path should return the sprite path" do
|
||||
assert_equal 'selectors', @importer.path
|
||||
end
|
||||
|
||||
test "should return all the sprite names" do
|
||||
assert_equal ["ten-by-ten", "ten-by-ten_active", "ten-by-ten_hover", "ten-by-ten_target"], @importer.sprite_names
|
||||
end
|
||||
|
||||
test "should have correct mtime" do
|
||||
thirtydays = Time.now.to_i + (60*60*24*30)
|
||||
file = Dir[File.join(@images_src_path, URI)].sort.first
|
||||
File.utime(thirtydays, thirtydays, file)
|
||||
assert_equal thirtydays, File.mtime(file).to_i
|
||||
assert_equal thirtydays, @importer.mtime(URI, {}).to_i
|
||||
end
|
||||
|
||||
test "should return sass engine on find" do
|
||||
assert @importer.find(URI, {}).is_a?(Sass::Engine)
|
||||
end
|
||||
|
||||
test "sass options should contain options" do
|
||||
assert_equal 'bar', @importer.sass_options[:foo]
|
||||
end
|
||||
|
||||
test "should fail givin bad sprite extensions" do
|
||||
@images_src_path = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'sprites', 'public', 'images')
|
||||
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
||||
Compass.add_configuration(file, "sprite_config")
|
||||
importer = Compass::SpriteImporter.new(:uri => 'bad_extensions/*.jpg', :options => options)
|
||||
begin
|
||||
importer.sass_engine
|
||||
assert false, "Somthing happened an invalid sprite file made it past validation"
|
||||
rescue Compass::Error => e
|
||||
assert e.message.include?('.png')
|
||||
end
|
||||
end
|
||||
|
||||
def taredown
|
||||
Compass.reset_configuration!
|
||||
end
|
||||
|
||||
end
|
@ -49,7 +49,7 @@ class SpriteMapTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
it 'should have correct filename' do
|
||||
assert_equal File.join(@images_tmp_path, "#{@base.path}-#{@base.uniqueness_hash}.png"), @base.filename
|
||||
assert_equal File.join(@images_tmp_path, "#{@base.path}-s#{@base.uniqueness_hash}.png"), @base.filename
|
||||
end
|
||||
|
||||
it "should return the 'ten-by-ten' image" do
|
||||
|
Loading…
Reference in New Issue
Block a user