From f11e5a3205059caeb8edab524dfbb6c7529ebcbf Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Mon, 30 Jan 2012 22:32:05 -0500 Subject: [PATCH] refactored the previous change --- lib/compass/app_integration.rb | 6 +++--- lib/compass/configuration/helpers.rb | 10 +++++----- test/units/sprites/sprite_command_test.rb | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/compass/app_integration.rb b/lib/compass/app_integration.rb index 640aebcd..2439984d 100644 --- a/lib/compass/app_integration.rb +++ b/lib/compass/app_integration.rb @@ -9,15 +9,15 @@ module Compass } def init - @project_types ||= DEAFULT_PROJECT_TYPES + @project_types ||= DEAFULT_PROJECT_TYPES.dup end def project_types @project_types end - def any? - @project_types == DEAFULT_PROJECT_TYPES + def default? + @project_types.keys === DEAFULT_PROJECT_TYPES.keys end def lookup(type) diff --git a/lib/compass/configuration/helpers.rb b/lib/compass/configuration/helpers.rb index f253c3e2..33071fc8 100644 --- a/lib/compass/configuration/helpers.rb +++ b/lib/compass/configuration/helpers.rb @@ -94,7 +94,7 @@ module Compass configuration_file_path = args.shift || detect_configuration_file raise ArgumentError, "Too many arguments" if args.any? - if data = configuration_for(configuration_file_path, nil, configuration_for(options[:defaults])) + if AppIntegration.default? && data = configuration_for(configuration_file_path, nil, configuration_for(options[:defaults])) if data.raw_project_type add_configuration(data.raw_project_type.to_sym) elsif options[:project_type] @@ -102,10 +102,10 @@ module Compass else add_configuration(:stand_alone) end - - unless AppIntegration.any? - add_configuration(data) - end + + + add_configuration(data) + else add_configuration(options[:project_type] || configuration.project_type_without_default || (yield if block_given?) || :stand_alone) end diff --git a/test/units/sprites/sprite_command_test.rb b/test/units/sprites/sprite_command_test.rb index 12a86786..8b262079 100644 --- a/test/units/sprites/sprite_command_test.rb +++ b/test/units/sprites/sprite_command_test.rb @@ -11,7 +11,8 @@ class SpriteCommandTest < Test::Unit::TestCase @before_dir = ::Dir.pwd create_temp_cli_dir create_sprite_temp - File.open(File.join(@test_dir, 'config.rb'), 'w') do |f| + @config_file = File.join(@test_dir, 'config.rb') + File.open(@config_file, 'w') do |f| f << config_data end end