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