Class: Specjour::Printer
- Inherits:
-
Object
- Object
- Specjour::Printer
- Includes:
- Protocol
- Defined in:
- lib/specjour/printer.rb
Constant Summary
- RANDOM_PORT =
0
Constants included from Protocol
Specjour::Protocol::TERMINATOR, Specjour::Protocol::TERMINATOR_REGEXP
Instance Attribute Summary (collapse)
-
- (Object) clients
readonly
Returns the value of attribute clients.
-
- (Object) example_size
Returns the value of attribute example_size.
-
- (Object) examples_complete
Returns the value of attribute examples_complete.
-
- (Object) port
readonly
Returns the value of attribute port.
-
- (Object) profiler
Returns the value of attribute profiler.
-
- (Object) tests_to_run
Returns the value of attribute tests_to_run.
Instance Method Summary (collapse)
- - (Object) exit_status
-
- (Printer) initialize
constructor
A new instance of Printer.
- - (Object) start
Methods included from Protocol
Constructor Details
- (Printer) initialize
A new instance of Printer
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/specjour/printer.rb', line 10 def initialize @host = "0.0.0.0" @server_socket = TCPServer.new(@host, RANDOM_PORT) @port = @server_socket.addr[1] @profiler = {} @clients = {} @tests_to_run = [] @example_size = 0 self.examples_complete = 0 end |
Instance Attribute Details
- (Object) clients (readonly)
Returns the value of attribute clients
7 8 9 |
# File 'lib/specjour/printer.rb', line 7 def clients @clients end |
- (Object) example_size
Returns the value of attribute example_size
8 9 10 |
# File 'lib/specjour/printer.rb', line 8 def example_size @example_size end |
- (Object) examples_complete
Returns the value of attribute examples_complete
8 9 10 |
# File 'lib/specjour/printer.rb', line 8 def examples_complete @examples_complete end |
- (Object) port (readonly)
Returns the value of attribute port
7 8 9 |
# File 'lib/specjour/printer.rb', line 7 def port @port end |
- (Object) profiler
Returns the value of attribute profiler
8 9 10 |
# File 'lib/specjour/printer.rb', line 8 def profiler @profiler end |
- (Object) tests_to_run
Returns the value of attribute tests_to_run
8 9 10 |
# File 'lib/specjour/printer.rb', line 8 def tests_to_run @tests_to_run end |
Instance Method Details
- (Object) exit_status
47 48 49 |
# File 'lib/specjour/printer.rb', line 47 def exit_status reporters.all? {|r| r.exit_status == true} end |
- (Object) start
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/specjour/printer.rb', line 21 def start fds = [@server_socket] catch(:stop) do while true reads = select(fds).first reads.each do |socket_being_read| if socket_being_read == @server_socket client_socket = @server_socket.accept fds << client_socket clients[client_socket] = Connection.wrap(client_socket) elsif socket_being_read.eof? socket_being_read.close fds.delete(socket_being_read) clients.delete(socket_being_read) disconnecting else serve(clients[socket_being_read]) end end end end ensure stopping fds.each {|c| c.close} end |