mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
pretty_inspect (colored with CodeRay) is now the default inspect output
This commit is contained in:
parent
f23bb4ba8a
commit
be67273e33
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue