diff --git a/lib/compass/commands/create_project.rb b/lib/compass/commands/create_project.rb index ad3ef3d0..e768b2f4 100644 --- a/lib/compass/commands/create_project.rb +++ b/lib/compass/commands/create_project.rb @@ -17,11 +17,13 @@ module Compass # all commands must implement perform def perform directory nil, options - directory 'stylesheets', options.merge(:force => true) - directory 'src', options.merge(:force => true) - template 'project/screen.sass', 'src/screen.sass', options - template 'project/print.sass', 'src/print.sass', options - template 'project/ie.sass', 'src/ie.sass', options + src_dir = options[:src_dir] || "src" + css_dir = options[:css_dir] || "stylesheets" + directory src_dir, options.merge(:force => true) + directory css_dir, options.merge(:force => true) + template 'project/screen.sass', "#{src_dir}/screen.sass", options + template 'project/print.sass', "#{src_dir}/print.sass", options + template 'project/ie.sass', "#{src_dir}/ie.sass", options UpdateProject.new(working_directory, options).perform end diff --git a/lib/compass/commands/update_project.rb b/lib/compass/commands/update_project.rb index c256c677..d5f935dd 100644 --- a/lib/compass/commands/update_project.rb +++ b/lib/compass/commands/update_project.rb @@ -11,7 +11,7 @@ module Compass Base::ACTIONS << :compile Base::ACTIONS << :overwrite - attr_accessor :project_directory, :project_name, :options + attr_accessor :project_directory, :project_name, :options, :project_src_subdirectory, :project_css_subdirectory def initialize(working_directory, options = {}) super(working_directory, options) @@ -36,9 +36,9 @@ module Compass end def perform - Dir.glob(separate("#{project_directory}/src/**/[^_]*.sass")).each do |sass_file| - stylesheet_name = sass_file[("#{project_directory}/src/".length)..-6] - compile "src/#{stylesheet_name}.sass", "stylesheets/#{stylesheet_name}.css", options + Dir.glob(separate("#{project_src_directory}/**/[^_]*.sass")).each do |sass_file| + stylesheet_name = sass_file[("#{project_src_directory}/".length)..-6] + compile "#{project_src_subdirectory}/#{stylesheet_name}.sass", "#{project_css_subdirectory}/#{stylesheet_name}.css", options end end @@ -81,9 +81,19 @@ module Compass @sass_load_paths ||= [project_src_directory] + Compass::Frameworks::ALL.map{|f| f.stylesheets_directory} end + # The subdirectory where the sass source is kept. + def project_src_subdirectory + @project_src_subdirectory ||= options[:src_dir] || "src" + end + + # The subdirectory where the css output is kept. + def project_css_subdirectory + @project_css_subdirectory ||= options[:css_dir] || "stylesheets" + end + # The directory where the project source files are located. def project_src_directory - @project_src_directory ||= separate("#{project_directory}/src") + @project_src_directory ||= separate("#{project_directory}/#{project_src_subdirectory}") end end diff --git a/lib/compass/commands/watch_project.rb b/lib/compass/commands/watch_project.rb index 4fc5ed69..bd45f990 100644 --- a/lib/compass/commands/watch_project.rb +++ b/lib/compass/commands/watch_project.rb @@ -28,12 +28,12 @@ module Compass end end def most_recent_update_time - Dir.glob(separate("#{project_directory}/src/**/*.sass")).map {|sass_file| File.stat(sass_file).mtime}.max + Dir.glob(separate("#{project_src_directory}/**/*.sass")).map {|sass_file| File.stat(sass_file).mtime}.max end def should_update? t = most_recent_update_time if t > last_update_time - file = Dir.glob(separate("#{project_directory}/src/**/*.sass")).detect {|sass_file| File.stat(sass_file).mtime >= t} + file = Dir.glob(separate("#{project_src_directory}/**/*.sass")).detect {|sass_file| File.stat(sass_file).mtime >= t} [file, t] end end diff --git a/lib/compass/exec.rb b/lib/compass/exec.rb index 62d4a4cc..da78a0af 100644 --- a/lib/compass/exec.rb +++ b/lib/compass/exec.rb @@ -96,6 +96,14 @@ END self.options[:command] = :watch_project end + opts.on('--source SRC_DIR', "The source directory (where you keep your sass stylesheets).") do |src_dir| + self.options[:src_dir] = src_dir + end + + opts.on('--target CSS_DIR', "The target directory (where you keep your css stylesheets).") do |css_dir| + self.options[:css_dir] = css_dir + end + opts.on('-f FRAMEWORK', '--framework FRAMEWORK', [:compass, :blueprint], 'Set up a new project using the selected framework. Legal values: compass (default), blueprint') do |framework| self.options[:framework] = framework end