From 24fe5d078fd78d78dadf955ef8fcd9ba7fc81572 Mon Sep 17 00:00:00 2001 From: Valeriy Mironov Date: Wed, 22 May 2024 11:51:03 +0100 Subject: [PATCH 1/2] Added support for irb 1.13+ --- lib/console1984/ext/irb/context.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/console1984/ext/irb/context.rb b/lib/console1984/ext/irb/context.rb index 21e465c..cfe25fa 100644 --- a/lib/console1984/ext/irb/context.rb +++ b/lib/console1984/ext/irb/context.rb @@ -12,8 +12,16 @@ def inspect_last_value end # - def evaluate(line, ...) - Console1984.command_executor.execute(Array(line)) do + def evaluate(line_or_statement, ...) + # irb < 1.13 passes String as parameter + # irb >= 1.13 passes IRB::Statement instead and method #code contains the actual code + code = if defined?(IRB::Statement) && line_or_statement.kind_of?(IRB::Statement) + line_or_statement.code + else + line_or_statement + end + + Console1984.command_executor.execute(Array(code)) do super end end From 0076ab382bfe8ec1ecc07818cf1112dd0066bd11 Mon Sep 17 00:00:00 2001 From: Valeriy Mironov Date: Wed, 22 May 2024 13:15:26 +0100 Subject: [PATCH 2/2] Fixed rubocop warnings --- lib/console1984/ext/irb/context.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/console1984/ext/irb/context.rb b/lib/console1984/ext/irb/context.rb index cfe25fa..c7856cb 100644 --- a/lib/console1984/ext/irb/context.rb +++ b/lib/console1984/ext/irb/context.rb @@ -16,10 +16,10 @@ def evaluate(line_or_statement, ...) # irb < 1.13 passes String as parameter # irb >= 1.13 passes IRB::Statement instead and method #code contains the actual code code = if defined?(IRB::Statement) && line_or_statement.kind_of?(IRB::Statement) - line_or_statement.code - else - line_or_statement - end + line_or_statement.code + else + line_or_statement + end Console1984.command_executor.execute(Array(code)) do super