diff --git a/lib/sass/plugin.rb b/lib/sass/plugin.rb index a7dd346a..2bea38fc 100644 --- a/lib/sass/plugin.rb +++ b/lib/sass/plugin.rb @@ -14,6 +14,12 @@ module Sass :full_exception => true } + # Whether or not Sass has *ever* checked if the stylesheets need updates + # (in this Ruby instance). + def checked_for_updates + @@checked_for_updates + end + # Gets various options for Sass. See README for details. #-- # TODO: *DOCUMENT OPTIONS* @@ -35,6 +41,7 @@ module Sass def update_stylesheets return if options[:never_update] + @@checked_for_updates = true Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file| # Get the relative path to the file with no extension diff --git a/lib/sass/plugin/merb.rb b/lib/sass/plugin/merb.rb index 938bd5ad..9a7263e6 100644 --- a/lib/sass/plugin/merb.rb +++ b/lib/sass/plugin/merb.rb @@ -20,7 +20,11 @@ unless defined?(Sass::MERB_LOADED) class MerbHandler # :nodoc: def process_with_sass(request, response) - Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check] + if !Sass::Plugin.checked_for_updates || + Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check] + Sass::Plugin.update_stylesheets + end + process_without_sass(request, response) end alias_method :process_without_sass, :process diff --git a/lib/sass/plugin/rails.rb b/lib/sass/plugin/rails.rb index cd34f0de..b4e17fe5 100644 --- a/lib/sass/plugin/rails.rb +++ b/lib/sass/plugin/rails.rb @@ -11,7 +11,11 @@ unless defined?(Sass::RAILS_LOADED) class Base alias_method :sass_old_process, :process def process(*args) - Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check] + if !Sass::Plugin.checked_for_updates || + Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check] + Sass::Plugin.update_stylesheets + end + sass_old_process(*args) end end