Move color constants to a private named tuple

This commit is contained in:
Michael Miller 2019-02-17 21:32:42 -07:00
parent 1a998b6cb6
commit bd500b0799

View file

@ -5,44 +5,38 @@ module Spectator::Formatters
module Color module Color
extend self extend self
# Symbol in `Colorize` representing success. # Symbols in `Colorize` representing result types and formatting types.
SUCCESS_COLOR = :green private COLORS = {
success: :green,
# Symbol in `Colorize` representing failure. failure: :red,
FAILURE_COLOR = :red error: :magenta,
pending: :yellow,
# Symbol in `Colorize` representing an error. comment: :cyan,
ERROR_COLOR = :magenta }
# Symbol in `Colorize` representing pending or skipped.
PENDING_COLOR = :yellow
# Symbol in `Colorize` representing a comment in output.
COMMENT_COLOR = :cyan
# Colorizes some text with the success color. # Colorizes some text with the success color.
def success(text) def success(text)
text.colorize(SUCCESS_COLOR) text.colorize(COLORS[:success])
end end
# Colorizes some text with the failure color. # Colorizes some text with the failure color.
def failure(text) def failure(text)
text.colorize(FAILURE_COLOR) text.colorize(COLORS[:failure])
end end
# Colorizes some text with the error color. # Colorizes some text with the error color.
def error(text) def error(text)
text.colorize(ERROR_COLOR) text.colorize(COLORS[:error])
end end
# Colorizes some text with the pending/skipped color. # Colorizes some text with the pending/skipped color.
def pending(text) def pending(text)
text.colorize(PENDING_COLOR) text.colorize(COLORS[:pending])
end end
# Colorizes some text with the comment color. # Colorizes some text with the comment color.
def comment(text) def comment(text)
text.colorize(COMMENT_COLOR) text.colorize(COLORS[:comment])
end end
end end
end end