Module: Rutema::Messaging

Included in:
Engine, Runners::Default
Defined in:
lib/rutema/core/framework.rb

Overview

Mix-in module which offers an interface to push messages to a queue

Instances of the class including this module need a @queue member variable.

Instance Method Summary collapse

Instance Method Details

#error(identifier, message) ⇒ Object

Push a new ErrorMessage instance to the queue

  • identifier - in most cases this would be the name of a test or its specification file
  • message - a short descriptive message detailing the error condition


156
157
158
# File 'lib/rutema/core/framework.rb', line 156

def error(identifier, message)
  @queue.push(ErrorMessage.new(:test => identifier, :text => message, :timestamp => Time.now))
end

#message(message) ⇒ Object

Push a new Message or RunnerMessage instance to the queue

If message is of type String a Message instance will be pushed to the queue. If it's of type Hash it will be passed to the initializer of RunnerMessage if it has both the keys :test and "status" or to the initializer of Message if not so.



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/rutema/core/framework.rb', line 167

def message(message)
  case message
  when String
    @queue.push(Message.new(:text => message, :timestamp => Time.now))
  when Hash
    hm = Message.new(message)
    hm = RunnerMessage.new(message) if message[:test] && message["status"]
    hm.timestamp = Time.now
    @queue.push(hm)
  end
end