Permalink
Browse files

Ugh, make irb/driver/socket work again.

  • Loading branch information...
1 parent 1eda01e commit daff59161da3237e9b3b825629dbdb45d22d14e1 @alloy committed Jul 24, 2010
Showing with 23 additions and 9 deletions.
  1. +3 −3 bin/dietrb
  2. +20 −6 lib/irb/driver/socket.rb
View
@@ -7,12 +7,12 @@ IRB_CONTEXT_TOPLEVEL_ARGS = [self, TOPLEVEL_BINDING.dup]
module IRB
# Just a namespace so not to pollute the toplevel namespace with lvars.
module Bin
+ driver = nil
+ ignore_irbrc = false
+
unless ARGV.empty?
require 'optparse'
- driver = nil
- ignore_irbrc = false
-
OptionParser.new do |opt|
bin = File.basename($0)
opt.banner = "Usage: #{bin} [options] [programfile] [arguments]"
View
@@ -4,6 +4,15 @@
module IRB
module Driver
class Socket
+ class << self
+ attr_reader :instance
+
+ def run(object, binding)
+ @instance = new(object, binding)
+ @instance.run
+ end
+ end
+
# Initializes with the object and binding that each new connection will
# get as Context. The binding is shared, so local variables will stay
# around. The benefit of this is that a socket based irb session is most
@@ -34,11 +43,16 @@ def run
end
end
-def self.irb(object, binding = nil)
- unless @server
- @server = IRB::Driver::Socket.new(object, binding)
- @server.run
- else
- super
+module Kernel
+ alias_method :irb_before_socket, :irb
+
+ def irb(object, binding = nil)
+ if IRB::Driver::Socket.instance.nil?
+ IRB::Driver::Socket.run(object, binding)
+ else
+ irb_before_socket(object, binding)
+ end
end
+
+ private :irb, :irb_before_socket
end

0 comments on commit daff591

Please sign in to comment.