Skip to content

Commit

Permalink
Fix ruby 2.7 warning
Browse files Browse the repository at this point in the history
> warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
  • Loading branch information
aliismayilov authored and iloveitaly committed Jul 13, 2021
1 parent d421f76 commit a442495
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pry-nav.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ module PryNav
# Checks that a binding is in a local file context. Extracted from
# https://github.com/pry/pry/blob/master/lib/pry/default_commands/context.rb
def check_file_context(target)
file = target.eval('__FILE__')
file = if target.respond_to?(:source_location)
target.source_location.first
else
target.eval('__FILE__')
end

file == Pry.eval_path || (file !~ /(\(.*\))|<.*>/ && file != '' && file != '-e')
end

Expand Down

0 comments on commit a442495

Please sign in to comment.