Use module_function in search.rb

This commit is contained in:
apainintheneck 2022-12-19 19:27:48 -08:00
parent 47b3f6fe6e
commit f41089fff4

View File

@ -9,7 +9,9 @@ module Homebrew
# #
# @api private # @api private
module Search module Search
def self.query_regexp(query) module_function
def query_regexp(query)
if (m = query.match(%r{^/(.*)/$})) if (m = query.match(%r{^/(.*)/$}))
Regexp.new(m[1]) Regexp.new(m[1])
else else
@ -19,7 +21,7 @@ module Homebrew
raise "#{query} is not a valid regex." raise "#{query} is not a valid regex."
end end
def self.search_descriptions(string_or_regex, args, search_type: :desc) def search_descriptions(string_or_regex, args, search_type: :desc)
both = !args.formula? && !args.cask? both = !args.formula? && !args.cask?
eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all? eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
@ -41,7 +43,7 @@ module Homebrew
end end
end end
def self.search_taps(query, silent: false) def search_taps(query, silent: false)
if query.match?(Regexp.union(HOMEBREW_TAP_FORMULA_REGEX, HOMEBREW_TAP_CASK_REGEX)) if query.match?(Regexp.union(HOMEBREW_TAP_FORMULA_REGEX, HOMEBREW_TAP_CASK_REGEX))
_, _, query = query.split("/", 3) _, _, query = query.split("/", 3)
end end
@ -86,7 +88,7 @@ module Homebrew
results results
end end
def self.search_formulae(string_or_regex) def search_formulae(string_or_regex)
if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_FORMULA_REGEX) if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_FORMULA_REGEX)
return begin return begin
[Formulary.factory(string_or_regex).name] [Formulary.factory(string_or_regex).name]
@ -122,7 +124,7 @@ module Homebrew
end.compact end.compact
end end
def self.search_casks(string_or_regex) def search_casks(string_or_regex)
if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX) if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX)
return begin return begin
[Cask::CaskLoader.load(string_or_regex).token] [Cask::CaskLoader.load(string_or_regex).token]
@ -151,7 +153,7 @@ module Homebrew
end.uniq end.uniq
end end
def self.search_names(query, string_or_regex, args) def search_names(query, string_or_regex, args)
both = !args.formula? && !args.cask? both = !args.formula? && !args.cask?
remote_results = search_taps(query, silent: true) remote_results = search_taps(query, silent: true)