From 03e01c4eb228bdb745a62d117388b37838904bda Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 30 Oct 2010 15:37:50 -0700 Subject: [PATCH] Add the ability to print out compass configuration values --- doc-src/content/CHANGELOG.markdown | 5 +++++ features/command_line.feature | 18 ++++++++++++++++++ .../step_definitions/command_line_steps.rb | 7 +++++++ lib/compass/commands/write_configuration.rb | 11 ++++++++++- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/doc-src/content/CHANGELOG.markdown b/doc-src/content/CHANGELOG.markdown index 1b831e8a..c9424b74 100644 --- a/doc-src/content/CHANGELOG.markdown +++ b/doc-src/content/CHANGELOG.markdown @@ -7,6 +7,11 @@ layout: article COMPASS CHANGELOG ================= +0.10.7 (UNRELEASED) +------------------- +* compass config -p -- will now print out the configuration value + for that property for the current project + 0.10.6 (10/11/2010) ------------------- diff --git a/features/command_line.feature b/features/command_line.feature index dbf3db33..110b7700 100644 --- a/features/command_line.feature +++ b/features/command_line.feature @@ -247,6 +247,24 @@ Feature: Command Line | sass_dir | sass | | css_dir | assets/css | + @now + Scenario Outline: Print out a configuration value + Given I am using the existing project in test/fixtures/stylesheets/compass + When I run: compass config -p + Then I should see the following output: + And the command exits + + Examples: + | property | value | exit | + | extensions_dir | extensions | normally | + | extensions_path | $PROJECT_PATH/extensions | normally | + | css_dir | tmp | normally | + | css_path | $PROJECT_PATH/tmp | normally | + | sass_dir | sass | normally | + | sass_path | $PROJECT_PATH/sass | normally | + | foobar | ERROR: configuration property 'foobar' does not exist | with a non-zero error code | + + @validator @ignore Scenario: Validate the generated CSS Given I am using the existing project in test/fixtures/stylesheets/compass When I run: compass validate diff --git a/features/step_definitions/command_line_steps.rb b/features/step_definitions/command_line_steps.rb index 7da0e42f..cc0f8e94 100644 --- a/features/step_definitions/command_line_steps.rb +++ b/features/step_definitions/command_line_steps.rb @@ -154,6 +154,9 @@ Then /^the command exits with a non\-zero error code$/ do @last_exit_code.should_not == 0 end +Then /^the command exits normally$/ do + @last_exit_code.should_not =~ 0 +end Then /^I am congratulated$/ do @last_result.should =~ /Congratulations!/ @@ -234,3 +237,7 @@ end Then /^I should see the following lines of output:$/ do |table| table.diff!([['blueprint'],['compass']]) end + +Then /^I should see the following output: (.*)$/ do |output| + (@last_result + @last_error).strip.should == output.gsub(/\$PROJECT_PATH/,Dir.pwd).strip +end diff --git a/lib/compass/commands/write_configuration.rb b/lib/compass/commands/write_configuration.rb index bc7d6988..83035aed 100644 --- a/lib/compass/commands/write_configuration.rb +++ b/lib/compass/commands/write_configuration.rb @@ -20,6 +20,9 @@ module Compass opts.on("--debug [PROPERTY]", "Debug your configuration by printing out details.") do |prop| self.options[:debug] = prop.nil? ? true : prop.to_sym end + opts.on("-p PROPERTY", "--property PROPERTY", "Print out the value of a particular configuration property") do |prop| + self.options[:display] = prop.to_sym + end super end @@ -40,7 +43,13 @@ module Compass end def perform - if options[:debug] + if options[:display] + if Compass.configuration.respond_to?(options[:display]) + puts Compass.configuration.send(options[:display]) + else + raise Compass::Error, "ERROR: configuration property '#{options[:display]}' does not exist" + end + elsif options[:debug] puts "Configuration sources:" c = Compass.configuration while c