mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Revert "Make whereami more consistent (and less cheeky) [Fixes #383]"
This reverts commit f937bb6097
.
This commit is contained in:
parent
f937bb6097
commit
a6c4c6950d
3 changed files with 11 additions and 16 deletions
|
@ -21,15 +21,14 @@ class Pry
|
|||
BANNER
|
||||
|
||||
def setup
|
||||
@method = Pry::Method.from_binding(target)
|
||||
if internal_binding?(target)
|
||||
location = _pry_.backtrace.detect do |x|
|
||||
!x.start_with?(File.expand_path('../../../../lib', __FILE__))
|
||||
end
|
||||
@method = nil
|
||||
@file = location.split(":").first
|
||||
@line = location.split(":")[1].to_i
|
||||
else
|
||||
@method = Pry::Method.from_binding(target)
|
||||
@file = target.eval('__FILE__')
|
||||
@line = target.eval('__LINE__')
|
||||
end
|
||||
|
@ -52,11 +51,13 @@ class Pry
|
|||
end
|
||||
|
||||
def process
|
||||
if opts.quiet? && (at_top_level? || !code?)
|
||||
return
|
||||
elsif at_top_level?
|
||||
output.puts "At the top level."
|
||||
if opts.quiet? && (internal_binding?(target) || !code?)
|
||||
return
|
||||
elsif internal_binding?(target)
|
||||
if @file.end_with?("bin/pry")
|
||||
output.puts "At the top level."
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
set_file_and_dir_locals(@file)
|
||||
|
@ -68,10 +69,6 @@ class Pry
|
|||
|
||||
private
|
||||
|
||||
def at_top_level?
|
||||
@file.end_with?("bin/pry")
|
||||
end
|
||||
|
||||
def show_method?
|
||||
args.empty? && @method && @method.source? && @method.source_range.count < 20 &&
|
||||
# These checks are needed in case of an eval with a binding and file/line
|
||||
|
|
|
@ -128,15 +128,15 @@ describe "whereami" do
|
|||
end
|
||||
|
||||
it "should work at the top level" do
|
||||
pry_eval(Pry.toplevel_binding, 'whereami', :backtrace => ['bin/pry:5:__foo__']).should =~
|
||||
pry_eval(Pry.toplevel_binding, 'whereami').should =~
|
||||
/At the top level/
|
||||
end
|
||||
|
||||
it "should work inside a class" do
|
||||
pry_eval(Pry, 'whereami', :backtrace => ['spec/fixtures/example.erb:5:__foo__']).should =~ /example.erb/
|
||||
pry_eval(Pry, 'whereami').should =~ /Inside Pry/
|
||||
end
|
||||
|
||||
it "should work inside an object" do
|
||||
pry_eval(Object.new, 'whereami', :backtrace => ['spec/fixtures/example.erb:5:bar']).should =~ /example.erb/
|
||||
pry_eval(Object.new, 'whereami').should =~ /Inside #<Object/
|
||||
end
|
||||
end
|
||||
|
|
|
@ -259,14 +259,13 @@ def pry_tester(*args, &block)
|
|||
end
|
||||
|
||||
def pry_eval(*eval_strs)
|
||||
opts = eval_strs.last.is_a?(Hash) ? eval_strs.pop : {}
|
||||
if eval_strs.first.is_a? String
|
||||
binding = Pry.toplevel_binding
|
||||
else
|
||||
binding = Pry.binding_for(eval_strs.shift)
|
||||
end
|
||||
|
||||
pry_tester(binding, opts).eval(*eval_strs)
|
||||
pry_tester(binding).eval(*eval_strs)
|
||||
end
|
||||
|
||||
class PryTester
|
||||
|
@ -274,7 +273,6 @@ class PryTester
|
|||
|
||||
def initialize(context = TOPLEVEL_BINDING, options = {})
|
||||
@pry = Pry.new(options)
|
||||
@pry.backtrace = options[:backtrace]
|
||||
|
||||
if context
|
||||
target = Pry.binding_for(context)
|
||||
|
|
Loading…
Add table
Reference in a new issue