Skip to content

Commit

Permalink
Merge pull request #306 from voxik/ruby-3-compat
Browse files Browse the repository at this point in the history
Ruby 3 compat
  • Loading branch information
gsamokovarov authored Jan 5, 2021
2 parents 167c240 + 006f739 commit 5345813
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/web_console/evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ def initialize(binding = TOPLEVEL_BINDING)
end

def eval(input)
"=> #{@binding.eval(input).inspect}\n"
# Binding#source_location is available since Ruby 2.6.
if @binding.respond_to? :source_location
"=> #{@binding.eval(input, *@binding.source_location).inspect}\n"
else
"=> #{@binding.eval(input).inspect}\n"
end
rescue Exception => exc
format_exception(exc)
end
Expand Down
3 changes: 3 additions & 0 deletions test/web_console/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def eval(string)
end
end

def source_location
end

self
end

Expand Down

0 comments on commit 5345813

Please sign in to comment.