Class: DescriptionCacheStore
- Inherits:
-
CacheStore
- Object
- CacheStore
- DescriptionCacheStore
- Includes:
- Searchable
- Defined in:
- Library/Homebrew/description_cache_store.rb
Overview
DescriptionCacheStore provides methods to fetch and mutate linkage-specific data used
by the brew linkage
command.
Instance Method Summary collapse
-
#delete!(formula_name) ⇒ nil
Delete the formula description from the DescriptionCacheStore.
-
#delete_from_formula_names!(formula_names) ⇒ nil
Use an array of formula names to delete them from the DescriptionCacheStore.
-
#populate_if_empty! ⇒ nil
If the database is empty
update!
it with all known formulae. -
#update!(formula_name, description) ⇒ nil
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
Use an array of formula names to update the DescriptionCacheStore.
-
#update_from_report!(report) ⇒ nil
Use an update report to update the DescriptionCacheStore.
Methods included from Searchable
Methods inherited from CacheStore
Constructor Details
This class inherits a constructor from CacheStore
Instance Method Details
#delete!(formula_name) ⇒ nil
Delete the formula description from the DescriptionCacheStore.
29 30 31 |
# File 'Library/Homebrew/description_cache_store.rb', line 29 def delete!(formula_name) database.delete(formula_name) end |
#delete_from_formula_names!(formula_names) ⇒ nil
Use an array of formula names to delete them from the DescriptionCacheStore.
78 79 80 81 82 |
# File 'Library/Homebrew/description_cache_store.rb', line 78 def delete_from_formula_names!(formula_names) return if database.empty? formula_names.each(&method(:delete!)) end |
#populate_if_empty! ⇒ nil
If the database is empty update!
it with all known formulae.
36 37 38 39 40 |
# File 'Library/Homebrew/description_cache_store.rb', line 36 def populate_if_empty! return unless database.empty? Formula.each { |f| update!(f.full_name, f.desc) } end |
#update!(formula_name, description) ⇒ nil
Inserts a formula description into the cache if it does not exist or updates the formula description if it does exist.
21 22 23 |
# File 'Library/Homebrew/description_cache_store.rb', line 21 def update!(formula_name, description) database.set(formula_name, description) end |
#update_from_formula_names!(formula_names) ⇒ nil
Use an array of formula names to update the DescriptionCacheStore.
64 65 66 67 68 69 70 71 72 |
# File 'Library/Homebrew/description_cache_store.rb', line 64 def update_from_formula_names!(formula_names) 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
Use an update report to update the DescriptionCacheStore.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'Library/Homebrew/description_cache_store.rb', line 46 def update_from_report!(report) return populate_if_empty! if database.empty? return if report.empty? renamings = report.select_formula(:R) alterations = report.select_formula(:A) + report.select_formula(:M) + renamings.map(&:last) update_from_formula_names!(alterations) delete_from_formula_names!(report.select_formula(:D) + renamings.map(&:first)) end |