class Test::Unit::Notify::Notifier
Constants
- ICON_DIR
@private
Public Class Methods
new()
click to toggle source
@private
# File lib/test/unit/notify.rb, line 236 def initialize @theme = "kinotan" end
Public Instance Methods
attach_to_mediator(mediator)
click to toggle source
@private
# File lib/test/unit/notify.rb, line 241 def attach_to_mediator(mediator) mediator.add_listener(UI::TestRunnerMediator::STARTED, &method(:started)) mediator.add_listener(UI::TestRunnerMediator::FINISHED, &method(:finished)) end
available?()
click to toggle source
@return [Boolean] return `true` if test result notification
is available.
# File lib/test/unit/notify.rb, line 211 def available? not command.nil? end
command()
click to toggle source
@private
# File lib/test/unit/notify.rb, line 216 def command @@command ||= commands.find {|command| command.available?} end
commands()
click to toggle source
@private
# File lib/test/unit/notify.rb, line 221 def commands [ NotifySend.new, Growlnotify.new, GrowlnotifyForWindows.new, TerminalNotifier.new, ] end
finished(elapsed_time)
click to toggle source
@private
# File lib/test/unit/notify.rb, line 254 def finished(elapsed_time) command = self.class.command return if command.nil? title = "%s [%g%%] (%gs)" % [ @result.status, @result.pass_percentage, elapsed_time, ] parameters = { :expire_time => 5, :icon => guess_suitable_icon, :urgency => urgency, :title => title, :message => @result.summary, } command.run(parameters) end
started(result)
click to toggle source
@private
# File lib/test/unit/notify.rb, line 249 def started(result) @result = result end
Private Instance Methods
guess_suitable_icon()
click to toggle source
# File lib/test/unit/notify.rb, line 274 def guess_suitable_icon icon_dir = ICON_DIR + @theme status = @result.status icon_base_names = [status] if @result.passed? icon_base_names << "pass" else case status when "failure" icon_base_names << "error" when "error" icon_base_names << "failure" end end icon_base_names << "default" icon_base_names.each do |base_name| icon = icon_dir + "#{base_name}.png" return icon if icon.exist? end nil end
urgency()
click to toggle source
# File lib/test/unit/notify.rb, line 296 def urgency if @result.passed? "normal" else "critical" end end