Skip to content

Commit

Permalink
make whereami N work, fixes #537
Browse files Browse the repository at this point in the history
  • Loading branch information
banister committed Apr 18, 2012
1 parent 14b7eb5 commit 4d2ed09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/pry.rb
Expand Up @@ -15,7 +15,7 @@ class Pry


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


Expand Down
1 change: 0 additions & 1 deletion lib/pry/code.rb
Expand Up @@ -135,7 +135,6 @@ def from_method(meth, start_line=nil)
# @return [Code] # @return [Code]
def from_module(mod, start_line=nil) def from_module(mod, start_line=nil)
mod = Pry::WrappedModule(mod) mod = Pry::WrappedModule(mod)

start_line ||= mod.source_line || 1 start_line ||= mod.source_line || 1
new(mod.source, start_line, :ruby) new(mod.source, start_line, :ruby)
end end
Expand Down
12 changes: 6 additions & 6 deletions lib/pry/default_commands/context.rb
Expand Up @@ -28,13 +28,13 @@ def process
marker = target.eval("__LINE__") marker = target.eval("__LINE__")
else else
file = target.eval("__FILE__") file = target.eval("__FILE__")
start = target.eval("__LINE__") start = target.eval("__LINE__")
finish = (args.first && args.first.to_i) || 5 finish = (args.first && args.first.to_i) || 5
marker = start marker = start
end end


if invalid_file?(file) if invalid_file?(file)
raise Pry::CommandError, raise Pry::CommandError,
"Cannot find local context. Did you use binding.pry?" "Cannot find local context. Did you use binding.pry?"
end end


Expand All @@ -48,20 +48,20 @@ def process
desc = (@method && @method.name_with_owner) || "" desc = (@method && @method.name_with_owner) || ""


if !code.empty? 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 code.with_line_numbers.with_marker(marker)
output.puts output.puts
end end
end end


private private


def show_method? 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 end


def invalid_file?(file) def invalid_file?(file)
file != Pry.eval_path && file != Pry.eval_path &&
(file =~ /(\(.*\))|<.*>/ || file == "" || file == "-e") (file =~ /(\(.*\))|<.*>/ || file == "" || file == "-e")
end end
end end
Expand Down

0 comments on commit 4d2ed09

Please sign in to comment.