Allow the project source and target directories to be different by specifying --source and --target to any of the command line commands.
This commit is contained in:
parent
c36e539990
commit
9631a403e3
@ -17,11 +17,13 @@ module Compass
|
|||||||
# all commands must implement perform
|
# all commands must implement perform
|
||||||
def perform
|
def perform
|
||||||
directory nil, options
|
directory nil, options
|
||||||
directory 'stylesheets', options.merge(:force => true)
|
src_dir = options[:src_dir] || "src"
|
||||||
directory 'src', options.merge(:force => true)
|
css_dir = options[:css_dir] || "stylesheets"
|
||||||
template 'project/screen.sass', 'src/screen.sass', options
|
directory src_dir, options.merge(:force => true)
|
||||||
template 'project/print.sass', 'src/print.sass', options
|
directory css_dir, options.merge(:force => true)
|
||||||
template 'project/ie.sass', 'src/ie.sass', options
|
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
|
UpdateProject.new(working_directory, options).perform
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ module Compass
|
|||||||
Base::ACTIONS << :compile
|
Base::ACTIONS << :compile
|
||||||
Base::ACTIONS << :overwrite
|
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 = {})
|
def initialize(working_directory, options = {})
|
||||||
super(working_directory, options)
|
super(working_directory, options)
|
||||||
@ -36,9 +36,9 @@ module Compass
|
|||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Dir.glob(separate("#{project_directory}/src/**/[^_]*.sass")).each do |sass_file|
|
Dir.glob(separate("#{project_src_directory}/**/[^_]*.sass")).each do |sass_file|
|
||||||
stylesheet_name = sass_file[("#{project_directory}/src/".length)..-6]
|
stylesheet_name = sass_file[("#{project_src_directory}/".length)..-6]
|
||||||
compile "src/#{stylesheet_name}.sass", "stylesheets/#{stylesheet_name}.css", options
|
compile "#{project_src_subdirectory}/#{stylesheet_name}.sass", "#{project_css_subdirectory}/#{stylesheet_name}.css", options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,9 +81,19 @@ module Compass
|
|||||||
@sass_load_paths ||= [project_src_directory] + Compass::Frameworks::ALL.map{|f| f.stylesheets_directory}
|
@sass_load_paths ||= [project_src_directory] + Compass::Frameworks::ALL.map{|f| f.stylesheets_directory}
|
||||||
end
|
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.
|
# The directory where the project source files are located.
|
||||||
def project_src_directory
|
def project_src_directory
|
||||||
@project_src_directory ||= separate("#{project_directory}/src")
|
@project_src_directory ||= separate("#{project_directory}/#{project_src_subdirectory}")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -28,12 +28,12 @@ module Compass
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def most_recent_update_time
|
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
|
end
|
||||||
def should_update?
|
def should_update?
|
||||||
t = most_recent_update_time
|
t = most_recent_update_time
|
||||||
if t > last_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]
|
[file, t]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -96,6 +96,14 @@ END
|
|||||||
self.options[:command] = :watch_project
|
self.options[:command] = :watch_project
|
||||||
end
|
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|
|
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
|
self.options[:framework] = framework
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user