Sha256: de02360ef12bb654a3a1d0144b336ea2a64fe37f81e2a589de595cc4fd5cbe2c
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
#!/usr/bin/env ruby =begin ======================================================================= # TORK-NOTIFY 1 2014-01-02 19.6.0 ## NAME tork-notify - notifies you of test status changes ## SYNOPSIS `tork-notify` [*OPTION*]... ## DESCRIPTION This program serves as an example of how to receive and process messages sent by the various programs in the tork(1) suite. It notifies you when previously passing tests fail (or vice versa) through libnotify, xmessage, or growl. If none are available on your system, then the notification is printed to stdout. ## OPTIONS `-h`, `--help` Show this help manual. ## EXIT STATUS See tork-remote(1). ## SEE ALSO tork-remote(1), tork-engine(1) =end ========================================================================= $0 = File.basename(__FILE__) # for easier identification in ps(1) output require 'binman' BinMan.help require 'json' IO.popen('tork-remote tork-engine', 'r+') do |remote| while message = remote.gets event, test_file, *details = JSON.load(message) # make notifications edge-triggered: pass => fail or vice versa. # we do not care about pass => pass or fail => fail transitions. icon = case event.to_sym when :fail_now_pass then 'dialog-information' when :pass_now_fail then 'dialog-error' end if icon _, _, line_numbers, log_file = details.first title = [event.upcase, test_file].join(' ') statistics = File.readlines(log_file).grep(/^\d+ \w+,/).join. gsub(/\e\[\d+(;\d+)?m/, '') # strip ANSI SGR escape codes # run in background; see http://stackoverflow.com/q/16745840 Thread.new(icon, title, statistics) do |icon, title, statistics| system 'notify-send', '-i', icon, title, statistics or system 'growlnotify', '-a', 'Xcode', '-m', statistics, title or system 'xmessage', '-timeout', '5', '-title', title, statistics or puts title, statistics, nil end end end end exit $?.exitstatus
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tork-19.6.0 | bin/tork-notify |