From 25513ed45f06127dd5c89efc6c0aeb288e24cd7c 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 +++++++++++----------- tool/make-snapshot | 32 ++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 21 deletions(-) (limited to 'tool') 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 diff --git a/tool/make-snapshot b/tool/make-snapshot index affc412fb7..d628004dea 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -7,6 +7,7 @@ require 'fileutils' require 'shellwords' require 'tmpdir' require File.expand_path("../vcs", __FILE__) +require File.expand_path("../colorize", __FILE__) STDOUT.sync = true $srcdir ||= nil @@ -18,6 +19,7 @@ $packages ||= nil $digests ||= nil $tooldir = File.expand_path("..", __FILE__) $unicode_version = nil if ($unicode_version ||= nil) == "" +$colorize = Colorize.new def usage <