Use a single staleness checker during a compile run to speed up dependency checking.
This commit is contained in:
parent
5a5c30caf4
commit
40d0e623d0
@ -3,7 +3,7 @@ module Compass
|
||||
|
||||
include Actions
|
||||
|
||||
attr_accessor :working_path, :from, :to, :options
|
||||
attr_accessor :working_path, :from, :to, :options, :staleness_checker, :importer
|
||||
|
||||
def initialize(working_path, from, to, options)
|
||||
self.working_path = working_path
|
||||
@ -12,6 +12,8 @@ module Compass
|
||||
self.options = options
|
||||
self.options[:cache_location] ||= determine_cache_location
|
||||
Compass.configure_sass_plugin!
|
||||
self.importer = Sass::Importers::Filesystem.new(from)
|
||||
self.staleness_checker = Sass::Plugin::StalenessChecker.new(options)
|
||||
end
|
||||
|
||||
def determine_cache_location
|
||||
@ -23,6 +25,10 @@ module Compass
|
||||
@sass_files = self.options[:sass_files] || Dir.glob(separate("#{from}/**/#{'[^_]' if exclude_partials}*.s[ac]ss"))
|
||||
end
|
||||
|
||||
def relative_stylesheet_name(sass_file)
|
||||
sass_file[("#{from}/".length)..-1]
|
||||
end
|
||||
|
||||
def stylesheet_name(sass_file)
|
||||
sass_file[("#{from}/".length)..-6]
|
||||
end
|
||||
@ -42,11 +48,15 @@ module Compass
|
||||
# Returns the sass file that needs to be compiled, if any.
|
||||
def out_of_date?
|
||||
sass_files.zip(css_files).each do |sass_filename, css_filename|
|
||||
return sass_filename if Sass::Plugin.send(:stylesheet_needs_update?, css_filename, sass_filename)
|
||||
return sass_filename if needs_update?(css_filename, sass_filename)
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def needs_update?(css_filename, sass_filename)
|
||||
staleness_checker.stylesheet_needs_update?(css_filename, relative_stylesheet_name(sass_filename), importer)
|
||||
end
|
||||
|
||||
# Determines if the configuration file is newer than any css file
|
||||
def new_config?
|
||||
config_file = Compass.detect_configuration_file
|
||||
@ -123,7 +133,7 @@ module Compass
|
||||
end
|
||||
|
||||
def should_compile?(sass_filename, css_filename)
|
||||
options[:force] || Sass::Plugin.send(:stylesheet_needs_update?, css_filename, sass_filename)
|
||||
options[:force] || needs_update?(css_filename, sass_filename)
|
||||
end
|
||||
|
||||
# A sass engine for compiling a single file.
|
||||
|
Loading…
Reference in New Issue
Block a user