Skip to content

Commit a01bf7d

Browse files
committed
maintain optional support for older rubies
1 parent 75eabad commit a01bf7d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/pry-rescue/source_location.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
else
55
class PryRescue
66
module SourceLocation
7-
DEPRECATION_TIME = Time.new(2021,4,1)
8-
9-
WithRuby2_5 = ->(b){ [b.eval("__FILE__"), b.eval("__LINE__")] }
7+
def self.call(b)
8+
[b.eval("__FILE__"), b.eval("__LINE__")]
9+
end
1010
end
1111
end
1212

13-
Binding.define_method(:source_location, &PryRescue::SourceLocation::WithRuby2_5)
13+
Binding.define_method :source_location do
14+
PryRescue::SourceLocation.call(self)
15+
end
1416
end

spec/source_location_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
describe 'PryRescue::SourceLocation' do
22
if RUBY_VERSION < "2.6.0"
3+
require 'pry-rescue/source_location'
4+
35
subject { binding.source_location }
46

57
it 'matches [file, line]' do

0 commit comments

Comments
 (0)