Class: FormulaInfo 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.
Formula information drawn from an external brew info --json
call.
Instance Attribute Summary collapse
-
#info ⇒ Hash{String => T.untyped}
private
The whole info structure parsed from the JSON.
Class Method Summary collapse
- .force_utf8!(str) ⇒ void private
-
.lookup(name) ⇒ FormulaInfo?
private
Looks up formula on disk and reads its info.
Instance Method Summary collapse
- #any_bottle_tag ⇒ String? private
- #bottle_info(my_bottle_tag = Utils::Bottles.tag) ⇒ Hash{String => String}? private
- #bottle_info_any ⇒ Hash{String => String}? private
- #bottle_tags ⇒ Array<String> private
- #initialize(info) ⇒ void constructor private
- #pkg_version(spec_type = :stable) ⇒ PkgVersion private
- #revision ⇒ Integer private
- #version(spec_type) ⇒ Version private
Constructor Details
#initialize(info) ⇒ 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.
11 12 13 |
# File 'formula_info.rb', line 11 def initialize(info) @info = T.let(info, T::Hash[String, T.untyped]) end |
Instance Attribute Details
#info ⇒ 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.
The whole info structure parsed from the JSON.
8 9 10 |
# File 'formula_info.rb', line 8 def info @info end |
Class Method Details
.force_utf8!(str) ⇒ 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.
82 83 84 |
# File 'formula_info.rb', line 82 def self.force_utf8!(str) str.force_encoding("UTF-8") if str.respond_to?(:force_encoding) end |
.lookup(name) ⇒ FormulaInfo?
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.
Looks up formula on disk and reads its info. Returns nil if formula is absent or if there was an error reading it.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'formula_info.rb', line 18 def self.lookup(name) json = Utils.popen_read( *HOMEBREW_RUBY_EXEC_ARGS, HOMEBREW_LIBRARY_PATH/"brew.rb", "info", "--json=v1", name, ) return unless $CHILD_STATUS.success? force_utf8!(json) FormulaInfo.new(JSON.parse(json)[0]) end |
Instance Method Details
#any_bottle_tag ⇒ 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.
59 60 61 62 63 |
# File 'formula_info.rb', line 59 def any_bottle_tag tag = Utils::Bottles.tag.to_s # Prefer native bottles as a convenience for download caching .include?(tag) ? tag : .first end |
#bottle_info(my_bottle_tag = Utils::Bottles.tag) ⇒ Hash{String => 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.
43 44 45 46 47 48 49 50 51 |
# File 'formula_info.rb', line 43 def bottle_info(my_bottle_tag = Utils::Bottles.tag) tag_s = my_bottle_tag.to_s return unless info["bottle"]["stable"] btl_info = info["bottle"]["stable"]["files"][tag_s] return unless btl_info { "url" => btl_info["url"], "sha256" => btl_info["sha256"] } end |
#bottle_info_any ⇒ Hash{String => 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.
54 55 56 |
# File 'formula_info.rb', line 54 def bottle_info_any bottle_info(any_bottle_tag) end |
#bottle_tags ⇒ Array<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.
34 35 36 37 38 |
# File 'formula_info.rb', line 34 def return [] unless info["bottle"]["stable"] info["bottle"]["stable"]["files"].keys end |
#pkg_version(spec_type = :stable) ⇒ PkgVersion
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 |
# File 'formula_info.rb', line 72 def pkg_version(spec_type = :stable) PkgVersion.new(version(spec_type), revision) end |
#revision ⇒ Integer
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.
77 78 79 |
# File 'formula_info.rb', line 77 def revision info["revision"] end |
#version(spec_type) ⇒ Version
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 |
# File 'formula_info.rb', line 66 def version(spec_type) version_str = info["versions"][spec_type.to_s] Version.new(version_str) end |