2014-05-01 04:10:10 -04:00
|
|
|
|
|
|
|
class Pry
|
|
|
|
class Output
|
|
|
|
attr_reader :_pry_
|
2014-05-01 04:39:12 -04:00
|
|
|
|
2014-05-01 04:10:10 -04:00
|
|
|
def initialize(_pry_)
|
|
|
|
@_pry_ = _pry_
|
|
|
|
end
|
|
|
|
|
|
|
|
def puts(str)
|
|
|
|
print "#{str.chomp}\n"
|
|
|
|
end
|
|
|
|
|
2014-05-01 04:39:12 -04:00
|
|
|
def print(str)
|
|
|
|
_pry_.config.output.print decolorize_maybe(str)
|
|
|
|
end
|
|
|
|
alias << print
|
|
|
|
alias write print
|
|
|
|
|
|
|
|
# If _pry_.config.color is currently false, removes ansi escapes from the string.
|
|
|
|
def decolorize_maybe(str)
|
2014-05-01 04:10:10 -04:00
|
|
|
if _pry_.config.color
|
2014-05-01 04:39:12 -04:00
|
|
|
str
|
2014-05-01 04:10:10 -04:00
|
|
|
else
|
2014-05-01 04:39:12 -04:00
|
|
|
Helpers::Text.strip_color str
|
2014-05-01 04:10:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def method_missing(name, *args, &block)
|
|
|
|
_pry_.config.output.send(name, *args, &block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def respond_to_missing?(*a)
|
|
|
|
_pry_.config.respond_to?(*a)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|