[Rails] Fix a setup bug and handle compass configuration changes at rails boot.

Existing rails projects should change their compass initializer file to:

    require 'compass'
    rails_root = (defined?(Rails) ? Rails.root : RAILS_ROOT).to_s
    Compass.add_project_configuration(File.join(rails_root, "config", "compass.rb"))
    Compass.configure_sass_plugin!
    Compass.handle_configuration_change!
This commit is contained in:
Chris Eppstein 2010-02-13 17:07:34 -08:00
parent c1b903024f
commit 8172fce22a
4 changed files with 21 additions and 8 deletions

View File

@ -20,6 +20,12 @@ module Compass
extend(ConfigurationDefaults)
end
def env
if rails_env = (defined?(::Rails) ? ::Rails.env : (defined?(RAILS_ENV) ? RAILS_ENV : nil))
rails_env.production? ? :production : :development
end
end
end
end
end

View File

@ -80,9 +80,12 @@ module Compass
end
def config_contents
"# This configuration file works with both the Compass command line tool and within Rails.\n" +
Compass.configuration.serialize do |prop, value|
if prop == :project_path
"project_path = RAILS_ROOT if defined?(RAILS_ROOT)\n"
elsif prop == :environment
"environment = Compass::AppIntegration::Rails.env\n"
elsif prop == :output_style
""
end
@ -91,11 +94,11 @@ module Compass
def initializer_contents
%Q{require 'compass'
# If you have any compass plugins, require them here.
Compass.configuration.parse(File.join(RAILS_ROOT, "config", "compass.rb"))
Compass.configuration.environment = (defined?(Rails) ? Rails.env : RAILS_ENV).to_sym
Compass.configure_sass_plugin!
}
|rails_root = (defined?(Rails) ? Rails.root : RAILS_ROOT).to_s
|Compass.add_project_configuration(File.join(rails_root, "config", "compass.rb"))
|Compass.configure_sass_plugin!
|Compass.handle_configuration_change!
|}.gsub(/^\s+\|/,'')
end
def stylesheet_prefix

View File

@ -145,13 +145,17 @@ module Compass
end
end
def debug
def chain
instances = [self]
instances << instances.last.inherited_data while instances.last.inherited_data
instances
end
def debug
normalized_attrs = {}
ATTRIBUTES.each do |prop|
values = []
instances.each do |instance|
chain.each do |instance|
values << {
:raw => (instance.send("raw_#{prop}") rescue nil),
:value => (instance.send("#{prop}_without_default") rescue nil),