Class: CaskDescriptionCacheStore Private
- Inherits:
-
DescriptionCacheStore
- Object
- CacheStore
- DescriptionCacheStore
- CaskDescriptionCacheStore
- 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.
CaskDescriptionCacheStore provides methods to fetch and mutate cask descriptions used
by the brew desc
and brew search
commands.
Instance Method Summary collapse
-
#populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?) ⇒ nil
private
If the database is empty
update!
it with all known casks. -
#update_from_cask_tokens!(cask_tokens) ⇒ nil
private
Use an array of cask tokens to update the CaskDescriptionCacheStore.
-
#update_from_report!(report) ⇒ nil
private
Use an update report to update the CaskDescriptionCacheStore.
Methods inherited from DescriptionCacheStore
#delete!, #delete_from_formula_names!, #select, #update!, #update_from_formula_names!
Methods inherited from CacheStore
#delete!, #fetch, #initialize, #update!
Constructor Details
This class inherits a constructor from CacheStore
Instance Method Details
#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 casks.
104 105 106 107 108 109 110 |
# File 'description_cache_store.rb', line 104 def populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?) return unless eval_all return unless database.empty? Cask::Cask.all(eval_all:) .each { |c| update!(c.full_name, [c.name.join(", "), c.desc.presence]) } end |
#update_from_cask_tokens!(cask_tokens) ⇒ 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 cask tokens to update the CaskDescriptionCacheStore.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'description_cache_store.rb', line 135 def update_from_cask_tokens!(cask_tokens) unless Homebrew::EnvConfig.eval_all? database.clear! return end return populate_if_empty! if database.empty? cask_tokens.each do |token| c = Cask::CaskLoader.load(token) update!(c.full_name, [c.name.join(", "), c.desc.presence]) rescue Cask::CaskUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS delete!(c.full_name) if c.present? 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 CaskDescriptionCacheStore.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'description_cache_store.rb', line 116 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? alterations = report.select_formula_or_cask(:AC) + report.select_formula_or_cask(:MC) update_from_cask_tokens!(alterations) delete_from_cask_tokens!(report.select_formula_or_cask(:DC)) end |