In rails 3, there's no need for an initializer. Instead we use a
Railstie. Additionally, we now default to app/stylesheets for sass files and public/stylesheets for css files -- though they can still be changed after installation or on the command line during project initialization. Compass is now a gem plugin in a rails environment. Lastly, in a rails3 environment the compass configuration can now be changed without restarting the rails server process.
This commit is contained in:
parent
f44e1ea492
commit
52c47d7de4
17
lib/compass/app_integration/rails/actionpack3/railtie.rb
Normal file
17
lib/compass/app_integration/rails/actionpack3/railtie.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
require 'compass'
|
||||||
|
require 'rails'
|
||||||
|
module Compass
|
||||||
|
class Railtie < Rails::Railtie
|
||||||
|
config.to_prepare do
|
||||||
|
# putting this here allows compass to detect
|
||||||
|
# and adjust to changes to the project configuration
|
||||||
|
Compass.reset_configuration!
|
||||||
|
Compass::AppIntegration::Rails.initialize!
|
||||||
|
end
|
||||||
|
|
||||||
|
# Might need to do this...
|
||||||
|
# initializer "compass/railtie.configure_rails_initialization" do |app|
|
||||||
|
# puts "Initializing compass"
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
@ -23,8 +23,10 @@ module Compass
|
|||||||
directory File.dirname(config_file)
|
directory File.dirname(config_file)
|
||||||
write_file config_file, config_contents
|
write_file config_file, config_contents
|
||||||
end
|
end
|
||||||
directory File.dirname(targetize('config/initializers/compass.rb'))
|
unless rails3?
|
||||||
write_file targetize('config/initializers/compass.rb'), initializer_contents
|
directory File.dirname(targetize('config/initializers/compass.rb'))
|
||||||
|
write_file targetize('config/initializers/compass.rb'), initializer_contents
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def rails3?
|
def rails3?
|
||||||
@ -73,26 +75,34 @@ NEXTSTEPS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prompt_sass_dir
|
def prompt_sass_dir
|
||||||
recommended_location = separate('app/stylesheets')
|
if rails3?
|
||||||
default_location = separate('public/stylesheets/sass')
|
nil
|
||||||
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
|
else
|
||||||
instead of the Sass default location of #{default_location}.
|
recommended_location = separate('app/stylesheets')
|
||||||
Is this OK? (Y/n) }
|
default_location = separate('public/stylesheets/sass')
|
||||||
answer = $stdin.gets.downcase[0]
|
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
|
||||||
answer == ?n ? default_location : recommended_location
|
instead of the Sass default location of #{default_location}.
|
||||||
|
Is this OK? (Y/n) }
|
||||||
|
answer = $stdin.gets.downcase[0]
|
||||||
|
answer == ?n ? default_location : recommended_location
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prompt_css_dir
|
def prompt_css_dir
|
||||||
recommended_location = separate("public/stylesheets/compiled")
|
if rails3?
|
||||||
default_location = separate("public/stylesheets")
|
nil
|
||||||
puts
|
else
|
||||||
print %Q{Compass recommends that you keep your compiled css in #{recommended_location}/
|
recommended_location = separate("public/stylesheets/compiled")
|
||||||
instead the Sass default of #{default_location}/.
|
default_location = separate("public/stylesheets")
|
||||||
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
|
puts
|
||||||
Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
|
print %Q{Compass recommends that you keep your compiled css in #{recommended_location}/
|
||||||
answer = $stdin.gets
|
instead the Sass default of #{default_location}/.
|
||||||
answer = answer.downcase[0]
|
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
|
||||||
answer == ?n ? default_location : recommended_location
|
Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
|
||||||
|
answer = $stdin.gets
|
||||||
|
answer = answer.downcase[0]
|
||||||
|
answer == ?n ? default_location : recommended_location
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def config_contents
|
def config_contents
|
||||||
|
@ -4,6 +4,9 @@ unless defined?(Compass::RAILS_LOADED)
|
|||||||
require 'action_pack/version'
|
require 'action_pack/version'
|
||||||
if ActionPack::VERSION::MAJOR >= 3
|
if ActionPack::VERSION::MAJOR >= 3
|
||||||
# TODO figure something out so image_path works with rails integration
|
# TODO figure something out so image_path works with rails integration
|
||||||
|
%w(railtie).each do |lib|
|
||||||
|
require "compass/app_integration/rails/actionpack3/#{lib}"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
%w(action_controller sass_plugin urls).each do |lib|
|
%w(action_controller sass_plugin urls).each do |lib|
|
||||||
require "compass/app_integration/rails/actionpack2/#{lib}"
|
require "compass/app_integration/rails/actionpack2/#{lib}"
|
||||||
|
2
lib/rails/init.rb
Normal file
2
lib/rails/init.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require 'compass'
|
||||||
|
require 'compass/app_integration/rails'
|
Loading…
Reference in New Issue
Block a user