From cb2f8c08f66ac5e164446d4f6ffa1e063bb85dff Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Mon, 5 May 2014 00:39:31 -0700 Subject: [PATCH] Fix behavior of `Pry::Output#puts` This implementation of puts didn't behave correctly in the presence of multiple arguments or arguments that are Arrays. I changed it to match the documented behavior of IO#puts, but we might still be missing some subtleties. --- lib/pry/output.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pry/output.rb b/lib/pry/output.rb index a4cf8484..f8d382cf 100644 --- a/lib/pry/output.rb +++ b/lib/pry/output.rb @@ -1,4 +1,3 @@ - class Pry class Output attr_reader :_pry_ @@ -7,8 +6,16 @@ class Pry @_pry_ = _pry_ end - def puts(str) - print "#{str.chomp}\n" + def puts(*objs) + return print "\n" if objs.empty? + + objs.each do |obj| + if obj.is_a?(Array) + puts(*obj) + else + print "#{obj.to_s.chomp}\n" + end + end end def print(str)