From f44e1ea492cadee05cfa098b329b4de357316e62 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 28 Aug 2010 21:54:40 -0700 Subject: [PATCH] Detect the version of rails and print out instructions accordingly. --- .../app_integration/rails/installer.rb | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/compass/app_integration/rails/installer.rb b/lib/compass/app_integration/rails/installer.rb index 2c6682a1..d6296279 100644 --- a/lib/compass/app_integration/rails/installer.rb +++ b/lib/compass/app_integration/rails/installer.rb @@ -27,24 +27,30 @@ module Compass write_file targetize('config/initializers/compass.rb'), initializer_contents end + def rails3? + File.exists?(targetize('config/application.rb')) + end + def prepare write_configuration_files end + def gem_config_instructions + if rails3? + %Q{Add the following to your Gemfile:\n\n gem "compass", ">= #{Compass::VERSION}"} + else + %Q{Add the following to your evironment.rb:\n\n config.gem "compass", :version => ">= #{Compass::VERSION}"} + end + end + def finalize(options = {}) if options[:create] puts <<-NEXTSTEPS Congratulations! Your rails project has been configured to use Compass. -Just one more thing left to do: Register the compass gem. +Just one more thing left to do if you haven't yet: Register the compass gem. -In Rails 2.2 & 2.3, add the following to your evironment.rb: - - config.gem "compass", :version => ">= #{Compass::VERSION}" - -In Rails 3, add the following to your Gemfile: - - gem "compass", ">= #{Compass::VERSION}" +#{gem_config_instructions} Then, make sure you restart your server.