Class: AbstractTab Private
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.
Rather than calling new
directly, use one of the class methods like Tab.create.
Constant Summary collapse
- FILENAME =
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.
"INSTALL_RECEIPT.json"
Instance Attribute Summary collapse
- #arch ⇒ Object private
- #built_on ⇒ Object private
- #homebrew_version ⇒ Object private
-
#installed_as_dependency ⇒ Boolean?
internal
Check whether the formula or cask was installed as a dependency.
-
#installed_on_request ⇒ Boolean?
internal
Check whether the formula or cask was installed on request.
- #loaded_from_api ⇒ Object private
-
#runtime_dependencies ⇒ Object
internal
Returns the formula or cask runtime dependencies.
- #source ⇒ Object private
- #tabfile ⇒ Object private
- #time ⇒ Object private
Class Method Summary collapse
-
.create(formula_or_cask) ⇒ Object
private
Instantiates a Tab for a new installation of a formula or cask.
- .empty ⇒ Object private
-
.from_file(path) ⇒ Object
private
Returns the Tab for a formula or cask install receipt at
path
. -
.from_file_content(content, path) ⇒ Object
private
Like AbstractTab.from_file, but bypass the cache.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ AbstractTab
constructor
private
A new instance of AbstractTab.
- #parsed_homebrew_version ⇒ Object private
- #tap ⇒ Tap? private
- #tap=(tap) ⇒ Object private
- #write ⇒ Object private
Methods included from Cachable
Constructor Details
#initialize(attributes = {}) ⇒ AbstractTab
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 new instance of AbstractTab.
109 110 111 |
# File 'tab.rb', line 109 def initialize(attributes = {}) attributes.each { |key, value| instance_variable_set(:"@#{key}", value) } end |
Instance Attribute Details
#arch ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def arch @arch end |
#built_on ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def built_on @built_on end |
#homebrew_version ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def homebrew_version @homebrew_version end |
#installed_as_dependency ⇒ Boolean?
This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Check whether the formula or cask was installed as a dependency.
20 21 22 |
# File 'tab.rb', line 20 def installed_as_dependency @installed_as_dependency end |
#installed_on_request ⇒ Boolean?
This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Check whether the formula or cask was installed on request.
26 27 28 |
# File 'tab.rb', line 26 def installed_on_request @installed_on_request end |
#loaded_from_api ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def loaded_from_api @loaded_from_api end |
#runtime_dependencies ⇒ Object
This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns the formula or cask runtime dependencies.
33 34 35 |
# File 'tab.rb', line 33 def runtime_dependencies @runtime_dependencies end |
#source ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def source @source end |
#tabfile ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def tabfile @tabfile end |
#time ⇒ 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.
28 29 30 |
# File 'tab.rb', line 28 def time @time end |
Class Method Details
.create(formula_or_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 Tab for a new installation of a formula or cask.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'tab.rb', line 36 def self.create(formula_or_cask) attributes = { "homebrew_version" => HOMEBREW_VERSION, "installed_as_dependency" => false, "installed_on_request" => false, "loaded_from_api" => formula_or_cask.loaded_from_api?, "time" => Time.now.to_i, "arch" => Hardware::CPU.arch, "source" => { "tap" => formula_or_cask.tap&.name, "tap_git_head" => formula_or_cask.tap_git_head, }, "built_on" => DevelopmentTools.build_system_info, } new(attributes) end |
.empty ⇒ 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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'tab.rb', line 78 def self.empty attributes = { "homebrew_version" => HOMEBREW_VERSION, "installed_as_dependency" => false, "installed_on_request" => false, "loaded_from_api" => false, "time" => nil, "runtime_dependencies" => nil, "arch" => nil, "source" => { "path" => nil, "tap" => nil, "tap_git_head" => nil, }, "built_on" => DevelopmentTools.build_system_info, } new(attributes) end |
.from_file(path) ⇒ 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.
Results are cached.
Returns the Tab for a formula or cask install receipt at path
.
57 58 59 60 61 62 63 64 |
# File 'tab.rb', line 57 def self.from_file(path) cache.fetch(path) do |p| content = File.read(p) return empty if content.blank? cache[p] = from_file_content(content, p) end end |
.from_file_content(content, path) ⇒ 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.
Like from_file, but bypass the cache.
67 68 69 70 71 72 73 74 75 76 |
# File 'tab.rb', line 67 def self.from_file_content(content, path) attributes = begin JSON.parse(content) rescue JSON::ParserError => e raise e, "Cannot parse #{path}: #{e}", e.backtrace end attributes["tabfile"] = path new(attributes) end |
Instance Method Details
#parsed_homebrew_version ⇒ 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.
113 114 115 116 117 |
# File 'tab.rb', line 113 def parsed_homebrew_version return Version::NULL if homebrew_version.nil? Version.new(homebrew_version) end |
#tap ⇒ Tap?
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.
120 121 122 123 |
# File 'tab.rb', line 120 def tap tap_name = source["tap"] Tap.fetch(tap_name) if tap_name end |
#tap=(tap) ⇒ 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.
125 126 127 128 |
# File 'tab.rb', line 125 def tap=(tap) tap_name = tap.respond_to?(:name) ? tap.name : tap source["tap"] = tap_name end |
#write ⇒ 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.
130 131 132 133 |
# File 'tab.rb', line 130 def write self.class.cache[tabfile] = self tabfile.atomic_write(to_json) end |