Class | Sass::Plugin::StalenessChecker |
In: |
lib/sass/plugin/staleness_checker.rb
|
Parent: | Object |
The class handles `.s[ca]ss` file staleness checks via their mtime timestamps.
To speed things up two level of caches are employed:
Usage:
DELETED | = | 1.0/0.0 |
dependencies_cache | [RW] | @private |
Creates a new StalenessChecker for checking the staleness of several stylesheets at once.
# File lib/sass/plugin/staleness_checker.rb, line 35 35: def initialize 36: @dependencies = self.class.dependencies_cache 37: 38: # Entries in the following instance-level caches are never explicitly expired. 39: # Instead they are supposed to automaticaly go out of scope when a series of staleness checks 40: # (this instance of StalenessChecker was created for) is finished. 41: @mtimes, @dependencies_stale = {}, {} 42: end
Returns whether or not a given CSS file is out of date and needs to be regenerated.
The distinction between this method and the instance-level \{stylesheet_needs_update?} is that the instance method preserves mtime and stale-dependency caches, so it‘s better to use when checking multiple stylesheets at once.
@param css_file [String] The location of the CSS file to check. @param template_file [String] The location of the Sass or SCSS template
that is compiled to `css_file`.
# File lib/sass/plugin/staleness_checker.rb, line 66 66: def self.stylesheet_needs_update?(css_file, template_file) 67: new.stylesheet_needs_update?(css_file, template_file) 68: end
Returns whether or not a given CSS file is out of date and needs to be regenerated.
@param css_file [String] The location of the CSS file to check. @param template_file [String] The location of the Sass or SCSS template
that is compiled to `css_file`.
# File lib/sass/plugin/staleness_checker.rb, line 50 50: def stylesheet_needs_update?(css_file, template_file) 51: template_file, css_mtime = File.expand_path(template_file), mtime(css_file) 52: 53: css_mtime == DELETED || dependency_updated?(css_mtime).call(template_file) 54: end