Module: Sass::Plugin

### Home Classes Methods

### In Files

- lib/sass/plugin.rb
- lib/sass/plugin/compiler.rb
- lib/sass/plugin/configuration.rb
- lib/sass/plugin/rack.rb
- lib/sass/plugin/staleness_checker.rb

### Namespace

- MODULE Sass::Plugin::Configuration
- CLASS Sass::Plugin::Compiler
- CLASS Sass::Plugin::MerbBootLoader
- CLASS Sass::Plugin::Rack
- CLASS Sass::Plugin::StalenessChecker

### Methods

- #check_for_updates
- #compiler
- #force_update_stylesheets
- #method_missing
- #options
- #respond_to?
- #update_stylesheets

### Class/Module Index

Quicksearch

- Sass
- Sass::BaseEnvironment
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Base
- Sass::Exec::SassConvert
- Sass::Exec::SassScss
- Sass::Exec::SassScss::Sass::Plugin.compiler
- Sass::Features
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::ReadOnlyEnvironment
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Lexer
- Sass::Script::Parser
- Sass::Script::Tree
- Sass::Script::Tree::Funcall
- Sass::Script::Tree::Interpolation
- Sass::Script::Tree::ListLiteral
- Sass::Script::Tree::Literal
- Sass::Script::Tree::MapLiteral
- Sass::Script::Tree::Node
- Sass::Script::Tree::Operation
- Sass::Script::Tree::Selector
- Sass::Script::Tree::StringInterpolation
- Sass::Script::Tree::UnaryOperation
- Sass::Script::Tree::Variable
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::Bool
- Sass::Script::Value::Color
- Sass::Script::Value::Helpers
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Script::Value::Null
- Sass::Script::Value::Number
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::SemiGlobalEnvironment
- Sass::Shared
- Sass::Source
- Sass::Source::Map
- Sass::Source::Map::Mapping
- Sass::Source::Position
- Sass::Source::Range
- Sass::Stack
- Sass::Stack::Frame
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::AtRootNode
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ErrorNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::KeyframeRuleNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::Cssize::Bubble
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::CrossPlatformRandom
- Sass::Util::MultibyteStringScanner
- Sass::Util::NormalizedMap
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object
- OrderedHash

No matching classes.

# Sass::Plugin

This module provides a single interface to the compilation of Sass/SCSS files for an application. 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}.

This module has a large set of callbacks available to allow users to run code (such as logging) when certain things happen. All callback methods are of the form `on_#{name}`, and they all take a block that's called when the given action occurs.

Note that this class proxies almost all methods to its {Sass::Plugin::Compiler} instance. See {#compiler}.

@example Using a callback

    Sass::Plugin.on_updating_stylesheet do |template, css|
      puts "Compiling #{template} to #{css}"
    end
    Sass::Plugin.update_stylesheets
      #=> Compiling app/sass/screen.scss to public/stylesheets/screen.css
      #=> Compiling app/sass/print.scss to public/stylesheets/print.css
      #=> Compiling app/sass/ie.scss to public/stylesheets/ie.css

@see Sass::Plugin::Compiler

### Attributes

checked_for_updates[RW]

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

@return [Boolean]

### Public Instance Methods

check_for_updates() click to toggle source

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

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

compiler() click to toggle source

Returns the singleton compiler instance. This compiler has been pre-configured according to the plugin configuration.

@return [Sass::Plugin::Compiler]

    # File lib/sass/plugin.rb, line 62
    def compiler
      @compiler ||= Compiler.new
    end

force_update_stylesheets(individual_files = []) click to toggle source

Updates all stylesheets, even those that aren't out-of-date. Ignores the cache.

@param individual_files [Array<(String, String)>]

    A list of files to check for updates
    **in addition to those specified by the
    {file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
    The first string in each pair is the location of the Sass/SCSS file,
    the second is the location of the CSS file that it should be compiled to.

@see update_stylesheets

    # File lib/sass/plugin.rb, line 95
    def force_update_stylesheets(individual_files = [])
      Compiler.new(options.dup.merge(
          :never_update => false,
          :always_update => true,
          :cache => false)).update_stylesheets(individual_files)
    end

method_missing(method, *args, &block) click to toggle source

All other method invocations are proxied to the {#compiler}.

@see compiler @see Sass::Plugin::Compiler

    # File lib/sass/plugin.rb, line 106
    def method_missing(method, *args, &block)
      if compiler.respond_to?(method)
        compiler.send(method, *args, &block)
      else
        super
      end
    end

options() click to toggle source

There's a small speedup by not using method missing for frequently delegated methods.

    # File lib/sass/plugin.rb, line 120
    def options
      compiler.options
    end

respond_to?(method) click to toggle source

For parity with method_missing

    # File lib/sass/plugin.rb, line 115
    def respond_to?(method)
      super || compiler.respond_to?(method)
    end

update_stylesheets(individual_files = []) click to toggle source

Updates out-of-date stylesheets.

Checks each Sass/SCSS 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.

@param individual_files [Array<(String, String)>]

    A list of files to check for updates
    **in addition to those specified by the
    {file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
    The first string in each pair is the location of the Sass/SCSS file,
    the second is the location of the CSS file that it should be compiled to.

    # File lib/sass/plugin.rb, line 80
    def update_stylesheets(individual_files = [])
      return if options[:never_update]
      compiler.update_stylesheets(individual_files)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.