Class: Specjour::Printer

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

Direct Known Subclasses

Cucumber::Printer

Constant Summary collapse

RANDOM_PORT =
0

Constants included from Protocol

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Protocol

#dump_object, #load_object

Constructor Details

#initialize(specs_to_run) ⇒ Printer

Returns a new instance of Printer.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/specjour/printer.rb', line 14

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

Instance Attribute Details

#completed_workersObject

Returns the value of attribute completed_workers.



12
13
14
# File 'lib/specjour/printer.rb', line 12

def completed_workers
  @completed_workers
end

#disconnectionsObject

Returns the value of attribute disconnections.



12
13
14
# File 'lib/specjour/printer.rb', line 12

def disconnections
  @disconnections
end

#specs_to_runObject

Returns the value of attribute specs_to_run.



12
13
14
# File 'lib/specjour/printer.rb', line 12

def specs_to_run
  @specs_to_run
end

#worker_sizeObject

Returns the value of attribute worker_size.



12
13
14
# File 'lib/specjour/printer.rb', line 12

def worker_size
  @worker_size
end

Class Method Details

.start(specs_to_run) ⇒ Object



8
9
10
# File 'lib/specjour/printer.rb', line 8

def self.start(specs_to_run)
  new(specs_to_run).start
end

Instance Method Details

#done(client) ⇒ Object



42
43
44
# File 'lib/specjour/printer.rb', line 42

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

#exit_statusObject



46
47
48
# File 'lib/specjour/printer.rb', line 46

def exit_status
  report.exit_status
end

#ready(client) ⇒ Object



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

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

#serve(client) ⇒ Object



28
29
30
31
32
33
# File 'lib/specjour/printer.rb', line 28

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

#worker_summary=(client, summary) ⇒ Object



50
51
52
# File 'lib/specjour/printer.rb', line 50

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