Skip to content

Commit 5345813

Browse files
authored
Merge pull request #306 from voxik/ruby-3-compat
Ruby 3 compat
2 parents 167c240 + 006f739 commit 5345813

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/web_console/evaluator.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ def initialize(binding = TOPLEVEL_BINDING)
1919
end
2020

2121
def eval(input)
22-
"=> #{@binding.eval(input).inspect}\n"
22+
# Binding#source_location is available since Ruby 2.6.
23+
if @binding.respond_to? :source_location
24+
"=> #{@binding.eval(input, *@binding.source_location).inspect}\n"
25+
else
26+
"=> #{@binding.eval(input).inspect}\n"
27+
end
2328
rescue Exception => exc
2429
format_exception(exc)
2530
end

test/web_console/session_test.rb

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def eval(string)
5151
end
5252
end
5353

54+
def source_location
55+
end
56+
5457
self
5558
end
5659

0 commit comments

Comments
 (0)