diff options
| author | Adam Vandenberg | 2013-06-23 13:51:57 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2013-06-23 18:42:18 -0700 |
| commit | 66fc5fa48a2a00a90b1ba147207606cf1c6f5221 (patch) | |
| tree | 4eb29ac661e9dfb0a215e4d8b46b5a9785858a3b /Library | |
| parent | 8777901cf013864d2acf5e3117dacbb6b68674c5 (diff) | |
| download | brew-66fc5fa48a2a00a90b1ba147207606cf1c6f5221.tar.bz2 | |
document canonical name and move vars down to usage
Closes Homebrew/homebrew#20719.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 6f642ce90..e8d045ff5 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -357,10 +357,7 @@ class Formula def self.canonical_name name name = name.to_s if name.kind_of? Pathname - formula_with_that_name = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Formula/#{name}.rb") - possible_alias = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Aliases/#{name}") - possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{name}.rb") - + # if name includes a '/', it may be a tap reference, path, or URL if name.include? "/" if name =~ %r{(.+)/(.+)/(.+)} tap_name = "#$1-#$2".downcase @@ -370,16 +367,29 @@ class Formula end if tapd.directory? end # Otherwise 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 - elsif possible_cached_formula.file? - possible_cached_formula.to_s - else - name + return name + end + + # test if the name is a core formula + formula_with_that_name = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Formula/#{name}.rb") + if formula_with_that_name.file? and formula_with_that_name.readable? + return name end + + # test if the name is a formula alias + possible_alias = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Aliases/#{name}") + if possible_alias.file? + return possible_alias.realpath.basename('.rb').to_s + end + + # test if the name is a cached downloaded formula + possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{name}.rb") + if possible_cached_formula.file? + return possible_cached_formula.to_s + end + + # dunno, pass through the name + return name end def self.factory name |
