Module: Announce

Defined in:
lib/terminal-announce.rb

Class Method Summary collapse

Class Method Details

.color_for(type) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/terminal-announce.rb', line 4

def self.color_for(type)
  {
    success: :green,
    failure: :red,
    warning: :yellow,
    info: :cyan
  }[type]
end

.failure(message) ⇒ Object



23
24
25
# File 'lib/terminal-announce.rb', line 23

def self.failure(message)
  log :failure, message
end

.info(message) ⇒ Object



31
32
33
# File 'lib/terminal-announce.rb', line 31

def self.info(message)
  log :info, message
end

.log(type, message) ⇒ Object



35
36
37
# File 'lib/terminal-announce.rb', line 35

def self.log(type, message)
  puts "#{prefix_for type} #{message}"
end

.prefix_for(type) ⇒ Object



13
14
15
16
17
# File 'lib/terminal-announce.rb', line 13

def self.prefix_for(type)
  color = color_for type
  text = type.to_s.capitalize
  "[#{Rainbow(text).color(color)}]"
end

.success(message) ⇒ Object



19
20
21
# File 'lib/terminal-announce.rb', line 19

def self.success(message)
  log :success, message
end

.warning(message) ⇒ Object



27
28
29
# File 'lib/terminal-announce.rb', line 27

def self.warning(message)
  log :warning, message
end