Backwards and forwards compatibility with the ever-changing Sass::Plugin api.
This commit is contained in:
parent
ebd9f22440
commit
b4070637b2
@ -42,7 +42,7 @@ module Compass
|
||||
def out_of_date?
|
||||
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
|
||||
sass_files.zip(css_files).each do |sass_filename, css_filename|
|
||||
return sass_filename if Sass::Plugin.exact_stylesheet_needs_update?(css_filename, sass_filename)
|
||||
return sass_filename if Sass::Plugin.send(:exact_stylesheet_needs_update?, css_filename, sass_filename)
|
||||
end
|
||||
false
|
||||
end
|
||||
@ -99,7 +99,7 @@ module Compass
|
||||
end
|
||||
|
||||
def should_compile?(sass_filename, css_filename)
|
||||
options[:force] || Sass::Plugin.exact_stylesheet_needs_update?(css_filename, sass_filename)
|
||||
options[:force] || Sass::Plugin.send(:exact_stylesheet_needs_update?, css_filename, sass_filename)
|
||||
end
|
||||
|
||||
# A sass engine for compiling a single file.
|
||||
@ -114,12 +114,13 @@ module Compass
|
||||
# if there's an error.
|
||||
def handle_exception(sass_filename, css_filename, e)
|
||||
logger.record :error, basename(sass_filename), "(Line #{e.sass_line}: #{e.message})"
|
||||
write_file css_filename, error_contents(e), options.merge(:force => true)
|
||||
write_file css_filename, error_contents(e, sass_filename), options.merge(:force => true)
|
||||
end
|
||||
|
||||
# Haml refactored this logic in 2.3, this is backwards compatibility for either one
|
||||
def error_contents(e)
|
||||
def error_contents(e, sass_filename)
|
||||
if Sass::SyntaxError.respond_to?(:exception_to_css)
|
||||
e.sass_template = sass_filename
|
||||
Sass::SyntaxError.exception_to_css(e, :full_exception => show_full_exception?)
|
||||
else
|
||||
Sass::Plugin.options[:full_exception] ||= show_full_exception?
|
||||
|
@ -2,22 +2,39 @@ require 'sass/plugin'
|
||||
|
||||
# XXX: We can remove this monkeypatch once Sass 2.2 is released.
|
||||
module Sass::Plugin
|
||||
class << self
|
||||
unless method_defined?(:exact_stylesheet_needs_update?)
|
||||
def stylesheet_needs_update?(name, template_path, css_path)
|
||||
css_file = css_filename(name, css_path)
|
||||
template_file = template_filename(name, template_path)
|
||||
exact_stylesheet_needs_update?(css_file, template_file)
|
||||
end
|
||||
def exact_stylesheet_needs_update?(css_file, template_file)
|
||||
if !File.exists?(css_file)
|
||||
return true
|
||||
else
|
||||
css_mtime = File.mtime(css_file)
|
||||
File.mtime(template_file) > css_mtime ||
|
||||
dependencies(template_file).any?(&dependency_updated?(css_mtime))
|
||||
end
|
||||
|
||||
# splits the stylesheet_needs_update? method into two pieces so I can use the exact_stylesheet_needs_update? piece
|
||||
module StylesheetNeedsUpdate
|
||||
def stylesheet_needs_update?(name, template_path, css_path)
|
||||
css_file = css_filename(name, css_path)
|
||||
template_file = template_filename(name, template_path)
|
||||
exact_stylesheet_needs_update?(css_file, template_file)
|
||||
end
|
||||
def exact_stylesheet_needs_update?(css_file, template_file)
|
||||
if !File.exists?(css_file)
|
||||
return true
|
||||
else
|
||||
css_mtime = File.mtime(css_file)
|
||||
File.mtime(template_file) > css_mtime ||
|
||||
dependencies(template_file).any?(&dependency_updated?(css_mtime))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# At some point Sass::Plugin changed from using the metaclass to extend self.
|
||||
metaclass = class << self; self; end
|
||||
if metaclass.included_modules.include?(Sass::Plugin)
|
||||
if method(:stylesheet_needs_update?).arity == 2
|
||||
alias exact_stylesheet_needs_update? stylesheet_needs_update?
|
||||
elsif !method_defined?(:exact_stylesheet_needs_update?)
|
||||
include StylesheetNeedsUpdate
|
||||
end
|
||||
else
|
||||
class << self
|
||||
unless method_defined?(:exact_stylesheet_needs_update?)
|
||||
include StylesheetNeedsUpdate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user