Formula.resolve_alias to compatability.rb
This commit is contained in:
parent
c1a3b724fd
commit
55bd25ff4c
@ -45,3 +45,20 @@ def search_brews text
|
||||
require 'cmd/search'
|
||||
Homebrew.search_brews text
|
||||
end
|
||||
|
||||
class Formula
|
||||
# in compatability because the naming is somewhat confusing
|
||||
def self.resolve_alias name
|
||||
opoo 'Formula.resolve_alias is deprecated and will eventually be removed'
|
||||
|
||||
# Don't resolve paths or URLs
|
||||
return name if name.include?("/")
|
||||
|
||||
aka = HOMEBREW_REPOSITORY/:Library/:Aliases/name
|
||||
if aka.file?
|
||||
aka.realpath.basename('.rb').to_s
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -9,7 +9,7 @@ module HomebrewArgvExtension
|
||||
|
||||
def formulae
|
||||
require 'formula'
|
||||
@formulae ||= downcased_unique_named.map{ |name| Formula.factory(Formula.resolve_alias(name)) }
|
||||
@formulae ||= downcased_unique_named.map{ |name| Formula.factory name }
|
||||
raise FormulaUnspecifiedError if @formulae.empty?
|
||||
@formulae
|
||||
end
|
||||
@ -18,7 +18,7 @@ module HomebrewArgvExtension
|
||||
require 'keg'
|
||||
require 'formula'
|
||||
@kegs ||= downcased_unique_named.collect do |name|
|
||||
d = HOMEBREW_CELLAR/Formula.resolve_alias(name)
|
||||
d = HOMEBREW_CELLAR/Formula.caniconical_name(name)
|
||||
dirs = d.children.select{ |pn| pn.directory? } rescue []
|
||||
raise NoSuchKegError.new(name) if not d.directory? or dirs.length == 0
|
||||
raise MultipleVersionsInstalledError.new(name) if dirs.length > 1
|
||||
|
||||
@ -298,13 +298,16 @@ class Formula
|
||||
Dir["#{HOMEBREW_REPOSITORY}/Library/Aliases/*"].map{ |f| File.basename f }.sort
|
||||
end
|
||||
|
||||
def self.resolve_alias name
|
||||
# Don't resolve paths or URLs
|
||||
return name if name.include?("/")
|
||||
|
||||
aka = HOMEBREW_REPOSITORY+"Library/Aliases/#{name}"
|
||||
if aka.file?
|
||||
aka.realpath.basename('.rb').to_s
|
||||
def self.caniconical_name name
|
||||
formula_with_that_name = HOMEBREW_REPOSITORY/"Library/Formula/#{name}.rb"
|
||||
possible_alias = HOMEBREW_REPOSITORY/"Library/Aliases"/name
|
||||
if name.include? "/"
|
||||
# Don't resolve paths or URLs
|
||||
name
|
||||
elsif formula_with_that_name.file? and formula_with_that_name.readable?
|
||||
name
|
||||
elsif possible_alias.file?
|
||||
possible_alias.realpath.basename('.rb').to_s
|
||||
else
|
||||
name
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user