module GithubActions::Colorizer

helper methods for colorizing output, if the “rainbow” colorizing gem is not installed then it prints the original messages without any colorizing

Public Instance Methods

error(msg) click to toggle source

print an error @param msg [Object] the text to print

# File lib/tasks/github_actions/github_actions/colorizer.rb, line 27
def error(msg)
  print_colored(msg, :red)
end
info(msg) click to toggle source

print a message @param msg [Object] the text to print

# File lib/tasks/github_actions/github_actions/colorizer.rb, line 45
def info(msg)
  print_colored(msg, :cyan)
end
stage(msg) click to toggle source

print the progress status @param msg [Object] the text to print

# File lib/tasks/github_actions/github_actions/colorizer.rb, line 51
def stage(msg)
  print_colored(msg, :yellow)
end
success(msg) click to toggle source

print a success message @param msg [Object] the text to print

# File lib/tasks/github_actions/github_actions/colorizer.rb, line 33
def success(msg)
  print_colored(msg, :green)
end
warning(msg) click to toggle source

print a warning @param msg [Object] the text to print

# File lib/tasks/github_actions/github_actions/colorizer.rb, line 39
def warning(msg)
  print_colored(msg, :magenta)
end

Private Instance Methods

print_colored(msg, color) click to toggle source

helper for printing the text @param msg [Object] the text to print @param color [Symbol] the text color

rainbow?() click to toggle source

load the Rainbow colorizing library if present see github.com/sickill/rainbow @return Boolean ‘true` if Rainbow was successfully loaded, `false` otherwise

# File lib/tasks/github_actions/github_actions/colorizer.rb, line 67
def rainbow?
  return @rainbow_present unless @rainbow_present.nil?

  begin
    require "rainbow"
    @rainbow_present = true
  rescue LoadError
    @rainbow_present = false
  end

  @rainbow_present
end