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
- #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(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.
22 23 24 25 26 27 |
# File 'cask/tab.rb', line 22 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.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'cask/tab.rb', line 31 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.
66 67 68 69 70 71 72 73 |
# File 'cask/tab.rb', line 66 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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'cask/tab.rb', line 48 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.
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 101 |
# File 'cask/tab.rb', line 76 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.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'cask/tab.rb', line 109 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.
104 105 106 |
# File 'cask/tab.rb', line 104 def version source["version"] end |