class Colors

Public Class Methods

contains?(ary, string) click to toggle source
# File lib/guac/colors.rb, line 22
def contains?(ary, string)
  ary.compact.any? { |r| r.include?(string) }
end
paint(ary) click to toggle source
# 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