Class: DescriptionCacheStore Private
- Inherits:
-
CacheStore
- Object
- CacheStore
- DescriptionCacheStore
- Defined in:
- description_cache_store.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
DescriptionCacheStore provides methods to fetch and mutate formula descriptions used
by the brew desc
and brew search
commands.
Direct Known Subclasses
Instance Method Summary collapse
-
#delete!(formula_name) ⇒ nil
private
Delete the formula description from the DescriptionCacheStore.
-
#delete_from_formula_names!(formula_names) ⇒ nil
(also: #delete_from_cask_tokens!)
private
Use an array of formula names to delete them from the DescriptionCacheStore.
-
#populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?) ⇒ nil
private
If the database is empty
update!
it with all known formulae. -
#select(&block) ⇒ Object
private
select
from the underlying database. -
#update!(formula_name, description) ⇒ nil
private
Inserts a formula description into the cache if it does not exist or updates the formula description if it does exist.
-
#update_from_formula_names!(formula_names) ⇒ nil
private
Use an array of formula names to update the DescriptionCacheStore.
-
#update_from_report!(report) ⇒ nil
private
Use an update report to update the DescriptionCacheStore.
Methods inherited from CacheStore
Constructor Details
This class inherits a constructor from CacheStore
Instance Method Details
#delete!(formula_name) ⇒ nil
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Delete the formula description from the DescriptionCacheStore.
25 26 27 |
# File 'description_cache_store.rb', line 25 def delete!(formula_name) database.delete(formula_name) end |
#delete_from_formula_names!(formula_names) ⇒ nil Also known as: delete_from_cask_tokens!
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Use an array of formula names to delete them from the DescriptionCacheStore.
83 84 85 86 87 |
# File 'description_cache_store.rb', line 83 def delete_from_formula_names!(formula_names) return if database.empty? formula_names.each(&method(:delete!)) end |
#populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?) ⇒ nil
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
If the database is empty update!
it with all known formulae.
32 33 34 35 36 37 |
# File 'description_cache_store.rb', line 32 def populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?) return unless eval_all return unless database.empty? Formula.all(eval_all:).each { |f| update!(f.full_name, f.desc) } end |
#select(&block) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
select
from the underlying database.
91 92 93 |
# File 'description_cache_store.rb', line 91 def select(&block) database.select(&block) end |
#update!(formula_name, description) ⇒ nil
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Inserts a formula description into the cache if it does not exist or updates the formula description if it does exist.
17 18 19 |
# File 'description_cache_store.rb', line 17 def update!(formula_name, description) database.set(formula_name, description) end |
#update_from_formula_names!(formula_names) ⇒ nil
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Use an array of formula names to update the DescriptionCacheStore.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'description_cache_store.rb', line 65 def update_from_formula_names!(formula_names) unless Homebrew::EnvConfig.eval_all? database.clear! return end return populate_if_empty! if database.empty? formula_names.each do |name| update!(name, Formula[name].desc) rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS delete!(name) end end |
#update_from_report!(report) ⇒ nil
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Use an update report to update the DescriptionCacheStore.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'description_cache_store.rb', line 43 def update_from_report!(report) unless Homebrew::EnvConfig.eval_all? database.clear! return end return populate_if_empty! if database.empty? return if report.empty? renamings = report.select_formula_or_cask(:R) alterations = report.select_formula_or_cask(:A) + report.select_formula_or_cask(:M) + renamings.map(&:last) update_from_formula_names!(alterations) delete_from_formula_names!(report.select_formula_or_cask(:D) + renamings.map(&:first)) end |