Class: Rutema::Reporters::Console

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

Overview

A very simple event reporter that outputs to the console

It has three settings: off, normal and verbose.

Example configuration: cfg.reporter="mode"=>"verbose"

Instance Method Summary collapse

Methods inherited from EventReporter

#exit, #run!

Constructor Details

#initialize(configuration, dispatcher) ⇒ Console

Returns a new instance of Console.



108
109
110
111
# File 'lib/rutema/core/reporter.rb', line 108

def initialize(configuration, dispatcher)
  super
  @mode = configuration.reporters.fetch(self.class, {})["mode"]
end

Instance Method Details

#update(message) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/rutema/core/reporter.rb', line 114

def update(message)
  return if @mode == "off"

  case message
  when RunnerMessage
    if message.status == :error
      puts "FATAL|#{message}"
    elsif message.status == :warning
      puts "WARNING|#{message}"
    elsif @mode == "verbose"
      puts "#{message} #{message.status}."
    end
  when ErrorMessage
    puts message
  when Message
    puts message if @mode == "verbose"
  end
end