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

replaced explicit '(pry)' string with Pry.eval_path method

This commit is contained in:
John Mair 2011-05-25 12:48:53 +12:00
parent fc31a44fda
commit d593294bfe
3 changed files with 8 additions and 3 deletions

View file

@ -43,7 +43,7 @@ class Pry
def check_for_dynamically_defined_method(meth)
file, _ = meth.source_location
if file =~ /(\(.*\))|<.*>/ && file != "(pry)"
if file =~ /(\(.*\))|<.*>/ && file != Pry.eval_path
raise "Cannot retrieve source for dynamically defined method."
end
end
@ -61,7 +61,7 @@ class Pry
code = Pry::MethodInfo.info_for(meth).source
code = strip_comments_from_c_code(code)
when :ruby
if meth.source_location.first == "(pry)"
if meth.source_location.first == Pry.eval_path
start_line = meth.source_location.last
p = Pry.new(:input => StringIO.new(Pry.line_buffer[start_line..-1].join)).r(target)

View file

@ -122,6 +122,10 @@ class Pry
# @return [Array] The Array of evaluated expressions.
attr_accessor :line_buffer
# @return [String] The __FILE__ for the `eval()`. Should be "(pry)"
# by default.
attr_accessor :eval_path
# plugin forwardables
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
@ -255,6 +259,7 @@ class Pry
@cli = false
@current_line = 0
@line_buffer = []
@eval_path = "(pry)"
end
# Basic initialization.

View file

@ -187,7 +187,7 @@ class Pry
expr = r(target)
Pry.line_buffer.push(*expr.each_line)
set_last_result(target.eval(expr, "(pry)", Pry.current_line), target)
set_last_result(target.eval(expr, Pry.eval_path, Pry.current_line), target)
rescue SystemExit => e
exit
rescue Exception => e