aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/descriptions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/descriptions.rb')
-rw-r--r--Library/Homebrew/descriptions.rb45
1 files changed, 22 insertions, 23 deletions
diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb
index cc690c050..08860f7cf 100644
--- a/Library/Homebrew/descriptions.rb
+++ b/Library/Homebrew/descriptions.rb
@@ -57,42 +57,41 @@ class Descriptions
# If it does exist, but the Report is empty, just touch the cache file.
# Otherwise, use the report to update the cache.
def self.update_cache(report)
- if CACHE_FILE.exist?
- if report.empty?
- FileUtils.touch CACHE_FILE
- else
- renamings = report.select_formula(:R)
- alterations = report.select_formula(:A) + report.select_formula(:M) +
- renamings.map(&:last)
- cache_formulae(alterations, save: false)
- uncache_formulae(report.select_formula(:D) +
- renamings.map(&:first))
- end
+ return unless CACHE_FILE.exist?
+
+ if report.empty?
+ FileUtils.touch CACHE_FILE
+ else
+ renamings = report.select_formula(:R)
+ alterations = report.select_formula(:A) + report.select_formula(:M) +
+ renamings.map(&:last)
+ cache_formulae(alterations, save: false)
+ uncache_formulae(report.select_formula(:D) +
+ renamings.map(&:first))
end
end
# Given an array of formula names, add them and their descriptions to the
# cache. Save the updated cache to disk, unless explicitly told not to.
def self.cache_formulae(formula_names, options = { save: true })
- if cache
- formula_names.each do |name|
- begin
- desc = Formulary.factory(name).desc
- rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS
- end
- @cache[name] = desc
+ return unless cache
+
+ formula_names.each do |name|
+ begin
+ desc = Formulary.factory(name).desc
+ rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS
end
- save_cache if options[:save]
+ @cache[name] = desc
end
+ save_cache if options[:save]
end
# Given an array of formula names, remove them and their descriptions from
# the cache. Save the updated cache to disk, unless explicitly told not to.
def self.uncache_formulae(formula_names, options = { save: true })
- if cache
- formula_names.each { |name| @cache.delete(name) }
- save_cache if options[:save]
- end
+ return unless cache
+ formula_names.each { |name| @cache.delete(name) }
+ save_cache if options[:save]
end
# Given a regex, find all formulae whose specified fields contain a match.