Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

`whereami -m` is gone in favor of context inference.

Ref #515.
  • Loading branch information...
commit 37377c1c45d965bf14a488db6daf6895312d125e 1 parent d4de593
Rob Gleeson authored
Showing with 8 additions and 10 deletions.
  1. +8 −10 lib/pry/default_commands/context.rb
18 lib/pry/default_commands/context.rb
View
@@ -16,17 +16,15 @@ module DefaultCommands
Usage: whereami [OPTIONS]
BANNER
- def options(opts)
- opts.on :m, 'Show the source code of the current method in context.'
+ def setup
+ @method = Pry::Method.from_binding(target)
end
- def process
- method = Pry::Method.from_binding(target)
-
+ def process
if show_method?
- file = method.source_file
- start = method.source_range.begin
- finish = method.source_range.end - 1
+ file = @method.source_file
+ start = @method.source_range.begin
+ finish = @method.source_range.end - 1
marker = binding.eval("__LINE__")
else
file = target.eval("__FILE__")
@@ -47,7 +45,7 @@ def process
code = Pry::Code.from_file(file).around(start, finish)
end
- desc = (method && method.name_with_owner) || ""
+ desc = (@method && @method.name_with_owner) || ""
if !code.empty?
output.puts "\n#{text.bold('From:')} #{file} @ line #{start}#{desc}:\n\n"
@@ -59,7 +57,7 @@ def process
private
def show_method?
- opts[:m]
+ @method && !@method.instance_of?(Pry::Method::Disowned)
end
def invalid_file?(file)

2 comments on commit 37377c1

John Mair
Owner

This is cool, but what to do in the case the method is enormous? I think there should be a reasonable cutoff for ridiculously large methods (they still exist :P)

Ryan Fitzgerald
Owner

Also, I think the whereami that happens automatically as a hook should probably still use a small window. Using something like pry-nav with this behavior would be really annoying.

Please sign in to comment.
Something went wrong with that request. Please try again.