Class: Rutema::Reporters::EventReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rutema/core/reporter.rb

Overview

Event reporters receive and process information continually during a test run

Direct Known Subclasses

Collector, Console

Instance Method Summary collapse

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

#exitObject



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 #{$!.message}"
        raise
      end
    end
  end
end

#update(data) ⇒ Object



60
61
# File 'lib/rutema/core/reporter.rb', line 60

def update(data)
end