2010-12-13 07:33:05 -05:00
|
|
|
class Pry
|
2010-12-08 19:59:30 -05:00
|
|
|
class Output
|
|
|
|
def refresh
|
|
|
|
puts "Refreshed REPL"
|
|
|
|
end
|
|
|
|
|
|
|
|
def session_start(obj)
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "Beginning Pry session for #{Pry.view(obj)}"
|
2010-12-08 19:59:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def session_end(obj)
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "Ending Pry session for #{Pry.view(obj)}"
|
2010-12-08 19:59:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# the print component of READ-EVAL-PRINT-LOOP
|
|
|
|
def print(value)
|
|
|
|
case value
|
|
|
|
when Exception
|
|
|
|
puts "#{value.class}: #{value.message}"
|
|
|
|
else
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "=> #{Pry.view(value)}"
|
2010-12-08 19:59:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-12-11 04:01:47 -05:00
|
|
|
def show_help
|
|
|
|
puts "Command list:"
|
|
|
|
puts "--"
|
|
|
|
puts "help This menu"
|
|
|
|
puts "status Show status information"
|
|
|
|
puts "! Refresh the REPL"
|
|
|
|
puts "nesting Show nesting information"
|
2010-12-16 23:56:50 -05:00
|
|
|
puts "ls Show the list of variables in the current scope"
|
|
|
|
puts "cd <var> Start a Pry session on <var> (use `cd ..` to go back)"
|
|
|
|
puts "show_method <methname> Show the sourcecode for the method <method_name>"
|
|
|
|
puts "show_instance_method <methname> Show the sourcecode for the instance method <method_name>"
|
2010-12-11 04:01:47 -05:00
|
|
|
puts "exit/quit/back End the current Pry session"
|
|
|
|
puts "exit_all End all nested Pry sessions"
|
|
|
|
puts "exit_program/quit_program End the current program"
|
2010-12-11 04:20:51 -05:00
|
|
|
puts "jump_to <level> Jump to a Pry session further up the stack, exiting all sessions below"
|
2010-12-11 04:01:47 -05:00
|
|
|
end
|
|
|
|
|
2010-12-08 19:59:30 -05:00
|
|
|
def show_nesting(nesting)
|
|
|
|
puts "Nesting status:"
|
2010-12-11 04:01:47 -05:00
|
|
|
puts "--"
|
2010-12-08 19:59:30 -05:00
|
|
|
nesting.each do |level, obj|
|
|
|
|
if level == 0
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "#{level}. #{Pry.view(obj)} (Pry top level)"
|
2010-12-08 19:59:30 -05:00
|
|
|
else
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "#{level}. #{Pry.view(obj)}"
|
2010-12-08 19:59:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-12-11 04:01:47 -05:00
|
|
|
def show_status(nesting, target)
|
|
|
|
puts "Status:"
|
|
|
|
puts "--"
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "Receiver: #{Pry.view(target.eval('self'))}"
|
2010-12-11 04:01:47 -05:00
|
|
|
puts "Nesting level: #{nesting.level}"
|
2010-12-16 23:56:50 -05:00
|
|
|
puts "Local variables: #{target.eval('Pry.view(local_variables)')}"
|
2010-12-14 05:54:26 -05:00
|
|
|
puts "Last result: #{Pry.view(Pry.last_result)}"
|
2010-12-11 04:01:47 -05:00
|
|
|
end
|
|
|
|
|
2010-12-16 23:56:50 -05:00
|
|
|
def ls(target)
|
|
|
|
puts "#{target.eval('Pry.view(local_variables + instance_variables)')}"
|
|
|
|
end
|
|
|
|
|
2010-12-14 21:21:13 -05:00
|
|
|
def show_method(code)
|
|
|
|
code.display
|
|
|
|
end
|
|
|
|
|
2010-12-11 16:53:14 -05:00
|
|
|
def warn_already_at_level(nesting_level)
|
|
|
|
puts "Already at nesting level #{nesting_level}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def err_invalid_nest_level(nest_level, max_nest_level)
|
2010-12-08 19:59:30 -05:00
|
|
|
puts "Invalid nest level. Must be between 0 and #{max_nest_level}. Got #{nest_level}."
|
|
|
|
end
|
|
|
|
|
|
|
|
def exit() end
|
2010-12-11 04:01:47 -05:00
|
|
|
def jump_to(nesting_level_breakout) end
|
2010-12-08 19:59:30 -05:00
|
|
|
def exit_program() end
|
|
|
|
end
|
|
|
|
end
|