### Home Classes Methods

### In Files

- lib/compass/configuration/helpers.rb

### Methods

- #add_configuration
- #add_project_configuration
- #compiler
- #configuration
- #configuration_for
- #configure_sass_plugin!
- #default_configuration
- #deprojectize
- #detect_configuration_file
- #discover_extensions!
- #handle_configuration_change!
- #projectize
- #reset_configuration!
- #sass_engine_options
- #sass_plugin_configuration

### 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::Configuration::Helpers

The helpers are available as methods on the Compass module. E.g. Compass.configuration

### Constants

KNOWN_CONFIG_LOCATIONS

  TODO: Deprecate the src/config.rb location.

### Public Instance Methods

add_configuration(config, filename = nil) click to toggle source

    # File lib/compass/configuration/helpers.rb, line 18
    def add_configuration(config, filename = nil)
      return if config.nil?

      data = configuration_for(config, filename)

      # puts "New configuration: #{data.name}"
      # puts caller.join("\n")
      data.inherit_from!(configuration)
      data.on_top!
      @configuration = data
    end

add_project_configuration(*args) click to toggle source

Read the configuration file for this project

    # File lib/compass/configuration/helpers.rb, line 92
    def add_project_configuration(*args)
      options = args.last.is_a?(Hash) ? args.pop : {}
      configuration_file_path = args.shift || detect_configuration_file

      raise ArgumentError, "Too many arguments" if args.any?
      if AppIntegration.default? && data = configuration_for(configuration_file_path, nil, configuration_for(options[:defaults]))
        if data.raw_project_type
          add_configuration(data.raw_project_type.to_sym)
        elsif options[:project_type]
          add_configuration(options[:project_type])
        else
          add_configuration(:stand_alone)
        end
        add_configuration(data)
      else
        add_configuration(options[:project_type] || configuration.project_type_without_default || (yield if block_given?) || :stand_alone)
      end
    end

compiler() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 152
    def compiler
      Compass::Compiler.new(*Compass.configuration.to_compiler_arguments)
    end

configuration() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 6
    def configuration
      @configuration ||= default_configuration
      if block_given?
        yield @configuration
      end
      @configuration
    end

configuration_for(config, filename = nil, defaults = nil) click to toggle source

    # File lib/compass/configuration/helpers.rb, line 31
    def configuration_for(config, filename = nil, defaults = nil)
      if config.nil?
        nil
      elsif config.is_a?(Compass::Configuration::Data)
        config
      elsif config.respond_to?(:read)
        filename ||= config.to_s if config.is_a?(Pathname)
        Compass::Configuration::FileData.new_from_string(config.read, filename, defaults)
      elsif config.is_a?(Hash)
        Compass::Configuration::Data.new(filename, config)
      elsif config.is_a?(String)
        Compass::Configuration::FileData.new_from_file(config, defaults)
      elsif config.is_a?(Symbol)
        Compass::AppIntegration.lookup(config).configuration
      else
        raise "I don't know what to do with: #{config.inspect}"
      end
    end

configure_sass_plugin!() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 59
    def configure_sass_plugin!
      require 'sass/plugin'
      config = sass_plugin_configuration
      locations = config.delete(:template_location)
      Sass::Plugin.options.merge!(config)
      locations.each do |sass_dir, css_dir|
        unless Sass::Plugin.engine_options[:load_paths].include?(sass_dir)
          Sass::Plugin.add_template_location sass_dir, css_dir
        end
      end
      unless @callbacks_loaded
        on_saved = Proc.new do |sass_file, css_file|
                     Compass.configuration.run_stylesheet_saved(css_file)
                   end
        if Sass::Plugin.respond_to?(:on_updated_stylesheet)
          Sass::Plugin.on_updated_stylesheet(&on_saved)
        else
          Sass::Plugin.on_updating_stylesheet(&on_saved)
        end

        Sass::Plugin.on_compilation_error do |e, filename, css|
          Compass.configuration.run_stylesheet_error(filename, e.message)
        end

        @callbacks_loaded = true
      end
    end

default_configuration() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 14
    def default_configuration
      Data.new('defaults').extend(Defaults).extend(Comments)
    end

deprojectize(path, project_path = nil) click to toggle source

    # File lib/compass/configuration/helpers.rb, line 128
    def deprojectize(path, project_path = nil)
      project_path ||= configuration.project_path
      if path[0..(project_path.size - 1)] == project_path
        path[(project_path.size + 1)..-1]
      else
        path
      end
    end

detect_configuration_file(project_path = nil) click to toggle source

Finds the configuration file, if it exists in a known location.

    # File lib/compass/configuration/helpers.rb, line 141
    def detect_configuration_file(project_path = nil)
      possible_files = KNOWN_CONFIG_LOCATIONS.map{|f| projectize(f, project_path) }
      possible_files.detect{|f| File.exists?(f)}
    end

discover_extensions!() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 111
    def discover_extensions!
      Compass.shared_extension_paths.each do |extensions_path|
        if File.directory?(extensions_path)
          Compass::Frameworks.discover(extensions_path)
        end
      end
      if File.directory?(configuration.extensions_path)
        Compass::Frameworks.discover(configuration.extensions_path)
      end
    end

handle_configuration_change!() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 146
    def handle_configuration_change!
      if (compiler = Compass.compiler).new_config?
        compiler.clean!
      end
    end

projectize(path, project_path = nil) click to toggle source

Returns a full path to the relative path to the project directory

    # File lib/compass/configuration/helpers.rb, line 123
    def projectize(path, project_path = nil)
      project_path ||= configuration.project_path
      File.join(project_path, *path.split('/'))
    end

reset_configuration!() click to toggle source

Support for testing.

    # File lib/compass/configuration/helpers.rb, line 51
    def reset_configuration!
      @configuration = nil
    end

sass_engine_options() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 87
    def sass_engine_options
      configuration.to_sass_engine_options
    end

sass_plugin_configuration() click to toggle source

    # File lib/compass/configuration/helpers.rb, line 55
    def sass_plugin_configuration
      configuration.to_sass_plugin_options
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.