Sha256: 69db46d5a939f3bccd5d998b1667332ccb15580137d912a3ddc71cc4572e41f2
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require 'dat-tcp/logger' module DatTCP class ServerSpy attr_reader :ip, :port, :file_descriptor attr_reader :client_file_descriptors attr_reader :logger attr_reader :waiting_for_pause, :waiting_for_stop, :waiting_for_halt attr_accessor :listen_called, :start_called attr_accessor :stop_listen_called, :pause_called attr_accessor :stop_called, :halt_called attr_accessor :serve_proc def initialize @ip = nil @port = nil @file_descriptor = nil @client_file_descriptors = [] @logger = DatTCP::Logger::Null.new @waiting_for_pause = nil @waiting_for_stop = nil @waiting_for_hale = nil @listen_called = false @stop_listen_called = false @start_called = false @pause_called = false @stop_called = false @halt_called = false @serve_proc = proc{ } end def listening? @listen_called && !@stop_listen_called end def running? @start_called && !(@pause_called || @stop_called || @halt_called) end def listen(*args) case args.size when 2 @ip, @port = args when 1 @file_descriptor = args.first end @listen_called = true end def stop_listen @stop_listen_called = true end def start(client_file_descriptors = nil) @client_file_descriptors = client_file_descriptors || [] @start_called = true end def pause(wait = false) @waiting_for_pause = wait @pause_called = true end def stop(wait = false) @waiting_for_stop = wait @stop_called = true end def halt(wait = false) @waiting_for_halt = wait @halt_called = true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dat-tcp-0.6.0 | lib/dat-tcp/server_spy.rb |
dat-tcp-0.5.1 | lib/dat-tcp/server_spy.rb |