[Rails] Make it possible to only install the configuration files into a rails project.

This commit is contained in:
Chris Eppstein 2010-07-23 23:31:11 -07:00
parent 5864f2aeab
commit a2a0d58508
4 changed files with 20 additions and 16 deletions

View File

@ -19,19 +19,16 @@ module Compass
def write_configuration_files(config_file = nil) def write_configuration_files(config_file = nil)
config_file ||= targetize('config/compass.rb') config_file ||= targetize('config/compass.rb')
directory File.dirname(config_file) unless File.exists?(config_file)
write_file config_file, config_contents directory File.dirname(config_file)
write_file config_file, config_contents
end
directory File.dirname(targetize('config/initializers/compass.rb')) directory File.dirname(targetize('config/initializers/compass.rb'))
write_file targetize('config/initializers/compass.rb'), initializer_contents write_file targetize('config/initializers/compass.rb'), initializer_contents
end end
def config_files_exist?
File.exists?(targetize('config/compass.rb')) &&
File.exists?(targetize('config/initializers/compass.rb'))
end
def prepare def prepare
write_configuration_files unless config_files_exist? write_configuration_files
end end
def finalize(options = {}) def finalize(options = {})
@ -55,10 +52,12 @@ Sass will automatically compile your stylesheets during the next
page request and keep them up to date when they change. page request and keep them up to date when they change.
NEXTSTEPS NEXTSTEPS
end end
if manifest.has_stylesheet? unless options[:prepare]
puts "\nNext add these lines to the head of your layouts:\n\n" if manifest.has_stylesheet?
puts stylesheet_links puts "\nNext add these lines to the head of your layouts:\n\n"
puts "\n(You are using haml, aren't you?)" puts stylesheet_links
puts "\n(You are using haml, aren't you?)"
end
end end
end end

View File

@ -43,7 +43,12 @@ module Compass
self.options[:preferred_syntax] = syntax self.options[:preferred_syntax] = syntax
end end
opts.on("--prepare", "Prepare the project by only creating configuration files.") do
self.options[:prepare] = true
end
super super
end end
end end

View File

@ -74,7 +74,7 @@ Options:
installer.init installer.init
installer.run(:skip_finalization => true) installer.run(:skip_finalization => true)
UpdateProject.new(working_path, options).perform if installer.compilation_required? UpdateProject.new(working_path, options).perform if installer.compilation_required?
installer.finalize(:create => is_project_creation?) installer.finalize(options.merge(:create => is_project_creation?))
end end
def is_project_creation? def is_project_creation?

View File

@ -28,10 +28,10 @@ module Compass
# Runs the installer. # Runs the installer.
# Every installer must conform to the installation strategy of prepare, install, and then finalize. # Every installer must conform to the installation strategy of prepare, install, and then finalize.
# A default implementation is provided for each step. # A default implementation is provided for each step.
def run(options = {}) def run(run_options = {})
prepare prepare
install install unless options[:prepare]
finalize(options) unless options[:skip_finalization] finalize(options.merge(run_options)) unless options[:prepare] || run_options[:skip_finalization]
end end
# The default prepare method -- it is a no-op. # The default prepare method -- it is a no-op.