From be67273e33c1ec23c6067f594350e9233ed9959e Mon Sep 17 00:00:00 2001 From: John Mair Date: Thu, 9 Jun 2011 02:49:35 +1200 Subject: [PATCH] pretty_inspect (colored with CodeRay) is now the default inspect output --- lib/pry.rb | 4 +++- lib/pry/pry_class.rb | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pry.rb b/lib/pry.rb index 37fe005a..9970b281 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -1,6 +1,8 @@ # (C) John Mair (banisterfiend) 2011 # MIT License +require 'pp' + class Pry # The default hooks - display messages when beginning and ending Pry sessions. DEFAULT_HOOKS = { @@ -19,7 +21,7 @@ class Pry # The default prints DEFAULT_PRINT = proc do |output, value| if Pry.color - output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}" + output.puts "=> #{CodeRay.scan(value.pretty_inspect, :ruby).term}" else output.puts "=> #{Pry.view(value)}" end diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 75c9062e..526ae79c 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -105,12 +105,12 @@ class Pry new(options).repl(target) end - # A custom version of `Kernel#inspect`. + # A custom version of `Kernel#pretty_inspect`. # This method should not need to be accessed directly. # @param obj The object to view. # @return [String] The string representation of `obj`. def self.view(obj) - obj.inspect + obj.pretty_inspect rescue NoMethodError "unknown" @@ -122,8 +122,8 @@ class Pry # @param max_size The maximum number of chars before clipping occurs. # @return [String] The string representation of `obj`. def self.view_clip(obj, max_size=60) - if Pry.view(obj).size < max_size - Pry.view(obj) + if obj.inspect.size < max_size + obj.inspect else "#<#{obj.class}:%#x>" % (obj.object_id << 1) end