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
|
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)
|
def initialize(working_path, from, to, options)
|
||||||
self.working_path = working_path
|
self.working_path = working_path
|
||||||
@ -12,6 +12,8 @@ module Compass
|
|||||||
self.options = options
|
self.options = options
|
||||||
self.options[:cache_location] ||= determine_cache_location
|
self.options[:cache_location] ||= determine_cache_location
|
||||||
Compass.configure_sass_plugin!
|
Compass.configure_sass_plugin!
|
||||||
|
self.importer = Sass::Importers::Filesystem.new(from)
|
||||||
|
self.staleness_checker = Sass::Plugin::StalenessChecker.new(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_cache_location
|
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"))
|
@sass_files = self.options[:sass_files] || Dir.glob(separate("#{from}/**/#{'[^_]' if exclude_partials}*.s[ac]ss"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def relative_stylesheet_name(sass_file)
|
||||||
|
sass_file[("#{from}/".length)..-1]
|
||||||
|
end
|
||||||
|
|
||||||
def stylesheet_name(sass_file)
|
def stylesheet_name(sass_file)
|
||||||
sass_file[("#{from}/".length)..-6]
|
sass_file[("#{from}/".length)..-6]
|
||||||
end
|
end
|
||||||
@ -42,11 +48,15 @@ module Compass
|
|||||||
# Returns the sass file that needs to be compiled, if any.
|
# Returns the sass file that needs to be compiled, if any.
|
||||||
def out_of_date?
|
def out_of_date?
|
||||||
sass_files.zip(css_files).each do |sass_filename, css_filename|
|
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
|
end
|
||||||
false
|
false
|
||||||
end
|
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
|
# Determines if the configuration file is newer than any css file
|
||||||
def new_config?
|
def new_config?
|
||||||
config_file = Compass.detect_configuration_file
|
config_file = Compass.detect_configuration_file
|
||||||
@ -123,7 +133,7 @@ module Compass
|
|||||||
end
|
end
|
||||||
|
|
||||||
def should_compile?(sass_filename, css_filename)
|
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
|
end
|
||||||
|
|
||||||
# A sass engine for compiling a single file.
|
# A sass engine for compiling a single file.
|
||||||
|
Loading…
Reference in New Issue
Block a user