mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
1f87725cae
http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210119T070008Z.log.html.gz is caused by: /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline/ansi.rb:157:in `winsize': Invalid argument - <STDIN> (Errno::EINVAL) from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline/ansi.rb:157:in `get_screen_size' from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline.rb:168:in `get_screen_size' from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/forwardable.rb:238:in `get_screen_size' from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/irb/color_printer.rb:7:in `pp' from -e:1:in `<main>' https://github.com/ruby/irb/commit/1719514598
38 lines
799 B
Ruby
38 lines
799 B
Ruby
# frozen_string_literal: true
|
|
require 'pp'
|
|
require 'irb/color'
|
|
|
|
module IRB
|
|
class ColorPrinter < ::PP
|
|
class << self
|
|
def pp(obj, out = $>, width = screen_width)
|
|
q = ColorPrinter.new(out, width)
|
|
q.guard_inspect_key {q.pp obj}
|
|
q.flush
|
|
out << "\n"
|
|
end
|
|
|
|
private
|
|
|
|
def screen_width
|
|
Reline.get_screen_size.last
|
|
rescue Errno::EINVAL # in `winsize': Invalid argument - <STDIN>
|
|
79
|
|
end
|
|
end
|
|
|
|
def text(str, width = nil)
|
|
unless str.is_a?(String)
|
|
str = str.inspect
|
|
end
|
|
width ||= str.length
|
|
|
|
case str
|
|
when /\A#</, '=', '>'
|
|
super(Color.colorize(str, [:GREEN]), width)
|
|
else
|
|
super(Color.colorize_code(str, ignore_error: true), width)
|
|
end
|
|
end
|
|
end
|
|
end
|