Fix DescriptionCacheStore searching
This commit is contained in:
parent
cb5e8298a2
commit
de90ddf07c
@ -82,8 +82,6 @@ class DescriptionCacheStore < CacheStore
|
|||||||
end
|
end
|
||||||
alias delete_from_cask_tokens! delete_from_formula_names!
|
alias delete_from_cask_tokens! delete_from_formula_names!
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# `select` from the underlying database.
|
# `select` from the underlying database.
|
||||||
def select(&block)
|
def select(&block)
|
||||||
database.select(&block)
|
database.select(&block)
|
||||||
|
@ -170,12 +170,12 @@ module Homebrew
|
|||||||
[all_formulae, all_casks]
|
[all_formulae, all_casks]
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(array, string_or_regex, &block)
|
def search(selectable, string_or_regex, &block)
|
||||||
case string_or_regex
|
case string_or_regex
|
||||||
when Regexp
|
when Regexp
|
||||||
search_regex(array, string_or_regex, &block)
|
search_regex(selectable, string_or_regex, &block)
|
||||||
else
|
else
|
||||||
search_string(array, string_or_regex.to_str, &block)
|
search_string(selectable, string_or_regex.to_str, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -183,17 +183,17 @@ module Homebrew
|
|||||||
string.downcase.gsub(/[^a-z\d]/i, "")
|
string.downcase.gsub(/[^a-z\d]/i, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_regex(array, regex)
|
def search_regex(selectable, regex)
|
||||||
array.select do |*args|
|
selectable.select do |*args|
|
||||||
args = yield(*args) if block_given?
|
args = yield(*args) if block_given?
|
||||||
args = Array(args).flatten.compact
|
args = Array(args).flatten.compact
|
||||||
args.any? { |arg| arg.match?(regex) }
|
args.any? { |arg| arg.match?(regex) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_string(array, string)
|
def search_string(selectable, string)
|
||||||
simplified_string = simplify_string(string)
|
simplified_string = simplify_string(string)
|
||||||
array.select do |*args|
|
selectable.select do |*args|
|
||||||
args = yield(*args) if block_given?
|
args = yield(*args) if block_given?
|
||||||
args = Array(args).flatten.compact
|
args = Array(args).flatten.compact
|
||||||
args.any? { |arg| simplify_string(arg).include?(simplified_string) }
|
args.any? { |arg| simplify_string(arg).include?(simplified_string) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user