зеркало из https://github.com/github/ruby.git
make-snapshot: colorize [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
95797e13d4
Коммит
d25ed18c3d
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче