Class: Cask::Tab
- Inherits:
-
AbstractTab
- Object
- AbstractTab
- Cask::Tab
- Defined in:
- cask/tab.rb
Constant Summary collapse
- Cache =
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_template { { fixed: T::Hash[T.any(Pathname, String), T.untyped] } }
Constants inherited from AbstractTab
AbstractTab::FILENAME, AbstractTab::RuntimeDependencies
Instance Attribute Summary collapse
Attributes inherited from AbstractTab
#arch, #built_on, #homebrew_version, #installed_on_request, #loaded_from_api, #loaded_from_internal_api, #runtime_dependencies, #source, #tabfile, #time
Class Method Summary collapse
-
.create(formula_or_cask) ⇒ T.attached_class
private
Instantiates a Tab for a new installation of a cask.
- .empty ⇒ T.attached_class private
-
.for_cask(cask) ⇒ T.attached_class
private
Returns a Tab for an already installed cask, or a fake one if the cask is not installed.
- .runtime_deps_hash(cask) ⇒ Hash{Symbol => Array<Hash{String => T.untyped}>} private
Instance Method Summary collapse
- #initialize(attributes = {}) ⇒ void constructor private
- #to_json(*_args) ⇒ String private
- #version ⇒ String? private
Methods inherited from AbstractTab
from_file, from_file_content, #installed_on_request_present?, #parsed_homebrew_version, #tap, #tap=, #write
Methods included from Cachable
Constructor Details
#initialize(attributes = {}) ⇒ 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.
21 22 23 24 25 26 |
# File 'cask/tab.rb', line 21 def initialize(attributes = {}) @uninstall_flight_blocks = T.let(nil, T.nilable(T::Boolean)) @uninstall_artifacts = T.let(nil, T.nilable(T::Array[T.untyped])) super end |
Instance Attribute Details
#uninstall_artifacts ⇒ Array<T.untyped>?
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.
18 19 20 |
# File 'cask/tab.rb', line 18 def uninstall_artifacts @uninstall_artifacts end |
#uninstall_flight_blocks ⇒ 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.
15 16 17 |
# File 'cask/tab.rb', line 15 def uninstall_flight_blocks @uninstall_flight_blocks end |
Class Method Details
.create(formula_or_cask) ⇒ T.attached_class
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.
Instantiates a Cask::Tab for a new installation of a cask.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'cask/tab.rb', line 30 def self.create(formula_or_cask) cask = T.cast(formula_or_cask, Cask) tab = super tab.tabfile = cask./FILENAME tab.uninstall_flight_blocks = cask.uninstall_flight_blocks? tab.runtime_dependencies = Tab.runtime_deps_hash(cask) tab.source["version"] = cask.version.to_s tab.source["path"] = cask.sourcefile_path.to_s tab.uninstall_artifacts = cask.artifacts_list(uninstall_only: true) tab end |
.empty ⇒ T.attached_class
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.
65 66 67 68 69 70 71 72 |
# File 'cask/tab.rb', line 65 def self.empty tab = super tab.uninstall_flight_blocks = false tab.uninstall_artifacts = [] tab.source["version"] = nil tab end |
.for_cask(cask) ⇒ T.attached_class
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 a Cask::Tab for an already installed cask, or a fake one if the cask is not installed.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'cask/tab.rb', line 47 def self.for_cask(cask) path = cask./FILENAME return from_file(path) if path.exist? tab = empty tab.source = { "path" => cask.sourcefile_path.to_s, "tap" => cask.tap&.name, "tap_git_head" => cask.tap_git_head, "version" => cask.version.to_s, } tab.uninstall_artifacts = cask.artifacts_list(uninstall_only: true) tab end |
.runtime_deps_hash(cask) ⇒ Hash{Symbol => Array<Hash{String => T.untyped}>}
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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'cask/tab.rb', line 75 def self.runtime_deps_hash(cask) cask_and_formula_dep_graph = ::Utils::TopologicalHash.graph_package_dependencies(cask) cask_deps, formula_deps = T.cast(cask_and_formula_dep_graph.values.flatten.uniq.partition do |dep| dep.is_a?(Cask) end, [T::Array[Cask], T::Array[Formula]]) runtime_deps = {} if cask_deps.any? runtime_deps[:cask] = cask_deps.map do |dep| { "full_name" => dep.full_name, "version" => dep.version.to_s, "declared_directly" => cask.depends_on.cask.include?(dep.full_name), } end end if formula_deps.any? runtime_deps[:formula] = formula_deps.map do |dep| formula_to_dep_hash(dep, cask.depends_on.formula) end end runtime_deps end |
Instance Method Details
#to_json(*_args) ⇒ String
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.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'cask/tab.rb', line 108 def to_json(*_args) attributes = { "homebrew_version" => homebrew_version, "loaded_from_api" => loaded_from_api, "loaded_from_internal_api" => loaded_from_internal_api, "uninstall_flight_blocks" => uninstall_flight_blocks, "installed_on_request" => installed_on_request, "time" => time, "runtime_dependencies" => runtime_dependencies, "source" => source, "arch" => arch, "uninstall_artifacts" => uninstall_artifacts, "built_on" => built_on, } JSON.pretty_generate(attributes) end |
#version ⇒ String?
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.
103 104 105 |
# File 'cask/tab.rb', line 103 def version source["version"] end |