2015-08-22 10:11:20 -04:00
|
|
|
class Pry::Output
|
|
|
|
attr_reader :_pry_
|
2014-05-01 04:39:12 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
def initialize(_pry_)
|
|
|
|
@_pry_ = _pry_
|
|
|
|
@boxed_io = _pry_.config.output
|
|
|
|
end
|
2014-05-05 03:39:31 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
def puts(*objs)
|
|
|
|
return print "\n" if objs.empty?
|
2018-10-14 09:44:58 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
objs.each do |obj|
|
2018-10-20 17:52:22 -04:00
|
|
|
if (ary = Array.try_convert(obj))
|
2015-08-22 10:11:20 -04:00
|
|
|
puts(*ary)
|
|
|
|
else
|
|
|
|
print "#{obj.to_s.chomp}\n"
|
2014-05-05 03:39:31 -04:00
|
|
|
end
|
2014-05-01 04:10:10 -04:00
|
|
|
end
|
2015-08-22 10:11:20 -04:00
|
|
|
nil
|
|
|
|
end
|
2014-05-01 04:10:10 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
def print(*objs)
|
|
|
|
objs.each do |obj|
|
|
|
|
@boxed_io.print decolorize_maybe(obj.to_s)
|
2014-05-01 04:39:12 -04:00
|
|
|
end
|
2015-08-22 10:11:20 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
alias << print
|
|
|
|
alias write print
|
2014-05-01 04:39:12 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
def tty?
|
2018-11-17 11:22:56 -05:00
|
|
|
@boxed_io.respond_to?(:tty?) && @boxed_io.tty?
|
2015-08-22 10:11:20 -04:00
|
|
|
end
|
2014-05-01 04:10:10 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
def method_missing(name, *args, &block)
|
|
|
|
@boxed_io.__send__(name, *args, &block)
|
|
|
|
end
|
|
|
|
|
2018-11-04 04:34:24 -05:00
|
|
|
def respond_to_missing?(m, include_all = false)
|
2017-05-27 13:40:19 -04:00
|
|
|
@boxed_io.respond_to?(m, include_all)
|
2015-08-22 10:11:20 -04:00
|
|
|
end
|
2014-05-01 04:10:10 -04:00
|
|
|
|
2015-08-22 10:11:20 -04:00
|
|
|
def decolorize_maybe(str)
|
|
|
|
if _pry_.config.color
|
|
|
|
str
|
|
|
|
else
|
|
|
|
Pry::Helpers::Text.strip_color str
|
2014-05-01 04:10:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|