lib/riot_notifier.rb in riot_notifier-0.0.2 vs lib/riot_notifier.rb in riot_notifier-0.0.3

- old
+ new

@@ -1,22 +1,20 @@ -require 'riot' - module RiotNotifier class Base < Riot::DotMatrixReporter def notify(color, msg) # overwrite me end def fail(desc, message) super - say "#{desc}: #{message}".yellow + say yellow("#{desc}: #{message}") notify(:red, "FAILURE: #{message}") end def error(desc, error) super - say "#{desc}: #{error}".red + say red("#{desc}: #{error}") notify(:red, "ERROR: #{error}") end def results(time_taken) super @@ -27,9 +25,37 @@ private def bad_results? failures + errors > 0 + end + end + + class Libnotify < Base + OPTIONS = { + :green => { + :icon_path => "/usr/share/icons/gnome/scalable/emblems/emblem-default.svg", + :timeout => 2.5, + :urgency => :normal, + :summary => ":-)" + }, + :red => { + :icon_path => "/usr/share/icons/gnome/scalable/emotes/face-angry.svg", + :timeout => 2.5, + :urgency => :critical, + :summary => ":-(" + } + } + + def initialize + require 'libnotify' + super() + end + + def notify(color, msg) + options = OPTIONS[color] or raise "unknown color #{color}" + + ::Libnotify.show(options.merge(:body => msg)) end end class RedgreenNotifier < Base attr_reader :path