aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2012-07-05 20:29:31 -0500
committerJack Nagel2012-07-05 20:32:55 -0500
commit9a72fecf84a0860ae4fc8bb3d7e663a5c1c9c07d (patch)
tree30928d7adb77cdeede10046223a2c43f4224e898 /Library
parentbb78df7356533502597a7bbacb529a3d7de71e7a (diff)
downloadbrew-9a72fecf84a0860ae4fc8bb3d7e663a5c1c9c07d.tar.bz2
Decouple pathname from bottles
Pathname is one of the basic building block classes in Homebrew, and as such it is preferrable that `require`ing it does not drag in other Homebrew code; thus avoiding circular dependency situations. Its dependency on bottles.rb gave it an implicit dependency on formula.rb, among other things. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/bottles.rb4
-rw-r--r--Library/Homebrew/extend/pathname.rb10
2 files changed, 9 insertions, 5 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index 12679e229..ad74c6710 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -56,11 +56,11 @@ def bottle_native_regex
end
def bottle_regex
- /(\.[a-z]+\.bottle\.(\d+\.)?tar\.gz)$/
+ Pathname::BOTTLE_EXTNAME_RX
end
def old_bottle_regex
- /((\.[a-z]+)?[\.-]bottle\.tar\.gz)$/
+ Pathname::OLD_BOTTLE_EXTNAME_RX
end
def bottle_base_url
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 5edd8b664..600e114a6 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -1,11 +1,13 @@
require 'pathname'
-require 'bottles'
require 'mach'
# we enhance pathname to make our code more readable
class Pathname
include MachO
+ BOTTLE_EXTNAME_RX = /(\.[a-z]+\.bottle\.(\d+\.)?tar\.gz)$/
+ OLD_BOTTLE_EXTNAME_RX = /((\.[a-z]+)?[\.-]bottle\.tar\.gz)$/
+
def install *sources
results = []
sources.each do |src|
@@ -122,8 +124,10 @@ class Pathname
# extended to support common double extensions
alias extname_old extname
def extname
- return $1 if to_s =~ bottle_regex
- return $1 if to_s =~ old_bottle_regex
+ BOTTLE_EXTNAME_RX.match to_s
+ return $1 if $1
+ OLD_BOTTLE_EXTNAME_RX.match to_s
+ return $1 if $1
/(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s
return $1 if $1
return File.extname(to_s)