Module: Sass::Plugin
Overview
This module handles the compilation of Sass files. It provides global options and checks whether CSS files need to be updated.
This module is used as the primary interface with Sass when it's used as a plugin for various frameworks. Currently Rails and Merb are supported out of the box.
Constant Summary
Constants included from Haml::Util
Instance Attribute Summary collapse
-
#checked_for_updates ⇒ Boolean
readonly
Whether or not Sass has ever checked if the stylesheets need to be updated (in this Ruby instance).
-
#options ⇒ Hash<Symbol, Object>
An options hash.
Instance Method Summary collapse
-
#check_for_updates ⇒ Object
Same as #update_stylesheets, but respects #checked_for_updates and the
:always_update
and:always_check
options. -
#engine_options(additional_options = {}) ⇒ Hash<Symbol, Object>
Non-destructively modifies #options so that default values are properly set.
-
#update_stylesheets ⇒ Object
Updates out-of-date stylesheets.
Methods included from Haml::Util
#assert_html_safe!, #caller_info, #check_encoding, #def_static_method, #enum_with_index, #has?, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #powerset, #rails_root, #rails_xss_safe?, #ruby1_8?, #scope, #static_method_name, #to_hash
Instance Attribute Details
#checked_for_updates ⇒ Boolean (readonly)
Whether or not Sass has ever checked if the stylesheets need to be updated (in this Ruby instance).
27 28 29 |
# File 'lib/sass/plugin.rb', line 27
def checked_for_updates
@checked_for_updates
end
|
#options ⇒ Hash<Symbol, Object>
An options hash. See the Sass options documentation.
33 34 35 |
# File 'lib/sass/plugin.rb', line 33
def options
@options
end
|
Instance Method Details
#check_for_updates ⇒ Object
Same as #update_stylesheets, but respects #checked_for_updates
and the :always_update
and :always_check
options.
58 59 60 61 62 |
# File 'lib/sass/plugin.rb', line 58
def check_for_updates
return unless !Sass::Plugin.checked_for_updates ||
Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
update_stylesheets
end
|
#engine_options(additional_options = {}) ⇒ Hash<Symbol, Object>
Non-destructively modifies #options so that default values are properly set.
47 48 49 50 51 |
# File 'lib/sass/plugin.rb', line 47
def engine_options(additional_options = {})
opts = options.dup.merge(additional_options)
opts[:load_paths] = load_paths(opts)
opts
end
|
#update_stylesheets ⇒ Object
Updates out-of-date stylesheets.
Checks each Sass file in :template_location
to see if it's been modified more recently than the corresponding CSS file
in SASS_REFERENCE :css_location
}.
If it has, it updates the CSS file.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sass/plugin.rb', line 70
def update_stylesheets
return if options[:never_update]
@checked_for_updates = true
template_locations.zip(css_locations).each do |template_location, css_location|
Dir.glob(File.join(template_location, "**", "*.sass")).each do |file|
# Get the relative path to the file with no extension
name = file.sub(template_location + "/", "")[0...-5]
if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name, template_location, css_location))
update_stylesheet(name, template_location, css_location)
end
end
end
end
|