diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-15 02:39:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-15 02:39:06 +0000 |
commit | 25513ed45f06127dd5c89efc6c0aeb288e24cd7c (patch) | |
tree | 01b98f339375c255bed445ebdab216287f004420 /tool | |
parent | 9536078d45d7da2c9af85a6acbd74ffe81af7d5c (diff) | |
download | ruby-25513ed45f06127dd5c89efc6c0aeb288e24cd7c.tar.gz |
make-snapshot: colorize [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r-- | tool/colorize.rb | 22 | ||||
-rwxr-xr-x | tool/make-snapshot | 32 |
2 files changed, 33 insertions, 21 deletions
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 <<USAGE @@ -262,7 +264,17 @@ def package(vcs, rev, destdir, tmp = nil) end system(*%W"patch -d #{v} -p0 -i #{$patch_file}") if $patch_file if !$exported or $patch_file - "take a breath, and go ahead".scan(/./) {|c|print c; sleep(c == "," ? 0.7 : 0.05)}; puts + colors = %w[red yellow green cyan blue magenta] + "take a breath, and go ahead".scan(/./) do |c| + if c == ' ' + print c + else + colors.push(color = colors.shift) + print $colorize.decorate(c, color) + end + sleep(c == "," ? 0.7 : 0.05) + end + puts end def (clean = []).add(n) push(n); n end Dir.chdir(v) do @@ -277,10 +289,10 @@ def package(vcs, rev, destdir, tmp = nil) unless File.exist?("configure") print "creating configure..." unless system([ENV["AUTOCONF"]]*2) - puts " failed" + puts $colorize.fail(" failed") return end - puts " done" + puts $colorize.pass(" done") end clean.add("autom4te.cache") clean.add("enc/unicode/data") @@ -354,10 +366,10 @@ update-gems: FileUtils.rm_rf("gems") end unless $?.success? - puts " failed" + puts $colorize.fail(" failed") return end - puts " done" + puts $colorize.pass(" done") end if v == "." @@ -381,9 +393,9 @@ update-gems: tarball = "#{$archname||v}.tar" print "creating tarball... #{tarball}" if system("tar", "cf", tarball, v) - puts " done" + puts $colorize.pass(" done") else - puts " failed" + puts $colorize.fail(" failed") tarball = "" next end @@ -401,10 +413,10 @@ update-gems: done = system(*cmd) end if done - puts " done" + puts $colorize.pass(" done") file else - puts " failed" + puts $colorize.fail(" failed") nil end end.compact @@ -432,7 +444,7 @@ revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name| next end str = open(name, "rb") {|f| f.read} - puts "* #{name}" + puts "* #{$colorize.pass(name)}" puts " SIZE: #{str.bytesize} bytes" $digests.each do |alg| printf " %-8s%s\n", "#{alg}:", Digest.const_get(alg).hexdigest(str) |