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

View file

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