From a442495b1d9c1e07789cab7ed1f041f82be7741e Mon Sep 17 00:00:00 2001 From: Ali Ismayilov Date: Fri, 3 Apr 2020 11:28:48 +0200 Subject: [PATCH] Fix ruby 2.7 warning > warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead --- lib/pry-nav.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pry-nav.rb b/lib/pry-nav.rb index 341fed1..25185ce 100644 --- a/lib/pry-nav.rb +++ b/lib/pry-nav.rb @@ -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