How to Send RubyMine Notifications to Growl?
Solution 1:
May be This code will help you
# -*- ruby -*-
module Autotest::RedGreen
Autotest.send(:alias_method, :real_ruby, :ruby)
Autotest.send(:define_method, :ruby) do |*args|
real_ruby + %[ -rrubygems -e "require 'redgreen'" ]
end
# Clean the output so other modules can work correctly
Autotest.add_hook :ran_command do |at|
at.results.each do |r|
r.gsub!("\033[31m", "")
r.gsub!("\033[32m", "")
r.gsub!("\033[33m", "")
r.gsub!("\033[0m", "")
end
end
end
module Autotest::Growl
AUTOTEST_IMAGE_ROOT = "~/.autotest_images"
def self.growl(title, msg, img, pri=0, sticky="")
system "growlnotify -n autotest --image #{img} -p #{pri} -m '#{msg.inspect} #{title}' #{sticky}"
end
Autotest.add_hook :red do |at|
growl("FAIL", "#{get_results(at)}", "#{AUTOTEST_IMAGE_ROOT}/fail.png", 2)
end
Autotest.add_hook :green do |at|
growl("Pass", "#{get_results(at)}", "#{AUTOTEST_IMAGE_ROOT}/pass.png")
end
private
def self.get_results(at)
results = [at.results].flatten.join("\n")
if results.include? 'tests'
output = results.slice(/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures? (,\s*(\d+)\s+errors)?/)
else
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?/)
end
output
end
end
# Esclusioni
Autotest.add_hook :initialize do |at|
%w{.hg .git .svn stories tmtags Rakefile Capfile README spec/spec.opts spec/rcov.opts vendor/gems autotest svn-commit .DS_Store }.each do |exception|
at.add_exception(exception)
end
at.add_mapping(/spec\/defaults.rb/) do |f, _|
at.files_matching %r%^spec/(controllers|helpers|lib|models|views)/.*\.rb$%
end
end