Class: Colors

Inherits:
Object
  • Object
show all
Defined in:
lib/guac/colors.rb

Class Method Summary collapse

Class Method Details

.contains?(ary, string) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/guac/colors.rb', line 22

def contains?(ary, string)
  ary.compact.any? { |r| r.include?(string) }
end

.paint(ary) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/guac/colors.rb', line 7

def paint(ary)
  color =
    if contains?(ary, 'Updating') ||
       contains?(ary, 'Changes not staged for commit') ||
       contains?(ary, 'Your branch is behind')
      :yellow
    elsif contains?(ary, 'Failed') || contains?(ary, 'error:')
      :red
    else
      :green
    end

  ary.map { |r| r.colorize(color) }
end