Class: Messages 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.
A Messages object collects messages that may need to be displayed together
at the end of a multi-step brew
command run.
Instance Attribute Summary collapse
- #caveats ⇒ Array<Hash> readonly private
- #install_times ⇒ Array<Hash{String => Float}> readonly private
- #package_count ⇒ Integer readonly private
Instance Method Summary collapse
- #display_caveats(force: false) ⇒ void private
- #display_install_times ⇒ void private
- #display_messages(force_caveats: false, display_times: false) ⇒ void private
- #initialize ⇒ void constructor private
- #package_installed(package, elapsed_time) ⇒ void private
- #record_caveats(package, caveats) ⇒ void private
- #record_completions_and_elisp(completions_and_elisp) ⇒ void private
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Constructor Details
#initialize ⇒ 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.
21 22 23 24 25 26 |
# File 'messages.rb', line 21 def initialize @caveats = T.let([], T::Array[{ package: String, caveats: T.any(String, Caveats) }]) @completions_and_elisp = T.let(Set.new, T::Set[String]) @package_count = T.let(0, Integer) @install_times = T.let([], T::Array[T::Hash[String, Float]]) end |
Instance Attribute Details
#caveats ⇒ Array<Hash> (readonly)
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 'messages.rb', line 12 def caveats @caveats end |
#install_times ⇒ Array<Hash{String => Float}> (readonly)
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.
18 19 20 |
# File 'messages.rb', line 18 def install_times @install_times end |
#package_count ⇒ Integer (readonly)
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 'messages.rb', line 15 def package_count @package_count end |
Instance Method Details
#display_caveats(force: false) ⇒ 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.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'messages.rb', line 51 def display_caveats(force: false) return if @package_count.zero? return if @caveats.empty? && @completions_and_elisp.empty? oh1 "Caveats" unless @completions_and_elisp.empty? @completions_and_elisp.each { |c| puts c } return if @package_count == 1 && !force oh1 "Caveats" if @completions_and_elisp.empty? @caveats.each { |c| ohai c.fetch(:package), c.fetch(:caveats) } end |
#display_install_times ⇒ 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.
64 65 66 67 68 69 70 71 |
# File 'messages.rb', line 64 def display_install_times return if install_times.empty? oh1 "Installation times" install_times.each do |t| puts format("%<package>-20s %<time>10.3f s", t) end end |
#display_messages(force_caveats: false, display_times: false) ⇒ 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.
45 46 47 48 |
# File 'messages.rb', line 45 def (force_caveats: false, display_times: false) display_caveats(force: force_caveats) display_install_times if display_times end |
#package_installed(package, elapsed_time) ⇒ 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.
39 40 41 42 |
# File 'messages.rb', line 39 def package_installed(package, elapsed_time) @package_count += 1 @install_times.push(package:, time: elapsed_time) end |
#record_caveats(package, caveats) ⇒ 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.
29 30 31 |
# File 'messages.rb', line 29 def record_caveats(package, caveats) @caveats.push(package:, caveats:) end |
#record_completions_and_elisp(completions_and_elisp) ⇒ 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.
34 35 36 |
# File 'messages.rb', line 34 def record_completions_and_elisp(completions_and_elisp) @completions_and_elisp.merge(completions_and_elisp) end |