diff --git a/.travis.yml b/.travis.yml index 9f7820b4..3bb2dc2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ rvm: + - 1.8.7 - 1.9.2 - jruby + - rbx - ree +script: "bundle exec rake test" diff --git a/Gemfile.lock b/Gemfile.lock index ee5d990d..8c07f283 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,13 @@ GIT remote: git://github.com/johnbintz/fakefs.git - revision: 005ddaaeb2b2881391c31ac9846a55ce5a42c206 + revision: 7363b6f13bfcd9f583bbf7cd1e0d65c2dc656db7 specs: fakefs (0.3.1) PATH remote: . specs: - compass (0.11.1.cc26b98) + compass (0.11.1.387bf36) chunky_png (~> 1.1) fssm (>= 0.2.7) sass (~> 3.1) @@ -17,12 +17,12 @@ GEM specs: ZenTest (4.5.0) abstract (1.0.0) - actionmailer (3.0.7) - actionpack (= 3.0.7) - mail (~> 2.2.15) - actionpack (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) + actionmailer (3.0.9.rc3) + actionpack (= 3.0.9.rc3) + mail (~> 2.2.19) + actionpack (3.0.9.rc3) + activemodel (= 3.0.9.rc3) + activesupport (= 3.0.9.rc3) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.5.0) @@ -30,21 +30,21 @@ GEM rack-mount (~> 0.6.14) rack-test (~> 0.5.7) tzinfo (~> 0.3.23) - activemodel (3.0.7) - activesupport (= 3.0.7) + activemodel (3.0.9.rc3) + activesupport (= 3.0.9.rc3) builder (~> 2.1.2) i18n (~> 0.5.0) - activerecord (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - arel (~> 2.0.2) + activerecord (3.0.9.rc3) + activemodel (= 3.0.9.rc3) + activesupport (= 3.0.9.rc3) + arel (~> 2.0.10) tzinfo (~> 0.3.23) - activeresource (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - activesupport (3.0.7) - addressable (2.2.5) - arel (2.0.9) + activeresource (3.0.9.rc3) + activemodel (= 3.0.9.rc3) + activesupport (= 3.0.9.rc3) + activesupport (3.0.9.rc3) + addressable (2.2.6) + arel (2.0.10) autotest (4.4.6) ZenTest (>= 4.4.1) autotest-fsevent (0.2.5) @@ -61,7 +61,7 @@ GEM term-ansicolor (~> 1.0.5) diff-lcs (1.1.2) em-dir-watcher (0.9.4) - em-websocket (0.2.1) + em-websocket (0.3.0) addressable (>= 2.1.1) eventmachine (>= 0.12.9) erubis (2.6.6) @@ -71,14 +71,14 @@ GEM gherkin (2.2.9) json (~> 1.4.6) term-ansicolor (~> 1.0.5) - haml (3.1.1) + haml (3.1.2) i18n (0.5.0) json (1.4.6) livereload (1.6) em-dir-watcher (>= 0.1) em-websocket (>= 0.1.2) ruby-json (>= 1.1.2) - mail (2.2.17) + mail (2.2.19) activesupport (>= 2.3.6) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -86,27 +86,29 @@ GEM mime-types (1.16) mocha (0.9.12) polyglot (0.3.1) - rack (1.2.2) + rack (1.2.3) rack-mount (0.6.14) rack (>= 1.0.0) rack-test (0.5.7) rack (>= 1.0) - rails (3.0.7) - actionmailer (= 3.0.7) - actionpack (= 3.0.7) - activerecord (= 3.0.7) - activeresource (= 3.0.7) - activesupport (= 3.0.7) + rails (3.0.9.rc3) + actionmailer (= 3.0.9.rc3) + actionpack (= 3.0.9.rc3) + activerecord (= 3.0.9.rc3) + activeresource (= 3.0.9.rc3) + activesupport (= 3.0.9.rc3) bundler (~> 1.0) - railties (= 3.0.7) - railties (3.0.7) - actionpack (= 3.0.7) - activesupport (= 3.0.7) + railties (= 3.0.9.rc3) + railties (3.0.9.rc3) + actionpack (= 3.0.9.rc3) + activesupport (= 3.0.9.rc3) rake (>= 0.8.7) + rdoc (~> 3.4) thor (~> 0.14.4) - rake (0.8.7) + rake (0.9.2) rb-fsevent (0.4.0) rcov (0.9.9) + rdoc (3.6.1) rspec (2.0.1) rspec-core (~> 2.0.1) rspec-expectations (~> 2.0.1) @@ -118,16 +120,16 @@ GEM rspec-core (~> 2.0.1) rspec-expectations (~> 2.0.1) ruby-json (1.1.2) - ruby-prof (0.10.5) + ruby-prof (0.10.7) rubyzip (0.9.4) - sass (3.1.1) + sass (3.1.2) sys-uname (0.8.5) term-ansicolor (1.0.5) thor (0.14.6) timecop (0.3.5) treetop (1.4.9) polyglot (>= 0.3.1) - tzinfo (0.3.26) + tzinfo (0.3.27) PLATFORMS ruby 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; 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'); -// } diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index 1b02ccba..94d3b11e 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -3,13 +3,12 @@ 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 + klass = Compass::SpriteImporter.new + klass.uri, klass.options = uri, options + klass end def initialize(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 + if uri =~ SPRITE_IMPORTER_REGEX + [$1, $3] + else + 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 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 index 00000000..c0ae53cc Binary files /dev/null and b/test/fixtures/sprites/public/images/bad_extensions/ten-by-ten.gif differ diff --git a/test/fixtures/sprites/public/images/bad_extensions/twenty-by-twenty.jpg b/test/fixtures/sprites/public/images/bad_extensions/twenty-by-twenty.jpg new file mode 100644 index 00000000..4e5e297f Binary files /dev/null and b/test/fixtures/sprites/public/images/bad_extensions/twenty-by-twenty.jpg differ 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 diff --git a/test/units/sprites/importer_test.rb b/test/units/sprites/importer_test.rb new file mode 100644 index 00000000..d25bff1e --- /dev/null +++ b/test/units/sprites/importer_test.rb @@ -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 \ No newline at end of file