Class: Cask::List Private

Inherits:
Object show all
Defined in:
cask/list.rb

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.

Class Method Summary collapse

Class Method Details

.format_versioned(cask) ⇒ 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.



45
46
47
# File 'cask/list.rb', line 45

def self.format_versioned(cask)
  "#{cask}#{cask.installed_version&.prepend(" ")}"
end

.list_artifacts(cask) ⇒ 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.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'cask/list.rb', line 31

def self.list_artifacts(cask)
  cask.artifacts.group_by(&:class).sort_by { |klass, _| klass.english_name }.each do |klass, artifacts|
    next if [Artifact::Uninstall, Artifact::Zap].include? klass

    ohai klass.english_name
    artifacts.each do |artifact|
      puts artifact.summarize_installed if artifact.respond_to?(:summarize_installed)
      next if artifact.respond_to?(:summarize_installed)

      puts artifact
    end
  end
end

.list_casks(*casks, one: false, full_name: false, versions: false) ⇒ 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.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'cask/list.rb', line 9

def self.list_casks(*casks, one: false, full_name: false, versions: false)
  output = if casks.any?
    casks.each do |cask|
      raise CaskNotInstalledError, cask unless cask.installed?
    end
  else
    Caskroom.casks
  end

  if one
    puts output.map(&:to_s)
  elsif full_name
    puts output.map(&:full_name).sort(&tap_and_name_comparison)
  elsif versions
    puts output.map { format_versioned(_1) }
  elsif !output.empty? && casks.any?
    output.map { list_artifacts(_1) }
  elsif !output.empty?
    puts Formatter.columns(output.map(&:to_s))
  end
end