Class: CaskDependent Private

Inherits:
Object show all
Defined in:
cask_dependent.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.

An adapter for casks to provide dependency information in a formula-like interface.

Defined Under Namespace

Classes: Requirement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:



22
23
24
# File 'cask_dependent.rb', line 22

def initialize(cask)
  @cask = cask
end

Instance Attribute Details

#caskCask::Cask (readonly)

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.

Returns:



19
20
21
# File 'cask_dependent.rb', line 19

def cask
  @cask
end

Instance Method Details

#any_version_installed?Boolean

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.

Returns:

  • (Boolean)


104
105
106
# File 'cask_dependent.rb', line 104

def any_version_installed?
  @cask.installed?
end

#depsArray<Dependency>

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.

Returns:



42
43
44
45
46
47
48
49
# File 'cask_dependent.rb', line 42

def deps
  @deps ||= T.let(
    @cask.depends_on.formula.map do |f|
      Dependency.new f
    end,
    T.nilable(T::Array[Dependency]),
  )
end

#full_nameString

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.

Returns:



32
33
34
# File 'cask_dependent.rb', line 32

def full_name
  @cask.full_name
end

#nameString

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.

Returns:



27
28
29
# File 'cask_dependent.rb', line 27

def name
  @cask.token
end

#recursive_dependencies(&block) ⇒ Array<::Dependency>

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.

Parameters:

Returns:



89
90
91
# File 'cask_dependent.rb', line 89

def recursive_dependencies(&block)
  Dependency.expand(self, &block)
end

#recursive_requirements(&block) ⇒ Requirements

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.

Parameters:

Returns:



99
100
101
# File 'cask_dependent.rb', line 99

def recursive_requirements(&block)
  Requirement.expand(self, &block)
end

#requirementsArray<::Requirement>

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.

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'cask_dependent.rb', line 52

def requirements
  @requirements ||= T.let(
    begin
      requirements = []
      dsl_reqs = @cask.depends_on

      dsl_reqs.arch&.each do |arch|
        arch = if arch[:bits] == 64
          if arch[:type] == :intel
            :x86_64
          else
            :"#{arch[:type]}64"
          end
        elsif arch[:type] == :intel && arch[:bits] == 32
          :i386
        else
          arch[:type]
        end
        requirements << ArchRequirement.new([arch])
      end
      dsl_reqs.cask.each do |cask_ref|
        requirements << CaskDependent::Requirement.new([{ cask: cask_ref }])
      end
      requirements << dsl_reqs.macos if dsl_reqs.macos

      requirements
    end,
    T.nilable(T::Array[::Requirement]),
  )
end

#runtime_dependenciesArray<Dependency>

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.

Returns:



37
38
39
# File 'cask_dependent.rb', line 37

def runtime_dependencies
  deps.flat_map { |dep| [dep, *dep.to_installed_formula.runtime_dependencies] }.uniq
end