Merge pull request #16808 from reitermarkus/tap-sig-alias-table
Simplify `Tap#alias_table`.
This commit is contained in:
commit
a86094d794
@ -150,8 +150,6 @@ class Tap
|
|||||||
@full_name = "#{@user}/homebrew-#{@repo}"
|
@full_name = "#{@user}/homebrew-#{@repo}"
|
||||||
@path = TAP_DIRECTORY/@full_name.downcase
|
@path = TAP_DIRECTORY/@full_name.downcase
|
||||||
@git_repo = GitRepository.new(@path)
|
@git_repo = GitRepository.new(@path)
|
||||||
@alias_table = nil
|
|
||||||
@alias_reverse_table = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Clear internal cache.
|
# Clear internal cache.
|
||||||
@ -715,30 +713,25 @@ class Tap
|
|||||||
@aliases ||= alias_table.keys
|
@aliases ||= alias_table.keys
|
||||||
end
|
end
|
||||||
|
|
||||||
# a table mapping alias to formula name
|
# Mapping from aliases to formula names.
|
||||||
|
#
|
||||||
# @private
|
# @private
|
||||||
sig { returns(T::Hash[String, String]) }
|
sig { returns(T::Hash[String, String]) }
|
||||||
def alias_table
|
def alias_table
|
||||||
return @alias_table if @alias_table
|
@alias_table ||= alias_files.each_with_object({}) do |alias_file, alias_table|
|
||||||
|
alias_table[alias_file_to_name(alias_file)] = formula_file_to_name(alias_file.resolved_path)
|
||||||
@alias_table = {}
|
|
||||||
alias_files.each do |alias_file|
|
|
||||||
@alias_table[alias_file_to_name(alias_file)] = formula_file_to_name(alias_file.resolved_path)
|
|
||||||
end
|
end
|
||||||
@alias_table
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# a table mapping formula name to aliases
|
# Mapping from formula names to aliases.
|
||||||
|
#
|
||||||
# @private
|
# @private
|
||||||
|
sig { returns(T::Hash[String, T::Array[String]]) }
|
||||||
def alias_reverse_table
|
def alias_reverse_table
|
||||||
return @alias_reverse_table if @alias_reverse_table
|
@alias_reverse_table ||= alias_table.each_with_object({}) do |(alias_name, formula_name), alias_reverse_table|
|
||||||
|
alias_reverse_table[formula_name] ||= []
|
||||||
@alias_reverse_table = {}
|
alias_reverse_table[formula_name] << alias_name
|
||||||
alias_table.each do |alias_name, formula_name|
|
|
||||||
@alias_reverse_table[formula_name] ||= []
|
|
||||||
@alias_reverse_table[formula_name] << alias_name
|
|
||||||
end
|
end
|
||||||
@alias_reverse_table
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user