diff --git a/lib/compass.rb b/lib/compass.rb index 952c0627..382f094b 100644 --- a/lib/compass.rb +++ b/lib/compass.rb @@ -1,7 +1,7 @@ module Compass end -%w(dependencies util browser_support sass_extensions core_ext version errors quick_cache).each do |lib| +%w(dependencies util browser_support sass_extensions version errors quick_cache).each do |lib| require "compass/#{lib}" end diff --git a/lib/compass/app_integration/rails/templates/compass-install-rails.rb b/lib/compass/app_integration/rails/templates/compass-install-rails.rb index 8bbc5593..aa2b8ce8 100644 --- a/lib/compass/app_integration/rails/templates/compass-install-rails.rb +++ b/lib/compass/app_integration/rails/templates/compass-install-rails.rb @@ -47,18 +47,18 @@ css_framework = ask("What CSS Framework install do you want to use with Compass? # sass storage prompt sass_dir = ask("Where would you like to keep your sass files within your project? (default: 'app/stylesheets')") -sass_dir = "app/stylesheets" if sass_dir.blank? +sass_dir = "app/stylesheets" if Compass::Util.blank?(sass_dir) # compiled css storage prompt css_dir = ask("Where would you like Compass to store your compiled css files? (default: 'public/stylesheets/compiled')") -css_dir = "public/stylesheets/compiled" if css_dir.blank? +css_dir = "public/stylesheets/compiled" if Compass::Util.blank?(css_dir) # use sudo for gem commands? use_sudo = nil if sudo_is_an_option? # dont give them the option if they are on a system that can't use sudo (aka windows) use_sudo = yes?("Use sudo for the gem commands? (the default for your system is #{sudo_is_an_option? ? 'yes' : 'no'})") end -use_sudo = sudo_is_an_option? if use_sudo.blank? +use_sudo = sudo_is_an_option? if Compass::Util.blank?(use_sudo) # define dependencies gem "haml", :version => ">=3.0.0" @@ -71,7 +71,7 @@ rake "gems:unpack GEM=compass --trace" # build out compass command compass_command = "compass init rails . --css-dir=#{css_dir} --sass-dir=#{sass_dir} " -compass_command << "--using #{css_framework} " unless css_framework.blank? +compass_command << "--using #{css_framework} " unless Compass::Util.blank?(css_framework) # integrate it! run "haml --rails ." diff --git a/lib/compass/core_ext.rb b/lib/compass/core_ext.rb deleted file mode 100644 index 09927e72..00000000 --- a/lib/compass/core_ext.rb +++ /dev/null @@ -1,14 +0,0 @@ -class String - unless method_defined?(:blank?) - # see if string has any content - def blank?; self.length.zero?; end - end -end - -class NilClass - unless method_defined?(:blank?) - def blank? - true - end - end -end diff --git a/lib/compass/util.rb b/lib/compass/util.rb index 516be5f9..4e75dd03 100644 --- a/lib/compass/util.rb +++ b/lib/compass/util.rb @@ -15,4 +15,15 @@ module Compass::Util send(WARN_METHOD, *args) end + def blank?(value) + case value + when NilClass, FalseClass + true + when String, Array + value.length.zero? + else + false + end + end + end diff --git a/test/test_case_helper.rb b/test/test_case_helper.rb index 3c4f95e0..9110ae5d 100644 --- a/test/test_case_helper.rb +++ b/test/test_case_helper.rb @@ -1,7 +1,7 @@ module Compass module TestCaseHelper def absolutize(path) - if path.blank? + if Compass::Util.blank?(path) File.dirname(__FILE__) elsif path[0] == ?/ "#{File.dirname(__FILE__)}#{path}"