### Home Classes Methods

### In Files

- lib/compass/commands/watch_project.rb

### Parent

UpdateProject

### Methods

- ::description
- ::option_parser
- #perform
- #recompile
- #remove_obsolete_css

### Included Modules

- Compass::Commands::MemoryDebugger

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::Rails
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::BrowserSupport
- Compass::Commands
- Compass::Commands::Base
- Compass::Commands::CleanProject
- Compass::Commands::CleanProjectOptionsParser
- Compass::Commands::CompileProjectOptionsParser
- Compass::Commands::ConfigurationOptionsParser
- Compass::Commands::CreateProject
- Compass::Commands::CreateProjectOptionsParser
- Compass::Commands::Default
- Compass::Commands::DefaultOptionsParser
- Compass::Commands::ExtensionCommand
- Compass::Commands::ExtensionOptionsParser
- Compass::Commands::ExtensionsOptionParser
- Compass::Commands::GenerateGridBackground
- Compass::Commands::GridBackgroundOptionsParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::MemoryDebugger
- Compass::Commands::PrintVersion
- Compass::Commands::ProjectBase
- Compass::Commands::ProjectStats
- Compass::Commands::Registry
- Compass::Commands::Sprite
- Compass::Commands::SpriteOptionsParser
- Compass::Commands::StampPattern
- Compass::Commands::StampPatternOptionsParser
- Compass::Commands::StatsOptionsParser
- Compass::Commands::StructureOptionsParser
- Compass::Commands::UnpackExtension
- Compass::Commands::UpdateProject
- Compass::Commands::ValidateProject
- Compass::Commands::ValidationOptionsParser
- Compass::Commands::VersionOptionsParser
- Compass::Commands::WatchProject
- Compass::Commands::WatchProjectOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Serialization
- Compass::Error
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::Exec::SwitchUI
- Compass::FilesystemConflict
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::GridBuilder
- Compass::Installers
- Compass::Installers::BareInstaller
- Compass::Installers::Base
- Compass::Installers::Manifest
- Compass::Installers::Manifest::Entry
- Compass::Installers::ManifestInstaller
- Compass::Installers::TemplateContext
- Compass::Logger
- Compass::MissingDependency
- Compass::NullLogger
- Compass::PNG
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::Colors
- Compass::SassExtensions::Functions::Constants
- Compass::SassExtensions::Functions::CrossBrowserSupport
- Compass::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::SassExtensions::Functions::Display
- Compass::SassExtensions::Functions::Enumerate
- Compass::SassExtensions::Functions::Env
- Compass::SassExtensions::Functions::FontFiles
- Compass::SassExtensions::Functions::GradientSupport
- Compass::SassExtensions::Functions::GradientSupport::Assertions
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::SassExtensions::Functions::GradientSupport::Functions
- Compass::SassExtensions::Functions::GradientSupport::Gradient
- Compass::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::SassExtensions::Functions::ImageSize
- Compass::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::SassExtensions::Functions::ImageSize::JPEG
- Compass::SassExtensions::Functions::InlineImage
- Compass::SassExtensions::Functions::Lists
- Compass::SassExtensions::Functions::Math
- Compass::SassExtensions::Functions::Selectors
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Functions::Urls
- Compass::SassExtensions::Functions::Urls::FontUrl
- Compass::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::SassExtensions::Functions::Urls::ImageUrl
- Compass::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::SassExtensions::Sprites
- Compass::SassExtensions::Sprites::ChunkyPngEngine
- Compass::SassExtensions::Sprites::Engine
- Compass::SassExtensions::Sprites::Image
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::ImageRow
- Compass::SassExtensions::Sprites::LayoutMethods
- Compass::SassExtensions::Sprites::RowFitter
- Compass::SassExtensions::Sprites::SpriteMap
- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SpriteException
- Compass::SpriteImporter
- Compass::Sprites
- Compass::Sprites::Binding
- Compass::Stats
- Compass::Stats::CssFile
- Compass::Stats::SassFile
- Compass::Stats::StatsVisitor
- Compass::TestCase
- Compass::Util
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Tree
- Sass::Tree::Node
- QuickCache

