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?
|
def out_of_date?
|
||||||
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
|
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
|
||||||
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.exact_stylesheet_needs_update?(css_filename, sass_filename)
|
return sass_filename if Sass::Plugin.send(:exact_stylesheet_needs_update?, css_filename, sass_filename)
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
@ -99,7 +99,7 @@ module Compass
|
|||||||
end
|
end
|
||||||
|
|
||||||
def should_compile?(sass_filename, css_filename)
|
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
|
end
|
||||||
|
|
||||||
# A sass engine for compiling a single file.
|
# A sass engine for compiling a single file.
|
||||||
@ -114,12 +114,13 @@ module Compass
|
|||||||
# if there's an error.
|
# if there's an error.
|
||||||
def handle_exception(sass_filename, css_filename, e)
|
def handle_exception(sass_filename, css_filename, e)
|
||||||
logger.record :error, basename(sass_filename), "(Line #{e.sass_line}: #{e.message})"
|
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
|
end
|
||||||
|
|
||||||
# Haml refactored this logic in 2.3, this is backwards compatibility for either one
|
# 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)
|
if Sass::SyntaxError.respond_to?(:exception_to_css)
|
||||||
|
e.sass_template = sass_filename
|
||||||
Sass::SyntaxError.exception_to_css(e, :full_exception => show_full_exception?)
|
Sass::SyntaxError.exception_to_css(e, :full_exception => show_full_exception?)
|
||||||
else
|
else
|
||||||
Sass::Plugin.options[:full_exception] ||= show_full_exception?
|
Sass::Plugin.options[:full_exception] ||= show_full_exception?
|
||||||
|
@ -2,8 +2,9 @@ require 'sass/plugin'
|
|||||||
|
|
||||||
# XXX: We can remove this monkeypatch once Sass 2.2 is released.
|
# XXX: We can remove this monkeypatch once Sass 2.2 is released.
|
||||||
module Sass::Plugin
|
module Sass::Plugin
|
||||||
class << self
|
|
||||||
unless method_defined?(:exact_stylesheet_needs_update?)
|
# 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)
|
def stylesheet_needs_update?(name, template_path, css_path)
|
||||||
css_file = css_filename(name, css_path)
|
css_file = css_filename(name, css_path)
|
||||||
template_file = template_filename(name, template_path)
|
template_file = template_filename(name, template_path)
|
||||||
@ -19,5 +20,21 @@ module Sass::Plugin
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
else
|
||||||
|
class << self
|
||||||
|
unless method_defined?(:exact_stylesheet_needs_update?)
|
||||||
|
include StylesheetNeedsUpdate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user