Sha256: cc719a6701c263b7f6dc3b5b7b7bcdede43e302910a5f8dbdbf3d6602b0ef5fa

Contents?: true

Size: 803 Bytes

Versions: 1

Compression:

Stored size: 803 Bytes

Contents

# Notifies you about failures and errors in your riot tests!
#
# Usage:
#   require 'riot'
#   require 'riot_notifier'
#
#   # auto-detection
#   Riot.reporter = RiotNotifier
#   # try these first
#   Riot.reporter = RiotNotifier[:RedgreenBinary, :Libnotify]
#
module RiotNotifier

  def self.new(*args, &block)
    notifier_class = notifier_classes.detect(&:usable?) || None
    notifier_class.new(*args, &block)
  end

  def self.order
    @order ||= []
  end

  def self.try(*order)
    @order = order
    self
  end

  class << self
    alias [] try
  end

  def self.notifier_classes
    order.map { |o| resolve_notifier_class(o) }.compact - [None]
  end

  def self.resolve_notifier_class(o)
    case o
    when Class; o
    when Symbol, String; const_get(o)
    else
      nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riot_notifier-0.0.7 lib/riot_notifier/module.rb