From ae4daa2572915d9e3cb44574190edd156de20c00 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 5 Apr 2009 03:50:41 -0700 Subject: [PATCH] Better rails boot sequence for compass that is both rails and compass command line friendly. --- lib/compass/configuration.rb | 6 ++++-- lib/compass/installers/rails.rb | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/compass/configuration.rb b/lib/compass/configuration.rb index d48a4a5d..b8819775 100644 --- a/lib/compass/configuration.rb +++ b/lib/compass/configuration.rb @@ -111,8 +111,10 @@ module Compass if respond_to?("comment_for_#{prop}") contents << send("comment_for_#{prop}") end - unless value.nil? - contents << %Q(#{prop} = #{value.inspect}\n) + if block_given? && (to_emit = yield(prop, value)) + contents << to_emit + else + contents << %Q(#{prop} = #{value.inspect}\n) unless value.nil? end end contents diff --git a/lib/compass/installers/rails.rb b/lib/compass/installers/rails.rb index 1887e99e..f8846b0a 100644 --- a/lib/compass/installers/rails.rb +++ b/lib/compass/installers/rails.rb @@ -4,7 +4,7 @@ module Compass class RailsInstaller < Base def configure - configuration_file = targetize('config/initializers/compass.rb') + configuration_file = targetize('config/compass.config') if File.exists?(configuration_file) open(configuration_file) do |config| eval(config.read, nil, configuration_file) @@ -20,6 +20,11 @@ module Compass end def prepare + write_file(targetize('config/compass.config'), Compass.configuration.serialize do |prop, value| + if prop == :project_path + "project_path = RAILS_ROOT if defined?(RAILS_ROOT)\n" + end + end) write_file targetize('config/initializers/compass.rb'), initializer_contents end @@ -81,11 +86,7 @@ Emit compiled stylesheets to #{recommended_location}/? (Y/n) } def initializer_contents %Q{require 'compass' # If you have any compass plugins, require them here. -Compass.configuration do |config| - config.project_path = RAILS_ROOT - config.sass_dir = "#{sass_dir}" - config.css_dir = "#{css_dir}" -end +Compass.configuration.parse(File.join(RAILS_ROOT, "config", "compass.config")) Compass.configure_sass_plugin! } end