Class: Rutema::Reporters::EventReporter
- Inherits:
-
Object
- Object
- Rutema::Reporters::EventReporter
- Defined in:
- lib/rutema/core/reporter.rb
Overview
Event reporters receive and process information continually during a test run
Instance Method Summary collapse
- #exit ⇒ Object
-
#initialize(configuration, dispatcher) ⇒ EventReporter
constructor
A new instance of EventReporter.
- #run! ⇒ Object
- #update(data) ⇒ Object
Constructor Details
#initialize(configuration, dispatcher) ⇒ EventReporter
Returns a new instance of EventReporter.
41 42 43 44 |
# File 'lib/rutema/core/reporter.rb', line 41 def initialize(configuration, dispatcher) @configuration = configuration @queue = dispatcher.subscribe(object_id) end |
Instance Method Details
#exit ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/rutema/core/reporter.rb', line 63 def exit puts "Exiting #{self.class}" if $DEBUG return unless @thread puts "Reporter died with #{@queue.size} messages in the queue" unless @thread.alive? sleep 0.1 while !@queue.empty? && @thread.alive? Thread.kill(@thread) end |
#run! ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rutema/core/reporter.rb', line 46 def run! @thread = Thread.new do loop do data = @queue.pop begin update(data) if data rescue StandardError puts "#{self.class} failed with #{$!.}" raise end end end end |
#update(data) ⇒ Object
60 61 |
# File 'lib/rutema/core/reporter.rb', line 60 def update(data) end |