Ensure that Sass::Plugin.update_stylesheets is run at least once per process, unless specifically forbidden.

This commit is contained in:
Nathan Weizenbaum 2008-02-11 19:49:16 -08:00
parent b9ac2c41a5
commit 9ab4f900f0
3 changed files with 17 additions and 2 deletions

View File

@ -14,6 +14,12 @@ module Sass
:full_exception => true :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. # Gets various options for Sass. See README for details.
#-- #--
# TODO: *DOCUMENT OPTIONS* # TODO: *DOCUMENT OPTIONS*
@ -35,6 +41,7 @@ module Sass
def update_stylesheets def update_stylesheets
return if options[:never_update] return if options[:never_update]
@@checked_for_updates = true
Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file| Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file|
# Get the relative path to the file with no extension # Get the relative path to the file with no extension

View File

@ -20,7 +20,11 @@ unless defined?(Sass::MERB_LOADED)
class MerbHandler # :nodoc: class MerbHandler # :nodoc:
def process_with_sass(request, response) 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) process_without_sass(request, response)
end end
alias_method :process_without_sass, :process alias_method :process_without_sass, :process

View File

@ -11,7 +11,11 @@ unless defined?(Sass::RAILS_LOADED)
class Base class Base
alias_method :sass_old_process, :process alias_method :sass_old_process, :process
def process(*args) 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) sass_old_process(*args)
end end
end end