Skip to content

Commit

Permalink
maintain optional support for older rubies
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonewall committed Aug 20, 2022
1 parent 75eabad commit a01bf7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/pry-rescue/source_location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
else
class PryRescue
module SourceLocation
DEPRECATION_TIME = Time.new(2021,4,1)

WithRuby2_5 = ->(b){ [b.eval("__FILE__"), b.eval("__LINE__")] }
def self.call(b)
[b.eval("__FILE__"), b.eval("__LINE__")]
end
end
end

Binding.define_method(:source_location, &PryRescue::SourceLocation::WithRuby2_5)
Binding.define_method :source_location do
PryRescue::SourceLocation.call(self)
end
end
2 changes: 2 additions & 0 deletions spec/source_location_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
describe 'PryRescue::SourceLocation' do
if RUBY_VERSION < "2.6.0"
require 'pry-rescue/source_location'

subject { binding.source_location }

it 'matches [file, line]' do
Expand Down

0 comments on commit a01bf7d

Please sign in to comment.