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

make whereami N work, fixes #537

This commit is contained in:
John Mair 2012-04-18 18:49:00 +12:00
parent 14b7eb5c65
commit 4d2ed095c4
3 changed files with 7 additions and 8 deletions

View file

@ -15,7 +15,7 @@ class Pry
# /unknown/ for rbx
if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e" || file == Pry.eval_path
_pry_.run_command("whereami 5", "", target)
_pry_.run_command("whereami", "", target)
end
end

View file

@ -135,7 +135,6 @@ class Pry
# @return [Code]
def from_module(mod, start_line=nil)
mod = Pry::WrappedModule(mod)
start_line ||= mod.source_line || 1
new(mod.source, start_line, :ruby)
end

View file

@ -28,13 +28,13 @@ class Pry
marker = target.eval("__LINE__")
else
file = target.eval("__FILE__")
start = target.eval("__LINE__")
start = target.eval("__LINE__")
finish = (args.first && args.first.to_i) || 5
marker = start
end
if invalid_file?(file)
raise Pry::CommandError,
raise Pry::CommandError,
"Cannot find local context. Did you use binding.pry?"
end
@ -48,20 +48,20 @@ class Pry
desc = (@method && @method.name_with_owner) || ""
if !code.empty?
output.puts "\n#{text.bold('From:')} #{file} @ line #{start}#{desc}:\n\n"
output.puts "\n#{text.bold('From:')} #{file} @ line #{start} #{desc}:\n\n"
output.puts code.with_line_numbers.with_marker(marker)
output.puts
end
end
private
private
def show_method?
@method && !@method.instance_of?(Pry::Method::Disowned) && @method.source_range.count < 20
args.empty? && @method && !@method.instance_of?(Pry::Method::Disowned) && @method.source_range.count < 20
end
def invalid_file?(file)
file != Pry.eval_path &&
file != Pry.eval_path &&
(file =~ /(\(.*\))|<.*>/ || file == "" || file == "-e")
end
end