Module: Compass

Extended by:
HasDeprecatedConstantsFromCore
Defined in:
lib/compass/core.rb,
lib/compass/error.rb,
lib/compass/frameworks.rb,
lib/compass/core/version.rb,
lib/compass/configuration.rb,
lib/compass/browser_support.rb,
lib/compass/configuration/data.rb,
lib/compass/configuration/watch.rb,
lib/compass/configuration/adapters.rb,
lib/compass/configuration/defaults.rb,
lib/compass/core/generated_version.rb,
lib/compass/configuration/inheritance.rb

Defined Under Namespace

Modules: BrowserSupport, Configuration, Core, Frameworks, HasDeprecatedConstantsFromCore, SassExtensions, Util Classes: Error

Class Method Summary collapse

Methods included from HasDeprecatedConstantsFromCore

extended

Class Method Details

.add_configuration(data, filename = nil) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# 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

.configurationObject

The Compass configuration singleton.



122
123
124
125
126
127
128
# File 'lib/compass/configuration.rb', line 122

def configuration
  @configuration ||= default_configuration
  if block_given?
    yield @configuration
  end
  @configuration
end

.default_configurationObject



130
131
132
# 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) ⇒ Object



162
163
164
165
166
167
168
169
# 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!Object



169
170
171
172
173
174
175
176
177
178
179
# 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!Object



157
158
159
160
161
162
163
164
165
166
167
# 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) ⇒ Object

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



157
158
159
160
# 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!Object



152
153
154
# File 'lib/compass/configuration.rb', line 152

def reset_configuration!
  @configuration = nil
end

.shared_extension_pathsObject



49
50
51
52
53
54
55
56
57
58
59
# 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