Skip to content
Snippets Groups Projects
Commit 98633e03 authored by Xu Cheng's avatar Xu Cheng
Browse files

add alias_table and alias_reverse_table for core and tap

parent 65488903
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -121,6 +121,29 @@ class Tap
@aliases ||= alias_files.map { |f| "#{name}/#{f.basename}" }
end
# a table mapping alias to formula name
# @private
def alias_table
return @alias_table if @alias_table
@alias_table = Hash.new
alias_files.each do |alias_file|
@alias_table["#{name}/#{alias_file.basename}"] = "#{name}/#{alias_file.resolved_path.basename(".rb")}"
end
@alias_table
end
# a table mapping formula name to aliases
# @private
def alias_reverse_table
return @alias_reverse_table if @alias_reverse_table
@alias_reverse_table = Hash.new
alias_table.each do |alias_name, formula_name|
@alias_reverse_table[formula_name] ||= []
@alias_reverse_table[formula_name] << alias_name
end
@alias_reverse_table
end
# an array of all commands files of this {Tap}.
def command_files
@command_files ||= Pathname.glob("#{path}/cmd/brew-*").select(&:executable?)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment