lib/travis/tools/notification.rb in travis-1.5.7.travis.345.4 vs lib/travis/tools/notification.rb in travis-1.5.7

- old
+ new

@@ -1,14 +1,16 @@ +require "travis" require "travis/tools/system" -require "terminal-notifier" +require "travis/tools/assets" require "cgi" module Travis module Tools module Notification extend self DEFAULT = [:osx, :growl, :libnotify] + ICON = Assets['notifications/icon.png'] def new(*list) list.concat(DEFAULT) if list.empty? notification = list.map { |n| get(n) }.detect { |n| n.available? } raise ArgumentError, "no notification system found (looked for #{list.join(", ")})" unless notification @@ -20,35 +22,38 @@ raise ArgumentError, "unknown notifications type %p" % name unless const const_get(const).new end class Dummy + BIN_PATH = Assets['Travis CI.app/Contents/MacOS/Travis CI'] def notify(title, body) end def available? true end end class OSX + BIN_PATH = Assets["notifications/Travis CI.app/Contents/MacOS/Travis CI"] + def notify(title, body) - TerminalNotifier.notify(body, :title => title) + system BIN_PATH, '-message', body.to_s, '-title', title.to_s end def available? - System.mac? and TerminalNotifier.available? + System.mac? and `sw_vers -productVersion`.strip >= '10.8' end end class Growl def initialize @command = "growlnotify" end def notify(title, body) - system @command, '-n', 'Travis', '-m', body, title + system @command, '-n', 'Travis', '--image', ICON, '-m', body, title end def available? system "which #{@command} >/dev/null 2>/dev/null" unless System.windows? end @@ -59,10 +64,10 @@ @command = "notify-send" @expire_time = 10_000 end def notify(title, body) - system @command, "--expire-time=#{@expire_time}", title, CGI.escapeHTML(body) + system @command, "--expire-time=#{@expire_time}", "-i", ICON, title, CGI.escapeHTML(body) end end end end end