diff --git a/lib/compass/commands/project_base.rb b/lib/compass/commands/project_base.rb index f5575d2c..11f096f7 100644 --- a/lib/compass/commands/project_base.rb +++ b/lib/compass/commands/project_base.rb @@ -7,12 +7,12 @@ require File.join(File.dirname(__FILE__), 'base') module Compass module Commands class ProjectBase < Base - attr_accessor :project_directory, :project_name, :options, :project_src_subdirectory, :project_css_subdirectory + attr_accessor :project_directory, :project_name, :options def initialize(working_directory, options = {}) super(working_directory, options) self.project_name = determine_project_name(working_directory, options) - self.project_directory = determine_project_directory(working_directory, options) + Compass.configuration.project_path = determine_project_directory(working_directory, options) assert_project_directory_exists! end @@ -37,13 +37,23 @@ module Compass def projectize(path) File.join(project_directory, separate(path)) end - + + def project_directory + Compass.configuration.project_path + end + + def project_css_subdirectory + Compass.configuration.css_dir + end + def project_src_subdirectory + Compass.configuration.sass_dir + end # Read the configuration file for this project def read_project_configuration - config_file = projectize('src/config.rb') - if File.exists?(config_file) - contents = open(config_file) {|f| f.read} - eval(contents, nil, config_file) + if File.exists?(projectize('config.rb')) + Compass.configuration.parse(projectize('config.rb')) + elsif File.exists?(projectize('src/config.rb')) + Compass.configuration.parse(projectize('src/config.rb')) end end diff --git a/lib/compass/commands/update_project.rb b/lib/compass/commands/update_project.rb index ab36e69b..ad7dc4af 100644 --- a/lib/compass/commands/update_project.rb +++ b/lib/compass/commands/update_project.rb @@ -56,12 +56,12 @@ module Compass # The subdirectory where the sass source is kept. def project_src_subdirectory - @project_src_subdirectory ||= options[:src_dir] || "src" + Compass.configuration.sass_dir ||= options[:src_dir] || "src" end # The subdirectory where the css output is kept. def project_css_subdirectory - @project_css_subdirectory ||= options[:css_dir] || "stylesheets" + Compass.configuration.css_dir ||= options[:css_dir] || "stylesheets" end # The directory where the project source files are located. diff --git a/lib/compass/configuration.rb b/lib/compass/configuration.rb index bcc60db4..04b87232 100644 --- a/lib/compass/configuration.rb +++ b/lib/compass/configuration.rb @@ -13,6 +13,12 @@ module Compass end end + def reset! + [:project_path, :css_dir, :sass_dir, :images_dir, :javascripts_dir].each do |attr| + send("#{attr}=", nil) + end + end + def instance_binding binding end diff --git a/test/command_line_test.rb b/test/command_line_test.rb index c44a5deb..b3af8cce 100644 --- a/test/command_line_test.rb +++ b/test/command_line_test.rb @@ -6,6 +6,11 @@ require 'timeout' class CommandLineTest < Test::Unit::TestCase include Compass::TestCaseHelper + + def teardown + Compass.configuration.reset! + end + def test_basic_install within_tmp_directory do compass "basic"