Don't extend core classes.

This commit is contained in:
Chris Eppstein 2011-03-21 09:21:36 -07:00
parent e475637682
commit cca6474ba2
5 changed files with 17 additions and 20 deletions

View File

@ -1,7 +1,7 @@
module Compass module Compass
end 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}" require "compass/#{lib}"
end end

View File

@ -47,18 +47,18 @@ css_framework = ask("What CSS Framework install do you want to use with Compass?
# sass storage prompt # sass storage prompt
sass_dir = ask("Where would you like to keep your sass files within your project? (default: 'app/stylesheets')") 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 # compiled css storage prompt
css_dir = ask("Where would you like Compass to store your compiled css files? (default: 'public/stylesheets/compiled')") 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 for gem commands?
use_sudo = nil 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) 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'})") use_sudo = yes?("Use sudo for the gem commands? (the default for your system is #{sudo_is_an_option? ? 'yes' : 'no'})")
end 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 # define dependencies
gem "haml", :version => ">=3.0.0" gem "haml", :version => ">=3.0.0"
@ -71,7 +71,7 @@ rake "gems:unpack GEM=compass --trace"
# build out compass command # build out compass command
compass_command = "compass init rails . --css-dir=#{css_dir} --sass-dir=#{sass_dir} " 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! # integrate it!
run "haml --rails ." run "haml --rails ."

View File

@ -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

View File

@ -15,4 +15,15 @@ module Compass::Util
send(WARN_METHOD, *args) send(WARN_METHOD, *args)
end end
def blank?(value)
case value
when NilClass, FalseClass
true
when String, Array
value.length.zero?
else
false
end
end
end end

View File

@ -1,7 +1,7 @@
module Compass module Compass
module TestCaseHelper module TestCaseHelper
def absolutize(path) def absolutize(path)
if path.blank? if Compass::Util.blank?(path)
File.dirname(__FILE__) File.dirname(__FILE__)
elsif path[0] == ?/ elsif path[0] == ?/
"#{File.dirname(__FILE__)}#{path}" "#{File.dirname(__FILE__)}#{path}"