Permalink
Browse files

Fix that shit!

  • Loading branch information...
1 parent 77d5c85 commit 351c6c9d684004c037bd023d994beaa272373d86 tailor committed Feb 14, 2008
Showing with 20 additions and 16 deletions.
  1. +13 −13 lib/live_console.rb
  2. +7 −3 lib/live_console/io_methods/socket_io.rb
View
@@ -142,21 +142,21 @@ class GenericIOMethod < IRB::StdioInputMethod
#
# Creates a GenericIOMethod, using either a single object for both input
# and output, or one object for input and another for output.
- def initialize in, out = nil
- @in, @out = in, out
+ def initialize(input, output = nil)
+ @input, @output = input, output
@line = []
@line_no = 0
end
- attr_reader :in
- def out
- @out || in
+ attr_reader :input
+ def output
+ @output || input
end
def gets
- out.print @prompt
- out.flush
- @line[@line_no += 1] = in.gets
+ output.print @prompt
+ output.flush
+ @line[@line_no += 1] = input.gets
# @io.flush # Not sure this is needed.
@line[@line_no]
end
@@ -167,19 +167,19 @@ def lines
end
def print(*a)
- out.print *a
+ output.print *a
end
def file_name
- in.inspect
+ input.inspect
end
def eof?
- in.eof?
+ input.eof?
end
def close
- in.close
- out.close if @out
+ input.close
+ output.close if @output
end
end
@@ -8,23 +8,27 @@ class LiveConsole::IOMethods::SocketIO
include LiveConsole::IOMethods::IOMethod
def start
- self.server ||= TCPServer.new host, port
+ @server ||= TCPServer.new host, port
begin
self.raw_input = self.raw_output = server.accept_nonblock
return true
rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO,
Errno::EINTR => e
- stop
+ select
retry
end
end
def stop
- IO.select [server], [], [], 1 if server
+ select
raw_input.close rescue nil
end
+ def select
+ IO.select [server], [], [], 1 if server
+ end
+
private
attr_accessor :server
end

0 comments on commit 351c6c9

Please sign in to comment.