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 ------ 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 diff --git a/doc-src/content/CHANGELOG.markdown b/doc-src/content/CHANGELOG.markdown index 92b80b26..da287628 100644 --- a/doc-src/content/CHANGELOG.markdown +++ b/doc-src/content/CHANGELOG.markdown @@ -20,6 +20,8 @@ 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 +* 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/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; -// } 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 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/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/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/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) diff --git a/lib/compass/sass_extensions/sprites/sprite_methods.rb b/lib/compass/sass_extensions/sprites/sprite_methods.rb index bd905247..95e5dda8 100644 --- a/lib/compass/sass_extensions/sprites/sprite_methods.rb +++ b/lib/compass/sass_extensions/sprites/sprite_methods.rb @@ -60,20 +60,21 @@ module Compass Compass.configuration.run_sprite_generated(engine.canvas) save! else - options[:compass][:logger].record(:unchanged, relativize(filename)) + 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)) + log :remove, file FileUtils.rm file + Compass.configuration.run_sprite_removed(file) end end # 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 @@ -97,7 +98,7 @@ module Compass def save! FileUtils.mkdir_p(File.dirname(filename)) saved = engine.save(filename) - options[:compass][:logger].record(:create, relativize(filename)) + log :create, filename Compass.configuration.run_sprite_saved(filename) saved end @@ -125,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 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(); +} 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?