module Compass

Public Class Methods

add_configuration(data, filename = nil) click to toggle source
# File lib/compass/configuration.rb, line 134
def add_configuration(data, filename = nil)
  return if data.nil?


  unless data.is_a?(Compass::Configuration::Data)
    # XXX HAX Need to properly factor this apart from the main compass project
    if respond_to?(:configuration_for)
      data = configuration_for(data, filename)
    else
      raise ArgumentError, "Invalid argument: #{data.inspect}"
    end
  end

  data.inherit_from!(configuration) if configuration
  data.on_top!
  @configuration = data
end
configuration() { |configuration| ... } click to toggle source

The Compass configuration singleton.

# File lib/compass/configuration.rb, line 122
def configuration
  @configuration ||= default_configuration
  if block_given?
    yield @configuration
  end
  @configuration
end
default_configuration() click to toggle source
# File lib/compass/configuration.rb, line 130
def default_configuration
  Compass::Configuration::Data.new('defaults').extend(Compass::Configuration::Defaults)
end
deprojectize(path, project_path = nil) click to toggle source
# File lib/compass/configuration.rb, line 162
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
discover_extensions!() click to toggle source
# File lib/compass/frameworks.rb, line 169
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
  discover_gem_extensions!
end
discover_gem_extensions!() click to toggle source
# File lib/compass/frameworks.rb, line 157
def discover_gem_extensions!
  if defined?(Gem)
    Gem.find_files("compass-*").map{|f| File.basename(f, ".rb")}.each do |compass_extension|
      begin
        require compass_extension
      rescue Gem::LoadError, LoadError
        Compass::Util.compass_warn "Unable to load extension: #{compass_extension}"
      end
    end
  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.rb, line 157
def projectize(path, project_path = nil)
  project_path ||= configuration.project_path
  File.join(project_path, *path.split('/'))
end
reset_configuration!() click to toggle source
# File lib/compass/configuration.rb, line 152
def reset_configuration!
  @configuration = nil
end
shared_extension_paths() click to toggle source
# File lib/compass/core.rb, line 49
def shared_extension_paths
  @shared_extension_paths ||= begin
    if ENV["HOME"] && File.directory?(ENV["HOME"])
      [File.join(ENV["HOME"], ".compass", "extensions")]
    else
      []
    end
  rescue ArgumentError # If HOME is relative
    []
  end
end

Private Instance Methods

shared_extension_paths() click to toggle source
# File lib/compass/core.rb, line 49
def shared_extension_paths
  @shared_extension_paths ||= begin
    if ENV["HOME"] && File.directory?(ENV["HOME"])
      [File.join(ENV["HOME"], ".compass", "extensions")]
    else
      []
    end
  rescue ArgumentError # If HOME is relative
    []
  end
end