From c40982c5335b7321bb3881b500ca96317f4d41d3 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 1 Nov 2009 09:59:48 -0800 Subject: [PATCH] Debug configuration with compass config --debug --- lib/compass/commands/write_configuration.rb | 19 +++++++++++++++++-- lib/compass/configuration/inheritance.rb | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/compass/commands/write_configuration.rb b/lib/compass/commands/write_configuration.rb index 1eb865aa..f4fbbd25 100644 --- a/lib/compass/commands/write_configuration.rb +++ b/lib/compass/commands/write_configuration.rb @@ -17,6 +17,9 @@ module Compass Options: }.strip.split("\n").map{|l| l.gsub(/^ {0,10}/,'')}.join("\n") + opts.on("--debug [PROPERTY]", "Debug your configuration by printing out details.") do |prop| + self.options[:debug] = prop.nil? ? true : prop.to_sym + end super end @@ -37,8 +40,20 @@ module Compass end def perform - directory projectize(File.dirname(options[:configuration_file])) - installer.write_configuration_files(options[:configuration_file]) + if options[:debug] + Compass.configuration.debug.each do |prop, values| + if options[:debug].is_a?(Symbol) + next unless prop == options[:debug] + end + puts "***** #{prop} = #{values.first[:resolved].inspect} *****" + [:default, :value, :raw, :resolved].each do |kind| + puts "#{kind}: " + values.inject([]){|m, v| m << v[kind]}.map{|v| v.nil? ? '-' : v.inspect}.join(", ") + end + end + else + directory projectize(File.dirname(options[:configuration_file])) + installer.write_configuration_files(options[:configuration_file]) + end end def installer_args diff --git a/lib/compass/configuration/inheritance.rb b/lib/compass/configuration/inheritance.rb index fd030172..255749c2 100644 --- a/lib/compass/configuration/inheritance.rb +++ b/lib/compass/configuration/inheritance.rb @@ -156,7 +156,7 @@ module Compass :raw => (instance.send("raw_#{prop}") rescue nil), :value => (instance.send("#{prop}_without_default") rescue nil), :default => (instance.send("default_#{prop}") rescue nil), - :resoved => instance.send(prop) + :resolved => instance.send(prop) } end normalized_attrs[prop] = values