Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Mike McQuaid <[email protected]>
  • Loading branch information
rrotter and MikeMcQuaid committed Jun 29, 2024
1 parent 622cbdc commit d84246c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Library/Homebrew/descriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# Helper class for printing and searching descriptions.
class Descriptions
# Given a regex, find all formulae whose specified fields contain a match.
def self.search(string_or_regex, field, cache_store, eval_all = Homebrew::EnvConfig.eval_all?)
# allow searching a simple hash, not only cache_store objects
cache_store.populate_if_empty!(eval_all:) if cache_store.methods.include?(:populate_if_empty!)
def self.search(string_or_regex, field, cache_store,
eval_all = Homebrew::EnvConfig.eval_all?, cache_store_hash: false)

cache_store.populate_if_empty!(eval_all:) unless cache_store_hash

results = case field
when :name
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.search_descriptions(string_or_regex, args, search_type: :desc)
end
else
descriptions = Homebrew::API::Formula.all_formulae.transform_values { |data| data["desc"] }
Descriptions.search(string_or_regex, search_type, descriptions, eval_all).print
Descriptions.search(string_or_regex, search_type, descriptions, eval_all, cache_store_hash: true).print
end
end
return if !args.cask? && !both
Expand All @@ -44,7 +44,7 @@ def self.search_descriptions(string_or_regex, args, search_type: :desc)
end
else
descriptions = Homebrew::API::Cask.all_casks.transform_values { |data| data["desc"] }
Descriptions.search(string_or_regex, search_type, descriptions, eval_all).print
Descriptions.search(string_or_regex, search_type, descriptions, eval_all, cache_store_hash: true).print
end
end

Expand Down

0 comments on commit d84246c

Please sign in to comment.