No matching classes.

# Compass::Commands::WatchProject

### Attributes

last_sass_files[RW]
last_update_time[RW]

### Public Class Methods

description(command) click to toggle source

    # File lib/compass/commands/watch_project.rb, line 156
    def description(command)
      "Compile Sass stylesheets to CSS when they change"
    end

option_parser(arguments) click to toggle source

    # File lib/compass/commands/watch_project.rb, line 160
    def option_parser(arguments)
      parser = Compass::Exec::CommandOptionParser.new(arguments)
      parser.extend(Compass::Exec::GlobalOptionsParser)
      parser.extend(Compass::Exec::ProjectOptionsParser)
      parser.extend(CompileProjectOptionsParser)
      parser.extend(WatchProjectOptionsParser)
    end

### Public Instance Methods

perform() click to toggle source

    # File lib/compass/commands/watch_project.rb, line 61
    def perform
      Signal.trap("INT") do
        puts ""
        exit 0
      end

      check_for_sass_files!(new_compiler_instance)
      recompile

      require 'fssm'

      if options[:poll]
        require "fssm/backends/polling"
        # have to silence the ruby warning about chaning a constant.
        stderr, $stderr = $stderr, StringIO.new
        FSSM::Backends.const_set("Default", FSSM::Backends::Polling)
        $stderr = stderr
      end

      action = FSSM::Backends::Default.to_s == "FSSM::Backends::Polling" ? "polling" : "watching"

      puts ">>> Compass is #{action} for changes. Press Ctrl-C to Stop."
      $stdout.flush

      begin
      FSSM.monitor do |monitor|
        Compass.configuration.sass_load_paths.each do |load_path|
          load_path = load_path.root if load_path.respond_to?(:root)
          next unless load_path.is_a? String
          monitor.path load_path do |path|
            path.glob '**/*.s[ac]ss'

            path.update &method(:recompile)
            path.delete {|base, relative| remove_obsolete_css(base,relative); recompile(base, relative)}
            path.create &method(:recompile)
          end
        end
        Compass.configuration.watches.each do |glob, callback|
          monitor.path Compass.configuration.project_path do |path|
            path.glob glob
            path.update do |base, relative|
              puts ">>> Change detected to: #{relative}"
              $stdout.flush
              callback.call(base, relative)
            end
            path.create do |base, relative|
              puts ">>> New file detected: #{relative}"
              $stdout.flush
              callback.call(base, relative)
            end
            path.delete do |base, relative|
              puts ">>> File Removed: #{relative}"
              $stdout.flush
              callback.call(base, relative)
            end
          end
        end

      end
    rescue FSSM::CallbackError => e
      # FSSM catches exit? WTF.
      if e.message =~ /exit/
        exit
      end
    end
    end

recompile(base = nil, relative = nil) click to toggle source

    # File lib/compass/commands/watch_project.rb, line 140
    def recompile(base = nil, relative = nil)
      @memory_cache.reset! if @memory_cache
      compiler = new_compiler_instance(:quiet => true, :loud => [:identical, :overwrite, :create])
      if file = compiler.out_of_date?
        begin
          puts ">>> Change detected at "+Time.now.strftime("%T")+" to: #{relative || compiler.relative_stylesheet_name(file)}"
          $stdout.flush
          compiler.run
          GC.start
        rescue StandardError => e
          ::Compass::Exec::Helpers.report_error(e, options)
        end
      end
    end

remove_obsolete_css(base = nil, relative = nil) click to toggle source

    # File lib/compass/commands/watch_project.rb, line 129
    def remove_obsolete_css(base = nil, relative = nil)
      compiler = new_compiler_instance(:quiet => true)
      sass_files = compiler.sass_files
      deleted_sass_files = (last_sass_files || []) - sass_files
      deleted_sass_files.each do |deleted_sass_file|
        css_file = compiler.corresponding_css_file(deleted_sass_file)
        remove(css_file) if File.exists?(css_file)
      end
      self.last_sass_files = sass_files
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.