lib/irby.rb in irby-1.0.0 vs lib/irby.rb in irby-1.0.1
- old
+ new
@@ -1,11 +1,27 @@
-module Kernel
- def irb
- require 'irb'
- IRB.setup(nil)
- irb = IRB::Irb.new(IRB::WorkSpace.new(binding))
- IRB.conf[:MAIN_CONTEXT] = irb.context
+require 'irb'
+
+module IRB
+ def self.start_session(binding)
+ unless @__irb_initialized
+ IRB.setup(nil)
+ @__irb_initialized = true
+ end
+
+ workspace = WorkSpace.new(binding)
+
+ irb = Irb.new(workspace)
+
+ @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
+ @CONF[:MAIN_CONTEXT] = irb.context
+
catch(:IRB_EXIT) do
irb.eval_input
end
+ end
+end
+
+module Kernel
+ def irb
+ IRB.start_session(binding)
end
end