2012-08-11 20:22:29 -04:00
|
|
|
class Pry
|
2012-12-25 16:35:17 -05:00
|
|
|
class Command::Nesting < Pry::ClassCommand
|
|
|
|
match 'nesting'
|
2012-08-11 21:26:59 -04:00
|
|
|
group 'Navigating Pry'
|
2012-12-25 16:35:17 -05:00
|
|
|
description 'Show nesting information.'
|
2012-08-11 21:26:59 -04:00
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
banner <<-'BANNER'
|
|
|
|
Show nesting information.
|
|
|
|
BANNER
|
|
|
|
|
2012-08-11 21:26:59 -04:00
|
|
|
def process
|
2012-12-25 16:35:17 -05:00
|
|
|
output.puts 'Nesting status:'
|
|
|
|
output.puts '--'
|
2012-08-11 21:26:59 -04:00
|
|
|
_pry_.binding_stack.each_with_index do |obj, level|
|
|
|
|
if level == 0
|
|
|
|
output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)"
|
|
|
|
else
|
|
|
|
output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))}"
|
|
|
|
end
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-12-25 16:35:17 -05:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::Nesting)
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|