Class: CaskDescriptionCacheStore Private

Inherits:
DescriptionCacheStore show all
Defined in:
description_cache_store/cask_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.

Constant Summary collapse

Key =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

type_member { { fixed: String } }
Value =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

type_member { { fixed: T.anything } }

Instance Method Summary collapse

Methods inherited from DescriptionCacheStore

#delete!, #delete_from_formula_names!, #select, #update!, #update_from_formula_names!

Methods inherited from CacheStore

#initialize

Constructor Details

This class inherits a constructor from CacheStore

Instance Method Details

#populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?) ⇒ void

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.

This method returns an undefined value.

If the database is empty update! it with all known casks.

Parameters:

  • eval_all (Boolean) (defaults to: Homebrew::EnvConfig.eval_all?)


16
17
18
19
20
21
22
# File 'description_cache_store/cask_description_cache_store.rb', line 16

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) ⇒ void

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.

This method returns an undefined value.

Use an array of cask tokens to update the CaskDescriptionCacheStore.

Parameters:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'description_cache_store/cask_description_cache_store.rb', line 49

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) ⇒ void

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.

This method returns an undefined value.

Use an update report to update the CaskDescriptionCacheStore.

Parameters:

  • report (ReporterHub)

    an update report generated by cmd/update.rb



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'description_cache_store/cask_description_cache_store.rb', line 29

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