1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Move Pry::SIMPLE_PRINT and CLIPPED_PRINT to Inspector

We use these procs only inside Inspector, so let's define them there.
This commit is contained in:
Kyrylo Silin 2019-03-09 02:01:49 +02:00
parent 19db442263
commit 20b7d04952
2 changed files with 10 additions and 17 deletions

View file

@ -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

View file

@ -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.