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 ⇒ Object
private
The whole info structure parsed from the JSON.
Class Method Summary collapse
- .force_utf8!(str) ⇒ Object private
-
.lookup(name) ⇒ Object
private
Looks up formula on disk and reads its info.
Instance Method Summary collapse
- #any_bottle_tag ⇒ Object private
- #bottle_info(my_bottle_tag = Utils::Bottles.tag) ⇒ Object private
- #bottle_info_any ⇒ Object private
- #bottle_tags ⇒ Object private
-
#initialize(info) ⇒ FormulaInfo
constructor
private
A new instance of FormulaInfo.
- #pkg_version(spec_type = :stable) ⇒ Object private
- #revision ⇒ Object private
- #version(spec_type) ⇒ Object private
Constructor Details
#initialize(info) ⇒ 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.
Returns a new instance of FormulaInfo.
9 10 11 |
# File 'formula_info.rb', line 9 def initialize(info) @info = info end |
Instance Attribute Details
#info ⇒ 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.
The whole info structure parsed from the JSON.
7 8 9 |
# File 'formula_info.rb', line 7 def info @info end |
Class Method Details
.force_utf8!(str) ⇒ 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.
69 70 71 |
# File 'formula_info.rb', line 69 def self.force_utf8!(str) str.force_encoding("UTF-8") if str.respond_to?(:force_encoding) end |
.lookup(name) ⇒ 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.
Looks up formula on disk and reads its info. Returns nil if formula is absent or if there was an error reading it.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'formula_info.rb', line 15 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 ⇒ 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.
50 51 52 53 54 |
# File 'formula_info.rb', line 50 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) ⇒ 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.
36 37 38 39 40 41 42 43 44 |
# File 'formula_info.rb', line 36 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 ⇒ 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.
46 47 48 |
# File 'formula_info.rb', line 46 def bottle_info_any bottle_info(any_bottle_tag) end |
#bottle_tags ⇒ 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.
30 31 32 33 34 |
# File 'formula_info.rb', line 30 def return [] unless info["bottle"]["stable"] info["bottle"]["stable"]["files"].keys end |
#pkg_version(spec_type = :stable) ⇒ 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.
61 62 63 |
# File 'formula_info.rb', line 61 def pkg_version(spec_type = :stable) PkgVersion.new(version(spec_type), revision) end |
#revision ⇒ 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.
65 66 67 |
# File 'formula_info.rb', line 65 def revision info["revision"] end |
#version(spec_type) ⇒ 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.
56 57 58 59 |
# File 'formula_info.rb', line 56 def version(spec_type) version_str = info["versions"][spec_type.to_s] version_str && Version.new(version_str) end |