Class: RiotNotifier::Base
- Inherits:
-
Riot::DotMatrixReporter
- Object
- Riot::DotMatrixReporter
- RiotNotifier::Base
- Defined in:
- lib/riot_notifier/base.rb
Direct Known Subclasses
Class Method Summary collapse
- .inherited(notifier) ⇒ Object
-
.usable? ⇒ Boolean
Tests if this notifier is usable.
Instance Method Summary collapse
- #error(desc, error) ⇒ Object
-
#fail(desc, message, file, line) ⇒ Object
Override.
-
#initialize(*args, &block) ⇒ Base
constructor
A new instance of Base.
-
#notify(color, msg) ⇒ Object
Notifies you about failures and errors.
- #results(time_taken) ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Base
Returns a new instance of Base.
10 11 12 13 |
# File 'lib/riot_notifier/base.rb', line 10 def initialize(*args, &block) raise "#{self.class} is NOT usable" unless self.class.usable? super end |
Class Method Details
.inherited(notifier) ⇒ Object
28 29 30 |
# File 'lib/riot_notifier/base.rb', line 28 def self.inherited(notifier) ::RiotNotifier.register notifier end |
.usable? ⇒ Boolean
Tests if this notifier is usable. Should contain some initialization code e.g. require ‘libnotify’.
23 24 25 26 |
# File 'lib/riot_notifier/base.rb', line 23 def self.usable? # override false end |
Instance Method Details
#error(desc, error) ⇒ Object
39 40 41 42 |
# File 'lib/riot_notifier/base.rb', line 39 def error(desc, error) super notify(:red, "ERROR: #{error}") end |
#fail(desc, message, file, line) ⇒ Object
Override
34 35 36 37 |
# File 'lib/riot_notifier/base.rb', line 34 def fail(desc, , file, line) super notify(:red, "FAILURE: #{}@#{file}:#{line}") end |
#notify(color, msg) ⇒ Object
Notifies you about failures and errors. This methods should be overridden in order to define specific notifications libraries.
17 18 19 |
# File 'lib/riot_notifier/base.rb', line 17 def notify(color, msg) # override me end |
#results(time_taken) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/riot_notifier/base.rb', line 44 def results(time_taken) super unless bad_results? notify(:green, "%d passes, %d failures, %d errors in %s seconds" % [passes, failures, errors, ("%0.6f" % time_taken)]) end end |