From 92464c5f6abf60d50fcc6b4cf4d1fb5cb27e1bd1 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 27 Jul 2009 00:12:36 -0700 Subject: [PATCH] More flexible manifests that can see the installation options and might not even have any stylesheets or require a project configuration file. --- lib/compass/installers/base.rb | 2 +- lib/compass/installers/manifest.rb | 22 +++++++++++++++++++++- lib/compass/installers/rails.rb | 8 +++++--- lib/compass/installers/stand_alone.rb | 10 ++++++---- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index c3d32d24..c47d609c 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -14,7 +14,7 @@ module Compass @target_path = target_path @working_path = Dir.getwd @options = options - @manifest = Manifest.new(manifest_file) if template_path + @manifest = Manifest.new(manifest_file, options) if template_path self.logger = options[:logger] end diff --git a/lib/compass/installers/manifest.rb b/lib/compass/installers/manifest.rb index 7c780f40..0f1978f5 100644 --- a/lib/compass/installers/manifest.rb +++ b/lib/compass/installers/manifest.rb @@ -11,8 +11,12 @@ module Compass end end - def initialize(manifest_file = nil) + attr_reader :options + def initialize(manifest_file = nil, options = {}) @entries = [] + @options = options + @generate_config = true + @compile_after_generation = true parse(manifest_file) if manifest_file end @@ -41,8 +45,24 @@ module Compass @entries.each {|e| yield e} end + def generate_config? + @generate_config + end + + def compile? + @compile_after_generation + end protected + + def no_configuration_file! + @generate_config = false + end + + def skip_compilation! + @compile_after_generation = false + end + # parses a manifest file which is a ruby script # evaluated in a Manifest instance context def parse(manifest_file) diff --git a/lib/compass/installers/rails.rb b/lib/compass/installers/rails.rb index cce33d9e..9be2a44d 100644 --- a/lib/compass/installers/rails.rb +++ b/lib/compass/installers/rails.rb @@ -62,9 +62,11 @@ page request and keep them up to date when they change. Make sure you restart your server! NEXTSTEPS end - puts "\nNext add these lines to the head of your layouts:\n\n" - puts stylesheet_links - puts "\n(You are using haml, aren't you?)" + if manifest.has_stylesheet? + puts "\nNext add these lines to the head of your layouts:\n\n" + puts stylesheet_links + puts "\n(You are using haml, aren't you?)" + end end diff --git a/lib/compass/installers/stand_alone.rb b/lib/compass/installers/stand_alone.rb index 053670b3..a0113a66 100644 --- a/lib/compass/installers/stand_alone.rb +++ b/lib/compass/installers/stand_alone.rb @@ -43,7 +43,7 @@ module Compass end def prepare - write_configuration_files unless config_files_exist? + write_configuration_files unless config_files_exist? || !@manifest.generate_config? end def default_configuration @@ -69,12 +69,14 @@ This can be done in one of the following ways: compass --watch [path/to/project] NEXTSTEPS end - puts "\nTo import your new stylesheets add the following lines of HTML (or equivalent) to your webpage:" - puts stylesheet_links + if manifest.has_stylesheet? + puts "\nTo import your new stylesheets add the following lines of HTML (or equivalent) to your webpage:" + puts stylesheet_links + end end def compilation_required? - true + @manifest.compile? end end end