Module: Sass::Plugin

Defined in:
lib/sass/plugin.rb

Overview

This module contains methods to aid in using Sass as a stylesheet-rendering plugin for various systems. Currently Rails/ActionController and Merb are supported out of the box.

Constant Summary collapse

@@options =
{
  :css_location       => './public/stylesheets',
  :always_update      => false,
  :always_check       => true,
  :full_exception     => true
}
@@checked_for_updates =
false

Class Method Summary collapse

Class Method Details

.checked_for_updatesObject

Whether or not Sass has ever checked if the stylesheets need updates (in this Ruby instance).



20
21
22
# File 'lib/sass/plugin.rb', line 20

def checked_for_updates
  @@checked_for_updates
end

.engine_options(additional_options = {}) ⇒ Object

Get the options ready to be passed to the Sass::Engine



38
39
40
41
42
# File 'lib/sass/plugin.rb', line 38

def engine_options(additional_options = {})
  opts = options.dup.merge(additional_options)
  opts[:load_paths] = load_paths(opts)
  opts
end

.optionsObject

Gets various options for Sass. See README.rdoc for details. – TODO: *DOCUMENT OPTIONS* ++



28
29
30
# File 'lib/sass/plugin.rb', line 28

def options
  @@options
end

.options=(value) ⇒ Object

Sets various options for Sass.



33
34
35
# File 'lib/sass/plugin.rb', line 33

def options=(value)
  @@options.merge!(value)
end

.update_stylesheetsObject

Checks each stylesheet in options[:css_location] to see if it needs updating, and updates it using the corresponding template from options[:templates] if it does.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sass/plugin.rb', line 49

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