mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
colorize.rb: fix reading from test/colors
[ci skip]
This commit is contained in:
parent
16cb1fb007
commit
b0c35ff2db
1 changed files with 3 additions and 2 deletions
|
@ -6,13 +6,14 @@ class Colorize
|
||||||
if color or (color == nil && STDOUT.tty?)
|
if color or (color == nil && STDOUT.tty?)
|
||||||
if (/\A\e\[.*m\z/ =~ IO.popen("tput smso", "r", err: IO::NULL, &:read) rescue nil)
|
if (/\A\e\[.*m\z/ =~ IO.popen("tput smso", "r", err: IO::NULL, &:read) rescue nil)
|
||||||
@beg = "\e["
|
@beg = "\e["
|
||||||
@colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
||||||
begin
|
begin
|
||||||
File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
|
File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
|
||||||
colors[n] ||= c
|
colors[n] ||= c
|
||||||
end
|
end
|
||||||
rescue
|
rescue Errno::ENOENT
|
||||||
end
|
end
|
||||||
|
@colors = colors
|
||||||
@reset = "#{@beg}m"
|
@reset = "#{@beg}m"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue