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

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. All Rack-enabled frameworks are supported out of the box. The plugin is {file:SASS_REFERENCE.md#rails_merb_plugin automatically activated for Rails and Merb}. Other frameworks must enable it explicitly; see {Sass::Plugin::Rack}.

Methods

Classes and Modules

Class Sass::Plugin::Rack

Attributes

checked_for_updates  [R]  Whether or not Sass has *ever* checked if the stylesheets need to be updated (in this Ruby instance).

@return [Boolean]

options  [R]  An options hash. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@return [{Symbol => Object}]

Public Instance methods

Same as \{update_stylesheets}, but respects \{checked_for_updates} and the {file:SASS_REFERENCE.md#always_update-option `:always_update`} and {file:SASS_REFERENCE.md#always_check-option `:always_check`} options.

@see update_stylesheets

[Source]

    # File lib/sass/plugin.rb, line 60
60:     def check_for_updates
61:       return unless !Sass::Plugin.checked_for_updates ||
62:           Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
63:       update_stylesheets
64:     end

Non-destructively modifies \{options} so that default values are properly set.

@param additional_options [{Symbol => Object}] An options hash with which to merge \{options} @return [{Symbol => Object}] The modified options hash

[Source]

    # File lib/sass/plugin.rb, line 49
49:     def engine_options(additional_options = {})
50:       opts = options.dup.merge(additional_options)
51:       opts[:load_paths] = load_paths(opts)
52:       opts
53:     end

Sets the options hash. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@param value [{Symbol => Object}] The options hash

[Source]

    # File lib/sass/plugin.rb, line 41
41:     def options=(value)
42:       @options.merge!(value)
43:     end

Updates out-of-date stylesheets.

Checks each Sass file in {file:SASS_REFERENCE.md#template_location-option `:template_location`} to see if it‘s been modified more recently than the corresponding CSS file in {file:SASS_REFERENCE.md#css_location-option `:css_location`}. If it has, it updates the CSS file.

[Source]

    # File lib/sass/plugin.rb, line 72
72:     def update_stylesheets
73:       return if options[:never_update]
74: 
75:       @checked_for_updates = true
76:       template_locations.zip(css_locations).each do |template_location, css_location|
77: 
78:         Dir.glob(File.join(template_location, "**", "*.sass")).each do |file|
79:           # Get the relative path to the file with no extension
80:           name = file.sub(template_location.sub(/\/*$/, '/'), "")[0...-5]
81: 
82:           if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name, template_location, css_location))
83:             update_stylesheet(name, template_location, css_location)
84:           end
85:         end
86:       end
87:     end

[Validate]