Module Sass::Plugin
In: lib/sass/plugin.rb

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.

Methods

Public Class methods

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

[Source]

    # File lib/sass/plugin.rb, line 20
20:       def checked_for_updates
21:         @@checked_for_updates
22:       end

Gets various options for Sass. See README for details.

[Source]

    # File lib/sass/plugin.rb, line 28
28:       def options
29:         @@options
30:       end

Sets various options for Sass.

[Source]

    # File lib/sass/plugin.rb, line 33
33:       def options=(value)
34:         @@options.merge!(value)
35:       end

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.

[Source]

    # File lib/sass/plugin.rb, line 42
42:       def update_stylesheets
43:         return if options[:never_update]
44: 
45:         @@checked_for_updates = true
46:         Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file|
47: 
48:           # Get the relative path to the file with no extension
49:           name = file.sub(options[:template_location] + "/", "")[0...-5]
50: 
51:           if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name))
52:             css = css_filename(name)
53:             File.delete(css) if File.exists?(css)
54: 
55:             filename = template_filename(name)
56:             l_options = @@options.dup
57:             l_options[:filename] = filename
58:             l_options[:load_paths] = load_paths
59:             engine = Engine.new(File.read(filename), l_options)
60:             result = begin
61:                        engine.render
62:                      rescue Exception => e
63:                        exception_string(e)
64:                      end
65: 
66:             # Create any directories that might be necessary
67:             dirs = [l_options[:css_location]]
68:             name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" }
69:             dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
70: 
71:             # Finally, write the file
72:             File.open(css, 'w') do |file|
73:               file.print(result)
74:             end
75:           end
76:         end
77:       end

[Validate]