From 118b41bfcdb13a4fec8da48e35de162ac62fe65c Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 31 Jul 2009 02:51:17 +0100 Subject: Refactor $foo into HOMEBREW_FOO CONSTANTS are the far saner choice for these important parameters. Split env up so I can redefine the CONSTANTS in unittest.rb. --- bin/brew | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/brew b/bin/brew index 0797422ae..bb89d3712 100755 --- a/bin/brew +++ b/bin/brew @@ -1,8 +1,7 @@ #!/usr/bin/ruby -require 'find' -require 'pathname' -$:.unshift Pathname.new(__FILE__).dirname.parent.realpath+'Library'+'Homebrew' +$:.unshift __FILE__+'/../../Library/Homebrew' require 'env' +require 'find' # often causes Ruby to throw exception ffs Dir.chdir '/' unless File.directory? ENV['PWD'] @@ -11,9 +10,9 @@ Dir.chdir '/' unless File.directory? ENV['PWD'] def prune n=0 dirs=Array.new - $root.find do |path| + HOMEBREW_PREFIX.find do |path| if path.directory? - name=path.relative_path_from($root).to_s + name=path.relative_path_from(HOMEBREW_PREFIX).to_s if name == '.git' or name == 'Cellar' or name == 'Library' Find.prune else @@ -60,7 +59,7 @@ def extract_kegs end def abv keg=nil - path=keg ? keg.path : $cellar + path=keg ? keg.path : HOMEBREW_CELLAR if path.directory? `find #{path} -type f | wc -l`.strip+' files, '+`du -hd0 #{path} | cut -d"\t" -f1`.strip else @@ -203,7 +202,8 @@ begin when 'edit' if ARGV.empty? - exec "mate #{$formula} #{$root}/Library/Homebrew #{$root}/bin/brew #{$root}/README" + r=HOMEBREW_PREFIX + exec "mate #{r}/Library/Formula #{r}/Library/Homebrew #{r}/bin/brew #{r}/README" else require 'formula' paths=extract_named_args.collect {|name| Formula.path(name).to_s.gsub ' ', '\\ '} @@ -258,7 +258,7 @@ begin when 'info', 'abv' if ARGV.empty? - puts `ls #{$cellar} | wc -l`.strip+" kegs, "+abv + puts `ls #{HOMEBREW_CELLAR} | wc -l`.strip+" kegs, "+abv elsif ARGV[0][0..6] == 'http://' puts Pathname.new(ARGV.shift).version else @@ -292,4 +292,4 @@ rescue StandardError, Interrupt => e else raise end -end \ No newline at end of file +end -- cgit v1.2.3