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 ⇒ Object readonly private
- #install_times ⇒ Object readonly private
- #package_count ⇒ Object readonly private
Instance Method Summary collapse
- #display_caveats(force: false) ⇒ Object private
- #display_install_times ⇒ Object private
- #display_messages(force_caveats: false, display_times: false) ⇒ Object private
- #initialize ⇒ void constructor private
- #package_installed(package, elapsed_time) ⇒ Object private
- #record_caveats(package, caveats) ⇒ Object private
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.
10 11 12 13 14 |
# File 'messages.rb', line 10 def initialize @caveats = [] @package_count = 0 @install_times = [] end |
Instance Attribute Details
#caveats ⇒ Object (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.
7 8 9 |
# File 'messages.rb', line 7 def caveats @caveats end |
#install_times ⇒ Object (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.
7 8 9 |
# File 'messages.rb', line 7 def install_times @install_times end |
#package_count ⇒ Object (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.
7 8 9 |
# File 'messages.rb', line 7 def package_count @package_count end |
Instance Method Details
#display_caveats(force: false) ⇒ 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 35 36 37 38 39 |
# File 'messages.rb', line 30 def display_caveats(force: false) return if @package_count.zero? return if @package_count == 1 && !force return if @caveats.empty? oh1 "Caveats" @caveats.each do |c| ohai c[:package], c[:caveats] end end |
#display_install_times ⇒ 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.
41 42 43 44 45 46 47 48 |
# File 'messages.rb', line 41 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) ⇒ 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.
25 26 27 28 |
# File 'messages.rb', line 25 def (force_caveats: false, display_times: false) display_caveats(force: force_caveats) display_install_times if display_times end |
#package_installed(package, elapsed_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.
20 21 22 23 |
# File 'messages.rb', line 20 def package_installed(package, elapsed_time) @package_count += 1 @install_times.push(package:, time: elapsed_time) end |
#record_caveats(package, caveats) ⇒ 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.
16 17 18 |
# File 'messages.rb', line 16 def record_caveats(package, caveats) @caveats.push(package:, caveats:) end |