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

nested pry, seems to create an anonymous object e.g pry (wait for new repl) then pry -- self changes!. Also exit_program seems broken!

This commit is contained in:
John Mair 2010-12-15 17:56:06 +13:00
parent 1471507b3a
commit a31d9e31c1
2 changed files with 20 additions and 15 deletions

View file

@ -106,6 +106,8 @@ class Pry
target = binding_for(target)
Pry.last_result = target.eval r(target)
target.eval("_ = Pry.last_result")
rescue SystemExit => e
exit
rescue Exception => e
e
end
@ -153,17 +155,15 @@ class Pry
obj = $~.captures.first
target.eval("#{obj}.pry")
eval_string.clear
when /^show_method\s*(\w*)/
when /^show_method\s*(.+)/
meth_name = ($~.captures).first
file, line = target.eval("method(:#{meth_name}).source_location")
tp = Pry.new.tap { |v| v.input = SourceInput.new(file, line) }
output.show_method tp.r
code = get_method_source(target, meth_name, :method)
output.show_method code
eval_string.clear
when /^show_instance_method\s*(\w*)/
when /^show_instance_method\s*(.+)/
meth_name = ($~.captures).first
file, line = target.eval("instance_method(:#{meth_name}).source_location")
tp = Pry.new.tap { |v| v.input = SourceInput.new(file, line) }
output.show_method tp.r
code = get_method_source(target, meth_name, :instance_method)
output.show_method code
eval_string.clear
when /^jump_to\s*(\d*)/
break_level = ($~.captures).first.to_i
@ -183,6 +183,11 @@ class Pry
end
end
def get_method_source(target, meth_name, kind)
file, line = target.eval("#{kind}(:#{meth_name}).source_location")
Pry.new.tap { |v| v.input = SourceInput.new(file, line) }.r
end
def prompt(eval_string, target, nest)
target_self = target.eval('self')
@ -198,14 +203,12 @@ class Pry
begin
test_bed.eval(code)
rescue Exception => e
case e
when SyntaxError
rescue SyntaxError => e
case e.message
when /(parse|syntax) error.*?\$end/i, /unterminated/i
return false
end
end
rescue Exception
end
true
end

View file

@ -2,6 +2,8 @@ require 'readline'
class Pry
class Input
trap('INT') { exit }
def read(prompt)
Readline.readline(prompt, true)
end