blob: 34a222d22537bf3166eb03442101d5716bc0522b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# frozen_string_literal: true
class Pry
class Output
attr_reader :pry_instance
def initialize(pry_instance)
@pry_instance = pry_instance
@output = pry_instance.config.output
end
def puts(*objs)
return print "\n" if objs.empty?
objs.each do |obj|
if (ary = Array.try_convert(obj))
puts(*ary)
else
print "#{obj.to_s.chomp}\n"
end
end
nil
end
def print(*objs)
objs.each do |obj|
@output.print decolorize_maybe(obj.to_s)
end
nil
end
alias << print
alias write print
def tty?
@output.respond_to?(:tty?) && @output.tty?
end
def method_missing(method_name, *args, &block)
if @output.respond_to?(method_name)
@output.__send__(method_name, *args, &block)
else
super
end
end
def respond_to_missing?(method_name, include_private = false)
@output.respond_to?(method_name, include_private)
end
def decolorize_maybe(str)
if pry_instance.config.color
str
else
Pry::Helpers::Text.strip_color str
end
end
end
end
|