Skip to content

Commit 36720b7

Browse files
authored
restore support for IRB <= v1.13.0 (#358)
1 parent aa7cd9c commit 36720b7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Diff for: lib/iruby/backend.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,29 @@ def initialize
5050
@irb = IRB::Irb.new(@workspace)
5151
@eval_path = @irb.context.irb_path
5252
IRB.conf[:MAIN_CONTEXT] = @irb.context
53-
@completor = IRB::RegexpCompletor.new
53+
@completor = IRB::RegexpCompletor.new if defined? IRB::RegexpCompletor # IRB::VERSION >= 1.8.2
5454
end
5555

5656
def eval_binding
5757
@workspace.binding
5858
end
5959

6060
def eval(code, store_history)
61-
@irb.context.evaluate(@irb.build_statement(code), 0)
61+
if Gem::Version.new(IRB::VERSION) < Gem::Version.new('1.13.0')
62+
@irb.context.evaluate(code, 0)
63+
else
64+
@irb.context.evaluate(@irb.build_statement(code), 0)
65+
end
6266
@irb.context.last_value unless IRuby.silent_assignment && assignment_expression?(code)
6367
end
6468

6569
def complete(code)
66-
# preposing and postposing never used, so they are empty, pass only target as code
67-
@completor.completion_candidates('', code, '', bind: @workspace.binding)
70+
if @completor
71+
# preposing and postposing never used, so they are empty, pass only target as code
72+
@completor.completion_candidates('', code, '', bind: @workspace.binding)
73+
else
74+
IRB::InputCompletor::CompletionProc.call(code)
75+
end
6876
end
6977

7078
private

0 commit comments

Comments
 (0)