Class: Cask::Tab
- Inherits:
-
AbstractTab
- Object
- AbstractTab
- Cask::Tab
- Defined in:
- cask/tab.rb
Constant Summary collapse
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(uninstall_flight_blocks: nil, uninstall_artifacts: nil, **rest) ⇒ void constructor private
- #to_json(*_args) ⇒ String private
-
#update_caskfile(cask) ⇒ void
private
Update the recorded definition while preserving the installation history.
- #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 Cacheable
Constructor Details
#initialize(uninstall_flight_blocks: nil, uninstall_artifacts: nil, **rest) ⇒ 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.
23 24 25 26 27 28 |
# File 'cask/tab.rb', line 23 def initialize(uninstall_flight_blocks: nil, uninstall_artifacts: nil, **rest) @uninstall_flight_blocks = uninstall_flight_blocks @uninstall_artifacts = uninstall_artifacts super(**rest) 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.
15 16 17 |
# File 'cask/tab.rb', line 15 def uninstall_artifacts @uninstall_artifacts end |
#uninstall_flight_blocks ⇒ 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.
12 13 14 |
# File 'cask/tab.rb', line 12 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.
32 33 34 35 36 37 38 39 |
# File 'cask/tab.rb', line 32 def self.create(formula_or_cask) cask = T.cast(formula_or_cask, Cask) tab = super tab.runtime_dependencies = Tab.runtime_deps_hash(cask) tab.update_caskfile(cask) 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.
72 73 74 75 76 77 78 79 |
# File 'cask/tab.rb', line 72 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.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'cask/tab.rb', line 54 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.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'cask/tab.rb', line 82 def self.runtime_deps_hash(cask) cask_and_formula_dep_graph = ::Utils::TopologicalHash.graph_package_dependencies(cask) dependencies_by_type = cask_and_formula_dep_graph.values.flatten.uniq.partition do |dep| dep.is_a?(Cask) end cask_deps, formula_deps = T.cast(dependencies_by_type, [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.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'cask/tab.rb', line 116 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 |
#update_caskfile(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.
This method returns an undefined value.
Update the recorded definition while preserving the installation history.
43 44 45 46 47 48 49 |
# File 'cask/tab.rb', line 43 def update_caskfile(cask) self.tabfile ||= cask./FILENAME self.uninstall_flight_blocks = cask.uninstall_flight_blocks? self.uninstall_artifacts = cask.artifacts_list(uninstall_only: true) self.source = source.merge("version" => cask.version.to_s, "path" => cask.sourcefile_path.to_s, "tap" => cask.tap&.name, "tap_git_head" => cask.tap_git_head) 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.
111 112 113 |
# File 'cask/tab.rb', line 111 def version source["version"] end |