aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-04-05 22:03:34 -0500
committerJack Nagel2014-04-05 22:03:40 -0500
commit0d90deac27b06642c3c71cc0ccf03304ec556b16 (patch)
tree40c5b910a5c4ad132ebfc0f3d55350c4eadcfc13 /Library
parentcaaa32325cf7bcf03d07f7525da082f53217cceb (diff)
downloadbrew-0d90deac27b06642c3c71cc0ccf03304ec556b16.tar.bz2
Extract alias resolution to a separate loader class
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formulary.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index ff1dcce38..75051b9f0 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -110,6 +110,14 @@ class Formulary
end
end
+ class AliasLoader < FormulaLoader
+ def initialize alias_path
+ path = alias_path.resolved_path
+ name = path.basename(".rb").to_s
+ super name, path
+ end
+ end
+
# Loads formulae from disk using a path
class FromPathLoader < FormulaLoader
def initialize path
@@ -192,12 +200,9 @@ class Formulary
return StandardLoader.new(ref, formula_with_that_name)
end
- # test if the name is a formula alias
possible_alias = Pathname.new("#{HOMEBREW_LIBRARY}/Aliases/#{ref}")
if possible_alias.file?
- path = possible_alias.resolved_path
- name = path.basename(".rb").to_s
- return StandardLoader.new(name, path)
+ return AliasLoader.new(possible_alias)
end
possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{ref}.rb")