Class: Messages

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/messages.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initializeMessages

Returns a new instance of Messages



8
9
10
11
12
# File 'brew/Library/Homebrew/messages.rb', line 8

def initialize
  @caveats = []
  @formula_count = 0
  @install_times = []
end

Instance Attribute Details

#caveatsObject (readonly)

Returns the value of attribute caveats



6
7
8
# File 'brew/Library/Homebrew/messages.rb', line 6

def caveats
  @caveats
end

#formula_countObject (readonly)

Returns the value of attribute formula_count



6
7
8
# File 'brew/Library/Homebrew/messages.rb', line 6

def formula_count
  @formula_count
end

#install_timesObject (readonly)

Returns the value of attribute install_times



6
7
8
# File 'brew/Library/Homebrew/messages.rb', line 6

def install_times
  @install_times
end

Instance Method Details

#display_caveatsObject



28
29
30
31
32
33
34
35
36
# File 'brew/Library/Homebrew/messages.rb', line 28

def display_caveats
  return if @formula_count <= 1
  return if @caveats.empty?

  oh1 "Caveats"
  @caveats.each do |c|
    ohai c[:formula], c[:caveats]
  end
end

#display_install_timesObject



38
39
40
41
42
43
44
45
# File 'brew/Library/Homebrew/messages.rb', line 38

def display_install_times
  return if install_times.empty?

  oh1 "Installation times"
  install_times.each do |t|
    puts format("%-20s %10.3f s", t[:formula], t[:time])
  end
end

#display_messagesObject



23
24
25
26
# File 'brew/Library/Homebrew/messages.rb', line 23

def display_messages
  display_caveats
  display_install_times if ARGV.include?("--display-times")
end

#formula_installed(f, elapsed_time) ⇒ Object



18
19
20
21
# File 'brew/Library/Homebrew/messages.rb', line 18

def formula_installed(f, elapsed_time)
  @formula_count += 1
  @install_times.push(formula: f.name, time: elapsed_time)
end

#record_caveats(f, caveats) ⇒ Object



14
15
16
# File 'brew/Library/Homebrew/messages.rb', line 14

def record_caveats(f, caveats)
  @caveats.push(formula: f.name, caveats: caveats)
end