From d25ed18c3defab09e71318baca5037541728c877 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 15 Jun 2017 02:39:06 +0000 Subject: make-snapshot: colorize [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/colorize.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tool/colorize.rb') diff --git a/tool/colorize.rb b/tool/colorize.rb index 6b9f568020..b840238e52 100644 --- a/tool/colorize.rb +++ b/tool/colorize.rb @@ -1,3 +1,5 @@ +# frozen-string-literal: true + class Colorize def initialize(color = nil) @colors = @reset = nil @@ -11,7 +13,11 @@ class Colorize self end - DEFAULTS = {"pass"=>"32;1", "fail"=>"31;1", "skip"=>"33;1"} + DEFAULTS = { + "pass"=>"32;1", "fail"=>"31;1", "skip"=>"33;1", + "black"=>"30", "red"=>"31", "green"=>"32", "yellow"=>"33", + "blue"=>"34", "magenta"=>"35", "cyan"=>"36", "white"=>"37", + } def decorate(str, name) if @colors and color = (@colors[name] || DEFAULTS[name]) @@ -21,16 +27,10 @@ class Colorize end end - def pass(str) - decorate(str, "pass") - end - - def fail(str) - decorate(str, "fail") - end - - def skip(str) - decorate(str, "skip") + DEFAULTS.each_key do |name| + define_method(name) {|str| + decorate(str, name) + } end end -- cgit v1.2.3