aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula.rb
diff options
context:
space:
mode:
authorXu Cheng2015-10-07 17:54:20 +0800
committerXu Cheng2015-10-14 17:26:41 +0800
commit98633e03c62bdf9f658338f57895da788c9eb76c (patch)
tree170b32a16d940bcffeb9e8d41f46f0223a262b23 /Library/Homebrew/formula.rb
parent65488903f9a10a8b5bbf39a13eaf9a40a789ca5b (diff)
downloadbrew-98633e03c62bdf9f658338f57895da788c9eb76c.tar.bz2
add alias_table and alias_reverse_table for core and tap
Diffstat (limited to 'Library/Homebrew/formula.rb')
-rw-r--r--Library/Homebrew/formula.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index fb274533e..8f0e0e141 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -1052,6 +1052,29 @@ class Formula
@alias_full_names ||= core_aliases + tap_aliases
end
+ # a table mapping core alias to formula name
+ # @private
+ def self.core_alias_table
+ return @core_alias_table if @core_alias_table
+ @core_alias_table = Hash.new
+ core_alias_files.each do |alias_file|
+ @core_alias_table[alias_file.basename.to_s] = alias_file.resolved_path.basename(".rb").to_s
+ end
+ @core_alias_table
+ end
+
+ # a table mapping core formula name to aliases
+ # @private
+ def self.core_alias_reverse_table
+ return @core_alias_reverse_table if @core_alias_reverse_table
+ @core_alias_reverse_table = Hash.new
+ core_alias_table.each do |alias_name, formula_name|
+ @core_alias_reverse_table[formula_name] ||= []
+ @core_alias_reverse_table[formula_name] << alias_name
+ end
+ @core_alias_reverse_table
+ end
+
def self.[](name)
Formulary.factory(name)
end