-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maintain optional support for older rubies
- Loading branch information
1 parent
75eabad
commit 53ec648
Showing
2 changed files
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
|
||
if binding.respond_to?(:source_location) | ||
raise 'source_location exists by default in Ruby 2.6 and greater, no need to required it manually' | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters