From 0518f0d293a6f2d38b99601f72a497111c1e8b97 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 3 Jun 2011 15:06:02 -0700 Subject: [PATCH 01/13] Fix encoding issue. --- .../stylesheets/compass/css3/_font-face.scss | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/frameworks/compass/stylesheets/compass/css3/_font-face.scss b/frameworks/compass/stylesheets/compass/css3/_font-face.scss index b110d25a..6c7d511c 100644 --- a/frameworks/compass/stylesheets/compass/css3/_font-face.scss +++ b/frameworks/compass/stylesheets/compass/css3/_font-face.scss @@ -12,7 +12,10 @@ // // If you need to generate other formats check out the Font Squirrel // [font generator](http://www.fontsquirrel.com/fontface/generator) - +// +// Example: +// +// +font-face("this name", font-files("this.woff", "woff", "this.otf", "opentype"), "this.eot") @mixin font-face( $name, $font-files, @@ -28,16 +31,3 @@ src: $font-files; } } - -// EXAMPLE -// +font-face("this name", font-files("this.woff", "woff", "this.otf", "opentype"), "this.eot") -// -// will generate: -// -// @font-face { -// font-family: 'this name'; -// src: url('fonts/this.eot'); -// src: local("☺"), -// url('fonts/this.otf') format('woff'), -// url('fonts/this.woff') format('opentype'); -// } From d80dde727a0503be013ee745ecbd64c7e3dc9b31 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 3 Jun 2011 15:29:47 -0700 Subject: [PATCH 02/13] This file has utf-8 chars in the comments. --- frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss b/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss index 1822bb11..b4b9cfd0 100644 --- a/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss +++ b/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss @@ -1,3 +1,4 @@ +@charset "utf-8"; @import "typography"; $alternate-text-font : "Warnock Pro", "Goudy Old Style", "Palatino", "Book Antiqua", Georgia, serif !default; From bfba73c1e368955dcd25a8e31b3c8a40c9071ee2 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Tue, 7 Jun 2011 11:22:33 -0700 Subject: [PATCH 03/13] Ignore charset in blueprint files --- test/integrations/compass_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integrations/compass_test.rb b/test/integrations/compass_test.rb index ebe2bc54..c8f4f5f8 100644 --- a/test/integrations/compass_test.rb +++ b/test/integrations/compass_test.rb @@ -57,7 +57,7 @@ class CompassTest < Test::Unit::TestCase assert_no_errors css_file, :blueprint end each_sass_file do |sass_file| - assert_renders_correctly sass_file + assert_renders_correctly sass_file, :ignore_charset => true end end end From f49120c1c8f0dc58bb0d478e1b833b4e1afcfdc5 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Tue, 7 Jun 2011 11:23:06 -0700 Subject: [PATCH 04/13] Revert "Disable 1.8.7 and rbx for now." This reverts commit 7d90dfe4a0540690e394e0c143fb5921d2fa673c. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9f7820b4..720da5df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ rvm: + - 1.8.7 - 1.9.2 - jruby + - rbx - ree From 7e583e5f588e5f1ab4939f999926e056731d2cff Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 15:43:38 -0400 Subject: [PATCH 05/13] readded mtime to importer class --- lib/compass/sprite_importer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index 1b02ccba..084dbc1e 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -43,7 +43,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 From b8811780ef77ac1ee1fb8467cb846dfbcfb12d70 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 15:44:10 -0400 Subject: [PATCH 06/13] removed unneeded cache --- lib/compass/sprite_importer.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index 084dbc1e..d385f3d0 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -56,12 +56,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 + if uri =~ SPRITE_IMPORTER_REGEX + [$1, $3] + else + raise Compass::Error "invalid sprite path" end end From fc7fd8b6b44bf8a8f2a188908e496a603724fa9b Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 15:44:35 -0400 Subject: [PATCH 07/13] added test for sprite importer --- test/units/sprites/importer_test.rb | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/units/sprites/importer_test.rb diff --git a/test/units/sprites/importer_test.rb b/test/units/sprites/importer_test.rb new file mode 100644 index 00000000..04f95c8b --- /dev/null +++ b/test/units/sprites/importer_test.rb @@ -0,0 +1,49 @@ +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 + +end \ No newline at end of file From 89869db09c39300394260b23ed050608cf6cb1e0 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 16:02:16 -0400 Subject: [PATCH 08/13] cleaned up some over zelious cacheing that was causing inconsistancy problems --- lib/compass/sprite_importer.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index d385f3d0..83d3692d 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -5,11 +5,9 @@ module Compass SPRITE_IMPORTER_REGEX = %r{((.+/)?([^\*.]+))/(.+?)\.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 + klass = Compass::SpriteImporter.new + klass.uri, klass.options = uri, options + klass end def initialize(options ={}) @@ -77,7 +75,7 @@ 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 From 7ff9ff15d0d6a4659c6e4fcd8e74067efa562948 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 16:03:58 -0400 Subject: [PATCH 09/13] run bundle exec when running tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 720da5df..3bb2dc2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,4 @@ rvm: - jruby - rbx - ree +script: "bundle exec rake test" From ab5d6e51d903303128b71d73c09239a07377feb9 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 16:27:23 -0400 Subject: [PATCH 10/13] updated importer to validate that sprites are png files --- lib/compass/sprite_importer.rb | 10 ++++++++++ .../images/bad_extensions/ten-by-ten.gif | Bin 0 -> 2804 bytes .../images/bad_extensions/twenty-by-twenty.jpg | Bin 0 -> 2799 bytes test/units/sprites/importer_test.rb | 17 +++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 test/fixtures/sprites/public/images/bad_extensions/ten-by-ten.gif create mode 100644 test/fixtures/sprites/public/images/bad_extensions/twenty-by-twenty.jpg diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index 83d3692d..0d92fda9 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -3,6 +3,7 @@ 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) klass = Compass::SpriteImporter.new @@ -89,6 +90,14 @@ 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) @@ -96,6 +105,7 @@ module Compass # Returns a Sass::Engine for this sprite object def sass_engine + validate_sprites! Sass::Engine.new(content_for_images, sass_options) end diff --git a/test/fixtures/sprites/public/images/bad_extensions/ten-by-ten.gif b/test/fixtures/sprites/public/images/bad_extensions/ten-by-ten.gif new file mode 100644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yGbhrC3F?OGgX%9g*fcaWDm4~2!A2tDLf92ryqZLBKpMrlfEarPuZSoKCN}SvX$Ce&<3?-w@tOjw-0qh zbo8I`In&+g(AoN%@o#l!)y`I&lRZ~_o_Id*{OpCC3)5Y~uE~qMizD4@x*uO!ap~UW z<(GS}_+Gho)${759+#dA*Bq~%y>5T~%njQc?KiD&w%xM2)%v^D@2$Poy=}K`Zg=$A z^>y|y?LU9V`Od|=?su==W8J$s;6KoRKlJ{C!KlHZ2iyna50f6gd6e;J=JDnym?s5K zrJj~PQ+ihWhu$A8L)Js*hTVs6Jr92Vc!V?Z>d(|azmDd;pu8v@QypsSHf2_lllLW{#WH|-Pfo8V*Yh&YQ@y(8_}EDw?*&d-_^aheBV7CIQ{HH@`ss^ z1)t=@-0@RJ`HGBX7002ovPDHLkV1j+) BIe!2E literal 0 HcmV?d00001 diff --git a/test/units/sprites/importer_test.rb b/test/units/sprites/importer_test.rb index 04f95c8b..d25bff1e 100644 --- a/test/units/sprites/importer_test.rb +++ b/test/units/sprites/importer_test.rb @@ -46,4 +46,21 @@ class ImporterTest < Test::Unit::TestCase 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 \ No newline at end of file From f248c22ab16610a5ae3f5341fe50dd71cbf3d377 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 16:28:10 -0400 Subject: [PATCH 11/13] removed another instance cache in the importer that could be problematic --- lib/compass/sprite_importer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index 0d92fda9..e2948271 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -81,7 +81,7 @@ module Compass # 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)}" From 5138c94ec44ac9c021abd06cb55526d70765e8ae Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 16:29:03 -0400 Subject: [PATCH 12/13] gemfile --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 90081653..9f979828 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) From 4461f1be5f9b993e80d14a7a3e02e35b810f8c1d Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Thu, 9 Jun 2011 16:37:50 -0400 Subject: [PATCH 13/13] removed all cacheing from importer class it causes more problems then it was worth --- lib/compass/sprite_importer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index e2948271..94d3b11e 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -100,7 +100,7 @@ module Compass # 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