From 28daff67713afa432ce300dfeb22f8b2aee8d7b9 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 19 Sep 2011 17:59:37 -0700 Subject: [PATCH 01/11] Assert that sprite offsets are numbers. --- lib/compass/sass_extensions/functions/sprites.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/compass/sass_extensions/functions/sprites.rb b/lib/compass/sass_extensions/functions/sprites.rb index da193f8e..e6506a66 100644 --- a/lib/compass/sass_extensions/functions/sprites.rb +++ b/lib/compass/sass_extensions/functions/sprites.rb @@ -120,6 +120,8 @@ module Compass::SassExtensions::Functions::Sprites # # background-position: 3px -36px; def sprite_position(map, sprite = nil, offset_x = ZERO, offset_y = ZERO) + assert_type offset_x, :Number + assert_type offset_y, :Number sprite = convert_sprite_name(sprite) verify_map(map, "sprite-position") unless sprite && sprite.is_a?(Sass::Script::String) From 71e5d28a2981c276c0815f65e56d7b2fb82e3189 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 19 Sep 2011 18:18:38 -0700 Subject: [PATCH 02/11] Respect the --quiet option with sprite logging --- doc-src/content/CHANGELOG.markdown | 1 + lib/compass/sass_extensions/sprites/sprite_methods.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc-src/content/CHANGELOG.markdown b/doc-src/content/CHANGELOG.markdown index 92b80b26..458fe07a 100644 --- a/doc-src/content/CHANGELOG.markdown +++ b/doc-src/content/CHANGELOG.markdown @@ -20,6 +20,7 @@ The Documentation for the [latest preview release](http://beta.compass-style.org * font-files helper: Stop requiring font type when the type can be guessed from URL * inline-font-files: actually works now * Upgrade CSS3 Pie to 1.0beta5 +* log sprite generation and removal to the console 0.12.alpha.0 (8/30/2011) diff --git a/lib/compass/sass_extensions/sprites/sprite_methods.rb b/lib/compass/sass_extensions/sprites/sprite_methods.rb index bd905247..e674aae3 100644 --- a/lib/compass/sass_extensions/sprites/sprite_methods.rb +++ b/lib/compass/sass_extensions/sprites/sprite_methods.rb @@ -60,13 +60,13 @@ module Compass Compass.configuration.run_sprite_generated(engine.canvas) save! else - options[:compass][:logger].record(:unchanged, relativize(filename)) + options[:compass][:logger].record(:unchanged, relativize(filename)) unless options[:quiet] end end def cleanup_old_sprites Dir[File.join(Compass.configuration.images_path, "#{path}-*.png")].each do |file| - options[:compass][:logger].record(:remove, relativize(file)) + options[:compass][:logger].record(:remove, relativize(file)) unless options[:quiet] FileUtils.rm file end end @@ -97,7 +97,7 @@ module Compass def save! FileUtils.mkdir_p(File.dirname(filename)) saved = engine.save(filename) - options[:compass][:logger].record(:create, relativize(filename)) + options[:compass][:logger].record(:create, relativize(filename)) unless options[:quiet] Compass.configuration.run_sprite_saved(filename) saved end From 38e4b3a3d97d8de330b426063bc5e21fc07d818e Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 19 Sep 2011 18:19:04 -0700 Subject: [PATCH 03/11] Run a callback when a sprite is removed. --- lib/compass/configuration/data.rb | 6 ++++++ lib/compass/sass_extensions/sprites/sprite_methods.rb | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/compass/configuration/data.rb b/lib/compass/configuration/data.rb index 2bd3b997..45c9e0c4 100644 --- a/lib/compass/configuration/data.rb +++ b/lib/compass/configuration/data.rb @@ -38,6 +38,12 @@ module Compass define_callback :sprite_generated chained_method :run_sprite_generated + # on_sprite_removed + # yields the filename + # usage: on_sprite_removed {|filename| do_something(filename) } + define_callback :sprite_removed + chained_method :run_sprite_removed + # on_stylesheet_saved # yields the filename # usage: on_stylesheet_saved {|filename| do_something(filename) } diff --git a/lib/compass/sass_extensions/sprites/sprite_methods.rb b/lib/compass/sass_extensions/sprites/sprite_methods.rb index e674aae3..251b5865 100644 --- a/lib/compass/sass_extensions/sprites/sprite_methods.rb +++ b/lib/compass/sass_extensions/sprites/sprite_methods.rb @@ -68,6 +68,7 @@ module Compass Dir[File.join(Compass.configuration.images_path, "#{path}-*.png")].each do |file| options[:compass][:logger].record(:remove, relativize(file)) unless options[:quiet] FileUtils.rm file + Compass.configuration.run_sprite_removed(file) end end From 972c53ecb5f0423d2bffdd5a72a116651387f257 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 19 Sep 2011 18:19:42 -0700 Subject: [PATCH 04/11] Respect the --force option with sprite generation. --- lib/compass/sass_extensions/sprites/sprite_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compass/sass_extensions/sprites/sprite_methods.rb b/lib/compass/sass_extensions/sprites/sprite_methods.rb index 251b5865..52458b00 100644 --- a/lib/compass/sass_extensions/sprites/sprite_methods.rb +++ b/lib/compass/sass_extensions/sprites/sprite_methods.rb @@ -74,7 +74,7 @@ module Compass # Does this sprite need to be generated def generation_required? - !File.exists?(filename) || outdated? + !File.exists?(filename) || outdated? || options[:force] end # Returns the uniqueness hash for this sprite object From d03d52990968db144483bcccea4dece826f06e3e Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Tue, 20 Sep 2011 09:36:40 -0700 Subject: [PATCH 05/11] Add a new compass-env() helper that returns the compass environment. --- doc-src/content/CHANGELOG.markdown | 1 + lib/compass/compiler.rb | 1 + lib/compass/sass_extensions/functions.rb | 6 +++-- lib/compass/sass_extensions/functions/env.rb | 5 +++++ test/integrations/compass_test.rb | 23 ++++++++++++++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 lib/compass/sass_extensions/functions/env.rb diff --git a/doc-src/content/CHANGELOG.markdown b/doc-src/content/CHANGELOG.markdown index 458fe07a..da287628 100644 --- a/doc-src/content/CHANGELOG.markdown +++ b/doc-src/content/CHANGELOG.markdown @@ -21,6 +21,7 @@ The Documentation for the [latest preview release](http://beta.compass-style.org * inline-font-files: actually works now * Upgrade CSS3 Pie to 1.0beta5 * log sprite generation and removal to the console +* Added a new helper function `compass-env()` that returns the current compass environment (development, production) 0.12.alpha.0 (8/30/2011) diff --git a/lib/compass/compiler.rb b/lib/compass/compiler.rb index a1006c21..345adb50 100644 --- a/lib/compass/compiler.rb +++ b/lib/compass/compiler.rb @@ -17,6 +17,7 @@ module Compass self.sass_options[:importer] = self.importer = Sass::Importers::Filesystem.new(from) self.sass_options[:compass] ||= {} self.sass_options[:compass][:logger] = self.logger + self.sass_options[:compass][:environment] = Compass.configuration.environment self.staleness_checker = Sass::Plugin::StalenessChecker.new(sass_options) end diff --git a/lib/compass/sass_extensions/functions.rb b/lib/compass/sass_extensions/functions.rb index 99cf687a..a87916d5 100644 --- a/lib/compass/sass_extensions/functions.rb +++ b/lib/compass/sass_extensions/functions.rb @@ -2,9 +2,10 @@ module Compass::SassExtensions::Functions end %w( - selectors enumerate urls display + selectors enumerate urls display inline_image image_size constants gradient_support - font_files lists colors trig sprites cross_browser_support + font_files lists colors trig + sprites env cross_browser_support ).each do |func| require "compass/sass_extensions/functions/#{func}" end @@ -24,6 +25,7 @@ module Sass::Script::Functions include Compass::SassExtensions::Functions::Trig include Compass::SassExtensions::Functions::Sprites include Compass::SassExtensions::Functions::CrossBrowserSupport + include Compass::SassExtensions::Functions::Env end # Wierd that this has to be re-included to pick up sub-modules. Ruby bug? diff --git a/lib/compass/sass_extensions/functions/env.rb b/lib/compass/sass_extensions/functions/env.rb new file mode 100644 index 00000000..ae9cd66d --- /dev/null +++ b/lib/compass/sass_extensions/functions/env.rb @@ -0,0 +1,5 @@ +module Compass::SassExtensions::Functions::Env + def compass_env + Sass::Script::String.new((options[:compass][:environment] || "development").to_s) + end +end diff --git a/test/integrations/compass_test.rb b/test/integrations/compass_test.rb index 61ad91c2..b06f1283 100644 --- a/test/integrations/compass_test.rb +++ b/test/integrations/compass_test.rb @@ -73,6 +73,28 @@ class CompassTest < Test::Unit::TestCase end end + def test_env_in_development + within_project('envtest', lambda {|c| c.environment = :development }) do |proj| + each_css_file(proj.css_path) do |css_file| + assert_no_errors css_file, 'envtest' + end + each_sass_file do |sass_file| + assert_renders_correctly sass_file, :ignore_charset => true, :environment => "development" + end + end + end + + def test_env_in_production + within_project('envtest', lambda {|c| c.environment = :production }) do |proj| + each_css_file(proj.css_path) do |css_file| + assert_no_errors css_file, 'envtest' + end + each_sass_file do |sass_file| + assert_renders_correctly sass_file, :ignore_charset => true, :environment => "production" + end + end + end + def test_busted_image_urls within_project('busted_image_urls') do |proj| each_css_file(proj.css_path) do |css_file| @@ -150,6 +172,7 @@ private if Compass.configuration.sass_path && File.exists?(Compass.configuration.sass_path) compiler = Compass::Compiler.new *args + compiler.clean! compiler.run end yield Compass.configuration if block_given? From 9b56dc61696f01df70d8513149b8142fa69fe27d Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Sat, 24 Sep 2011 01:21:41 -0400 Subject: [PATCH 06/11] updated for image_size monkey patch for api change --- lib/compass/app_integration/rails/actionpack31/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compass/app_integration/rails/actionpack31/helpers.rb b/lib/compass/app_integration/rails/actionpack31/helpers.rb index 2728462f..819e4242 100644 --- a/lib/compass/app_integration/rails/actionpack31/helpers.rb +++ b/lib/compass/app_integration/rails/actionpack31/helpers.rb @@ -8,7 +8,7 @@ end module Compass::RailsImageFunctionPatch private - def image_path(image_file) + def image_path_for_size(image_file) if file = ::Rails.application.assets.find_asset(image_file) return file end From fecc98219d05104a13f66be78bc2ca9d048ab369 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 26 Sep 2011 09:00:51 -0700 Subject: [PATCH 07/11] Refactor loggin within sprites Handle missing logger instance more elegantly and centralize relativizing and quiet mode checking. Closes GH-84. --- lib/compass/sass_extensions/sprites/sprite_methods.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/compass/sass_extensions/sprites/sprite_methods.rb b/lib/compass/sass_extensions/sprites/sprite_methods.rb index 52458b00..95e5dda8 100644 --- a/lib/compass/sass_extensions/sprites/sprite_methods.rb +++ b/lib/compass/sass_extensions/sprites/sprite_methods.rb @@ -60,13 +60,13 @@ module Compass Compass.configuration.run_sprite_generated(engine.canvas) save! else - options[:compass][:logger].record(:unchanged, relativize(filename)) unless options[:quiet] + log :unchanged, filename end end def cleanup_old_sprites Dir[File.join(Compass.configuration.images_path, "#{path}-*.png")].each do |file| - options[:compass][:logger].record(:remove, relativize(file)) unless options[:quiet] + log :remove, file FileUtils.rm file Compass.configuration.run_sprite_removed(file) end @@ -98,7 +98,7 @@ module Compass def save! FileUtils.mkdir_p(File.dirname(filename)) saved = engine.save(filename) - options[:compass][:logger].record(:create, relativize(filename)) unless options[:quiet] + log :create, filename Compass.configuration.run_sprite_saved(filename) saved end @@ -126,6 +126,11 @@ module Compass [width, height] end + def log(action, filename, *extra) + if options[:compass] && options[:compass][:logger] && !options[:quiet] + options[:compass][:logger].record(action, relativize(filename), *extra) + end + end end end end From d794394ceb92e7acda366cd92c50f3976fb91647 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 26 Sep 2011 09:31:12 -0700 Subject: [PATCH 08/11] Add missing test fixture. --- test/fixtures/stylesheets/envtest/config.rb | 9 +++++++++ test/fixtures/stylesheets/envtest/css/env.css | 2 ++ test/fixtures/stylesheets/envtest/sass/env.scss | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 test/fixtures/stylesheets/envtest/config.rb create mode 100644 test/fixtures/stylesheets/envtest/css/env.css create mode 100644 test/fixtures/stylesheets/envtest/sass/env.scss diff --git a/test/fixtures/stylesheets/envtest/config.rb b/test/fixtures/stylesheets/envtest/config.rb new file mode 100644 index 00000000..6fff7da1 --- /dev/null +++ b/test/fixtures/stylesheets/envtest/config.rb @@ -0,0 +1,9 @@ +# Require any additional compass plugins here. +project_type = :stand_alone +css_dir = "tmp" +sass_dir = "sass" +images_dir = "images" +output_style = :nested +line_comments = false + +disable_warnings = true diff --git a/test/fixtures/stylesheets/envtest/css/env.css b/test/fixtures/stylesheets/envtest/css/env.css new file mode 100644 index 00000000..1c08a273 --- /dev/null +++ b/test/fixtures/stylesheets/envtest/css/env.css @@ -0,0 +1,2 @@ +.env { + env: <%= options[:environment] %>; } diff --git a/test/fixtures/stylesheets/envtest/sass/env.scss b/test/fixtures/stylesheets/envtest/sass/env.scss new file mode 100644 index 00000000..e88f6fbe --- /dev/null +++ b/test/fixtures/stylesheets/envtest/sass/env.scss @@ -0,0 +1,3 @@ +.env { + env: compass-env(); +} From 067fb963df8fb68692ce45ab2140ca394a2b40cd Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Mon, 26 Sep 2011 13:42:12 -0400 Subject: [PATCH 09/11] updated rake and cucumber so tests pass in 1.9.3 --- Gemfile | 4 ++-- Gemfile.lock | 41 +++++++++++++++++++++-------------------- Rakefile | 1 + 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index f4971264..38a007b4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source :rubygems gemspec -gem "cucumber", "~> 0.9.2" +gem "cucumber", "~> 1.1.0" gem "rspec", "~>2.0.0" gem "rails", "~>3.0.0.rc" gem "compass-validator", "3.0.1" @@ -18,6 +18,6 @@ gem 'mocha' gem 'timecop' gem 'diff-lcs', '~> 1.1.2' -gem 'rake', '0.8.7' +gem 'rake', '~> 0.9.2' #Warning becarful adding OS dependant gems to this file it will cause issues on the CI server \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index c4b8f64f..642290be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - compass (0.12.0.alpha.0.91a748a) + compass (0.12.alpha.0.d794394) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) @@ -39,16 +39,16 @@ GEM addressable (2.2.6) arel (2.0.10) builder (2.1.2) - chunky_png (1.2.1) + chunky_png (1.2.5) compass-validator (3.0.1) css_parser (1.0.1) - cucumber (0.9.4) - builder (~> 2.1.2) - diff-lcs (~> 1.1.2) - gherkin (~> 2.2.9) - json (~> 1.4.6) - term-ansicolor (~> 1.0.5) - diff-lcs (1.1.2) + cucumber (1.1.0) + builder (>= 2.1.2) + diff-lcs (>= 1.1.2) + gherkin (~> 2.5.0) + json (>= 1.4.6) + term-ansicolor (>= 1.0.6) + diff-lcs (1.1.3) em-dir-watcher (0.9.4) em-websocket (0.3.1) addressable (>= 2.1.1) @@ -57,12 +57,11 @@ GEM abstract (>= 1.0.0) eventmachine (0.12.10) fssm (0.2.7) - gherkin (2.2.9) - json (~> 1.4.6) - term-ansicolor (~> 1.0.5) - haml (3.1.2) + gherkin (2.5.1) + json (>= 1.4.6) + haml (3.1.3) i18n (0.5.0) - json (1.4.6) + json (1.6.1) livereload (1.6) em-dir-watcher (>= 0.1) em-websocket (>= 0.1.2) @@ -72,10 +71,12 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) + metaclass (0.0.1) mime-types (1.16) - mocha (0.9.12) + mocha (0.10.0) + metaclass (~> 0.0.1) polyglot (0.3.2) - rack (1.2.3) + rack (1.2.4) rack-mount (0.6.14) rack (>= 1.0.0) rack-test (0.5.7) @@ -94,9 +95,9 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.4) - rake (0.8.7) + rake (0.9.2) rcov (0.9.10) - rdoc (3.9.2) + rdoc (3.9.4) rspec (2.0.1) rspec-core (~> 2.0.1) rspec-expectations (~> 2.0.1) @@ -126,13 +127,13 @@ DEPENDENCIES compass! compass-validator (= 3.0.1) css_parser (~> 1.0.1) - cucumber (~> 0.9.2) + cucumber (~> 1.1.0) diff-lcs (~> 1.1.2) haml (~> 3.1) livereload mocha rails (~> 3.0.0.rc) - rake (= 0.8.7) + rake (~> 0.9.2) rcov rspec (~> 2.0.0) ruby-prof diff --git a/Rakefile b/Rakefile index 40e25323..7fcfe035 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ require 'rubygems' require 'bundler' Bundler.setup +require 'rake/dsl_definition' rescue nil require 'compass' # ----- Default: Testing ------ From 656f12a4abb4e8cfa13e19248ac81a9dcf7ede15 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Fri, 30 Sep 2011 14:01:07 -0300 Subject: [PATCH 10/11] Fixed type conversion error I encountered this when using jruby and passing an illegal option. --- bin/compass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compass b/bin/compass index c174ce02..13c47e68 100755 --- a/bin/compass +++ b/bin/compass @@ -36,5 +36,5 @@ if ARGV.delete("--profile") printer.print(STDERR, 0) exit exit_code else - exit runner.call + exit runner.call || 0 end From 4c9656f35a056fcf9599bbdc692453db8c569789 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Tue, 4 Oct 2011 13:26:06 -0700 Subject: [PATCH 11/11] Removed UTF-8 Character from the comments. --- .../stylesheets/compass/css3/_font-face.scss | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/frameworks/compass/stylesheets/compass/css3/_font-face.scss b/frameworks/compass/stylesheets/compass/css3/_font-face.scss index abb0bc53..bbca5fb4 100644 --- a/frameworks/compass/stylesheets/compass/css3/_font-face.scss +++ b/frameworks/compass/stylesheets/compass/css3/_font-face.scss @@ -46,18 +46,3 @@ } } } - -// EXAMPLE -// +font-face("this name", font-files("this.woff", "woff", "this.otf", "opentype"), "this.eot", bold, italic) -// -// 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'); -// font-weight: bold; -// font-style: italic; -// }