From 20b7d049527af793590139729b959a28646c5703 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Sat, 9 Mar 2019 02:01:49 +0200 Subject: [PATCH] Move Pry::SIMPLE_PRINT and CLIPPED_PRINT to Inspector We use these procs only inside Inspector, so let's define them there. --- lib/pry.rb | 15 --------------- lib/pry/inspector.rb | 12 ++++++++++-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/pry.rb b/lib/pry.rb index 87f69a29..31a0252c 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -6,21 +6,6 @@ require 'pry/helpers/base_helpers' require 'pry/hooks' class Pry - # may be convenient when working with enormous objects and - # pretty_print is too slow - SIMPLE_PRINT = proc do |output, value| - begin - output.puts value.inspect - rescue RescuableException - output.puts "unknown" - end - end - - # useful when playing with truly enormous objects - CLIPPED_PRINT = proc do |output, value| - output.puts Pry.view_clip(value, id: true) - end - # Will only show the first line of the backtrace DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _| if UserError === exception && SyntaxError === exception diff --git a/lib/pry/inspector.rb b/lib/pry/inspector.rb index ce8394d8..afe58690 100644 --- a/lib/pry/inspector.rb +++ b/lib/pry/inspector.rb @@ -10,7 +10,13 @@ class Pry }, "simple" => { - value: Pry::SIMPLE_PRINT, + value: proc do |output, value| + begin + output.puts value.inspect + rescue RescuableException + output.puts "unknown" + end + end, description: <<-DESCRIPTION.each_line.map(&:lstrip) A simple inspector that uses #puts and #inspect when printing an object. It has no pager, color, or pretty_inspect support. @@ -18,7 +24,9 @@ class Pry }, "clipped" => { - value: Pry::CLIPPED_PRINT, + value: proc do |output, value| + output.puts Pry.view_clip(value, id: true) + end, description: <<-DESCRIPTION.each_line.map(&:lstrip) The clipped inspector has the same features as the 'simple' inspector but prints large objects as a smaller string.