Class: Cask::Tab
- Inherits:
-
AbstractTab
- Object
- AbstractTab
- Cask::Tab
- Defined in:
- cask/tab.rb
Constant Summary
Constants inherited from AbstractTab
Instance Attribute Summary collapse
-
#uninstall_artifacts ⇒ Object
private
Returns the value of attribute uninstall_artifacts.
-
#uninstall_flight_blocks ⇒ Object
private
Returns the value of attribute uninstall_flight_blocks.
Attributes inherited from AbstractTab
#arch, #built_on, #homebrew_version, #installed_as_dependency, #installed_on_request, #loaded_from_api, #runtime_dependencies, #source, #tabfile, #time
Class Method Summary collapse
-
.create(cask) ⇒ Object
private
Instantiates a Tab for a new installation of a cask.
- .empty ⇒ Object
-
.for_cask(cask) ⇒ Object
private
Returns a Tab for an already installed cask, or a fake one if the cask is not installed.
- .runtime_deps_hash(cask) ⇒ Object
Instance Method Summary collapse
Methods inherited from AbstractTab
from_file, from_file_content, #initialize, #parsed_homebrew_version, #tap, #tap=, #write
Methods included from Cachable
Constructor Details
This class inherits a constructor from AbstractTab
Instance Attribute Details
#uninstall_artifacts ⇒ 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.
Returns the value of attribute uninstall_artifacts.
8 9 10 |
# File 'cask/tab.rb', line 8 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.
Returns the value of attribute uninstall_flight_blocks.
8 9 10 |
# File 'cask/tab.rb', line 8 def uninstall_flight_blocks @uninstall_flight_blocks end |
Class Method Details
.create(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.
Instantiates a Cask::Tab for a new installation of a cask.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'cask/tab.rb', line 11 def self.create(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 ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'cask/tab.rb', line 43 def self.empty tab = super tab.uninstall_flight_blocks = false tab.uninstall_artifacts = [] tab.source["version"] = nil tab end |
.for_cask(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.
Returns a Cask::Tab for an already installed cask, or a fake one if the cask is not installed.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'cask/tab.rb', line 26 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) ⇒ Object
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 |
# File 'cask/tab.rb', line 52 def self.runtime_deps_hash(cask) cask_and_formula_dep_graph = ::Utils::TopologicalHash.graph_package_dependencies(cask) cask_deps, formula_deps = cask_and_formula_dep_graph.values.flatten.uniq.partition do |dep| dep.is_a?(Cask) end 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) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'cask/tab.rb', line 83 def to_json(*_args) attributes = { "homebrew_version" => homebrew_version, "loaded_from_api" => loaded_from_api, "uninstall_flight_blocks" => uninstall_flight_blocks, "installed_as_dependency" => installed_as_dependency, "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 ⇒ Object
79 80 81 |
# File 'cask/tab.rb', line 79 def version source["version"] end |