From 2a9d9bf4fb9eddca87396477dd9ea93ec5d3b985 Mon Sep 17 00:00:00 2001 From: Thomas McDonald Date: Fri, 11 May 2012 14:39:47 +0100 Subject: [PATCH] Register the rails engine when using Rails w/Compass This means that the javascripts will still be available through the asset pipeline. --- lib/bootstrap-sass.rb | 15 ++++++++++----- ...compass_extensions.rb => compass_functions.rb} | 0 .../{rails_extentions.rb => rails_functions.rb} | 0 test/test_helper.rb | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) rename lib/bootstrap-sass/{compass_extensions.rb => compass_functions.rb} (100%) rename lib/bootstrap-sass/{rails_extentions.rb => rails_functions.rb} (100%) diff --git a/lib/bootstrap-sass.rb b/lib/bootstrap-sass.rb index 485c4c8d..d6bea4f6 100644 --- a/lib/bootstrap-sass.rb +++ b/lib/bootstrap-sass.rb @@ -5,14 +5,15 @@ module Bootstrap def self.load! if compass? && asset_pipeline? register_compass_extension + register_rails_engine elsif compass? # Only require compass extension if a standalone project - require 'bootstrap-sass/compass_extensions' + require 'bootstrap-sass/compass_functions' register_compass_extension elsif asset_pipeline? require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4 - require 'bootstrap-sass/engine' - require 'bootstrap-sass/rails_extentions' + register_rails_engine + require 'bootstrap-sass/rails_functions' else raise Bootstrap::FrameworkNotFound, "bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded" end @@ -23,6 +24,10 @@ module Bootstrap defined?(::Rails) && ::Rails.version >= '3.1.0' end + def self.compass? + defined?(::Compass) + end + def self.register_compass_extension base = File.join(File.dirname(__FILE__), '..') styles = File.join(base, 'vendor', 'assets', 'stylesheets') @@ -30,8 +35,8 @@ module Bootstrap ::Compass::Frameworks.register('bootstrap', :stylesheets_directory => styles, :templates_directory => templates) end - def self.compass? - defined?(::Compass) + def self.register_rails_engine + require 'bootstrap-sass/engine' end end diff --git a/lib/bootstrap-sass/compass_extensions.rb b/lib/bootstrap-sass/compass_functions.rb similarity index 100% rename from lib/bootstrap-sass/compass_extensions.rb rename to lib/bootstrap-sass/compass_functions.rb diff --git a/lib/bootstrap-sass/rails_extentions.rb b/lib/bootstrap-sass/rails_functions.rb similarity index 100% rename from lib/bootstrap-sass/rails_extentions.rb rename to lib/bootstrap-sass/rails_functions.rb diff --git a/test/test_helper.rb b/test/test_helper.rb index caff7e14..021d0d6a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,5 +3,5 @@ $:.unshift("#{File.dirname(__FILE__)}/..") require 'test/unit' require 'sass' -require 'lib/bootstrap-sass/compass_extensions' -require 'lib/bootstrap-sass/rails_extentions' \ No newline at end of file +require 'lib/bootstrap-sass/compass_functions' +require 'lib/bootstrap-sass/rails_functions' \ No newline at end of file