aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2012-11-05 18:08:52 -0600
committerJack Nagel2012-11-06 12:32:09 -0600
commitf8183d9510594c4fac3d2f4d8d7912e680628349 (patch)
treecb6cb1196efcba082f1b84d236f4545b58ea6856
parentc92971f475272109153889b6ada0ed0603eb60d4 (diff)
downloadbrew-f8183d9510594c4fac3d2f4d8d7912e680628349.tar.bz2
Hoist top-level directory list into a constant
-rw-r--r--Library/Homebrew/cmd/doctor.rb4
-rw-r--r--Library/Homebrew/cmd/prune.rb2
-rw-r--r--Library/Homebrew/keg.rb4
3 files changed, 6 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 2134de3d3..6f7b3a98b 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -187,9 +187,9 @@ def check_for_other_package_managers
end
def check_for_broken_symlinks
+ require 'keg'
broken_symlinks = []
- %w[lib include sbin bin etc share].each do |d|
- d = HOMEBREW_PREFIX/d
+ Keg::PRUNEABLE_DIRECTORIES.map { |d| HOMEBREW_PREFIX/d }.each do |d|
next unless d.directory?
d.find do |pn|
broken_symlinks << pn if pn.symlink? and pn.readlink.expand_path.to_s =~ /^#{HOMEBREW_PREFIX}/ and not pn.exist?
diff --git a/Library/Homebrew/cmd/prune.rb b/Library/Homebrew/cmd/prune.rb
index 75e6026df..394b8ad7f 100644
--- a/Library/Homebrew/cmd/prune.rb
+++ b/Library/Homebrew/cmd/prune.rb
@@ -9,7 +9,7 @@ module Homebrew extend self
$d = 0
dirs = []
- %w[bin sbin etc lib include share Library/LinkedKegs].map{ |d| HOMEBREW_PREFIX+d }.each do |path|
+ Keg::PRUNEABLE_DIRECTORIES.map{ |d| HOMEBREW_PREFIX/d }.each do |path|
next unless path.directory?
path.find do |path|
path.extend ObserverPathnameExtension
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index ba394266c..8bd779eca 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -10,6 +10,8 @@ class Keg < Pathname
# locale-specific directories have the form language[_territory][.codeset][@modifier]
LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/
INFOFILE_RX = %r[info/([^.].*?\.info|dir)$]
+ TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var]
+ PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Library/LinkedKegs]
# if path is a file in a keg then this will return the containing Keg object
def self.for path
@@ -31,7 +33,7 @@ class Keg < Pathname
# of files and directories linked
$n=$d=0
- %w[bin etc lib include sbin share var].map{ |d| self/d }.each do |src|
+ TOP_LEVEL_DIRECTORIES.map{ |d| self/d }.each do |src|
next unless src.exist?
src.find do |src|
next if src == self