Class: Specjour::Printer

Inherits:
GServer
  • Object
show all
Includes:
Protocol
Defined in:
lib/specjour/printer.rb

Constant Summary collapse

RANDOM_PORT =
0

Constants included from Protocol

Specjour::Protocol::TERMINATOR, Specjour::Protocol::TERMINATOR_REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Protocol

#dump_object, #load_object

Constructor Details

#initializePrinter

Returns a new instance of Printer.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/specjour/printer.rb', line 8

def initialize
  super(
    port = RANDOM_PORT,
    host = "0.0.0.0",
    max_connections = 100,
    stdlog = $stderr,
    audit = true,
    debug = true
  )
  @completed_workers = 0
end

Instance Attribute Details

#completed_workersObject

Returns the value of attribute completed_workers.



6
7
8
# File 'lib/specjour/printer.rb', line 6

def completed_workers
  @completed_workers
end

#specs_to_runObject

Returns the value of attribute specs_to_run.



6
7
8
# File 'lib/specjour/printer.rb', line 6

def specs_to_run
  @specs_to_run
end

#worker_sizeObject

Returns the value of attribute worker_size.



6
7
8
# File 'lib/specjour/printer.rb', line 6

def worker_size
  @worker_size
end

Instance Method Details

#done(client) ⇒ Object



32
33
34
# File 'lib/specjour/printer.rb', line 32

def done(client)
  self.completed_workers += 1
end

#ready(client) ⇒ Object



27
28
29
30
# File 'lib/specjour/printer.rb', line 27

def ready(client)
  client.print specs_to_run.shift
  client.flush
end

#serve(client) ⇒ Object



20
21
22
23
24
25
# File 'lib/specjour/printer.rb', line 20

def serve(client)
  client = Connection.wrap client
  client.each(TERMINATOR) do |data|
    process load_object(data), client
  end
end

#worker_summary=(client, summary) ⇒ Object



36
37
38
# File 'lib/specjour/printer.rb', line 36

def worker_summary=(client, summary)
  report.add(summary)
end