diff --git a/lib/iruby/backend.rb b/lib/iruby/backend.rb index 156d78f..a8b17ef 100644 --- a/lib/iruby/backend.rb +++ b/lib/iruby/backend.rb @@ -50,7 +50,7 @@ def initialize @irb = IRB::Irb.new(@workspace) @eval_path = @irb.context.irb_path IRB.conf[:MAIN_CONTEXT] = @irb.context - @completor = IRB::RegexpCompletor.new + @completor = IRB::RegexpCompletor.new if defined? IRB::RegexpCompletor # IRB::VERSION >= 1.8.2 end def eval_binding @@ -58,13 +58,21 @@ def eval_binding end def eval(code, store_history) - @irb.context.evaluate(@irb.build_statement(code), 0) + if Gem::Version.new(IRB::VERSION) < Gem::Version.new('1.13.0') + @irb.context.evaluate(code, 0) + else + @irb.context.evaluate(@irb.build_statement(code), 0) + end @irb.context.last_value unless IRuby.silent_assignment && assignment_expression?(code) end def complete(code) - # preposing and postposing never used, so they are empty, pass only target as code - @completor.completion_candidates('', code, '', bind: @workspace.binding) + if @completor + # preposing and postposing never used, so they are empty, pass only target as code + @completor.completion_candidates('', code, '', bind: @workspace.binding) + else + IRB::InputCompletor::CompletionProc.call(code) + end end private