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>
This commit is contained in:
parent
bb78df7356
commit
9a72fecf84
@ -56,11 +56,11 @@ def bottle_native_regex
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bottle_regex
|
def bottle_regex
|
||||||
/(\.[a-z]+\.bottle\.(\d+\.)?tar\.gz)$/
|
Pathname::BOTTLE_EXTNAME_RX
|
||||||
end
|
end
|
||||||
|
|
||||||
def old_bottle_regex
|
def old_bottle_regex
|
||||||
/((\.[a-z]+)?[\.-]bottle\.tar\.gz)$/
|
Pathname::OLD_BOTTLE_EXTNAME_RX
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_base_url
|
def bottle_base_url
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'bottles'
|
|
||||||
require 'mach'
|
require 'mach'
|
||||||
|
|
||||||
# we enhance pathname to make our code more readable
|
# we enhance pathname to make our code more readable
|
||||||
class Pathname
|
class Pathname
|
||||||
include MachO
|
include MachO
|
||||||
|
|
||||||
|
BOTTLE_EXTNAME_RX = /(\.[a-z]+\.bottle\.(\d+\.)?tar\.gz)$/
|
||||||
|
OLD_BOTTLE_EXTNAME_RX = /((\.[a-z]+)?[\.-]bottle\.tar\.gz)$/
|
||||||
|
|
||||||
def install *sources
|
def install *sources
|
||||||
results = []
|
results = []
|
||||||
sources.each do |src|
|
sources.each do |src|
|
||||||
@ -122,8 +124,10 @@ class Pathname
|
|||||||
# extended to support common double extensions
|
# extended to support common double extensions
|
||||||
alias extname_old extname
|
alias extname_old extname
|
||||||
def extname
|
def extname
|
||||||
return $1 if to_s =~ bottle_regex
|
BOTTLE_EXTNAME_RX.match to_s
|
||||||
return $1 if to_s =~ old_bottle_regex
|
return $1 if $1
|
||||||
|
OLD_BOTTLE_EXTNAME_RX.match to_s
|
||||||
|
return $1 if $1
|
||||||
/(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s
|
/(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s
|
||||||
return $1 if $1
|
return $1 if $1
|
||||||
return File.extname(to_s)
|
return File.extname(to_s)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user