require 'rubygems' require 'autotest' require File.join(File.dirname(__FILE__), 'result') ## # Autotest::NotifyOSD # # == FEATUERS: # * Display autotest results as NotifyOSD notifications. # * Clean the terminal on every test cycle while maintaining scrollback. # # == SYNOPSIS: # ~/.autotest # require 'autotest/notify-osd' module Autotest::NotifyOSD GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) @label = '' @modified_files = [] @ran_tests = false @ran_features = false @@remote_notification = false @@one_notification_per_run = false @@clear_terminal = true @@hide_label = false @@show_modified_files = false ## # Whether to use remote or local notificaton (default). def self.remote_notification=(boolean) @@remote_notification = boolean end ## # Whether to limit the number of notifications per run to one or not (default). def self.one_notification_per_run=(boolean) @@one_notification_per_run = boolean end ## # Whether to clear the terminal before running tests (default) or not. def self.clear_terminal=(boolean) @@clear_terminal = boolean end ## # Whether to display the label (default) or not. def self.hide_label=(boolean) @@hide_label = boolean end ## # Whether to display the modified files or not (default). def self.show_modified_files=(boolean) @@show_modified_files = boolean end ## # Display a message through Growl. def self.notify_osd(title, message, icon, priority=0, stick="") image = File.join(ENV['HOME'], '.autotest-notify-osd', "#{icon}.png") image = File.join(GEM_PATH, 'img', "#{icon}.png") unless File.exists?(image) # Translate the priority case priority when 0,1 pri = 'normal' when 2 pri = 'critical' else pri = 'low' end system %(notify-send -i '#{image}' -u #{pri} '#{title}' '#{message}') end ## # Display the modified files. Autotest.add_hook :updated do |autotest, modified| print "\nThis gem has been deprecated and replaced by autotest-growl\n" false end ## # Set the label and clear the terminal. Autotest.add_hook :run_command do print "\nThis gem has been deprecated and replaced by autotest-growl\n" false end ## # Parse the RSpec and Test::Unit results and send them to Growl. Autotest.add_hook :ran_command do |autotest| print "\nThis gem has been deprecated and replaced by autotest-growl\n" false end ## # Parse the Cucumber results and sent them to Growl. Autotest.add_hook :ran_features do |autotest| print "\nThis gem has been deprecated and replaced by autotest-growl\n" false end end