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:
parent
19db442263
commit
20b7d04952
2 changed files with 10 additions and 17 deletions
15
lib/pry.rb
15
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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue