Module: Testowl::Growl
- Defined in:
- lib/testowl/growl.rb
Constant Summary collapse
- Growlnotify =
"growlnotify"
- TerminalNotifier =
"terminal-notifier"
Class Method Summary collapse
- .grr(title, message, seconds, status, files, suffix, identifier) ⇒ Object
- .image_path(name) ⇒ Object
- .with_growl(title, message, seconds, status, files, suffix, identifier) ⇒ Object
- .with_terminal_notifier(title, message, seconds, status, files, suffix, identifier) ⇒ Object
Class Method Details
.grr(title, message, seconds, status, files, suffix, identifier) ⇒ Object
7 8 9 10 |
# File 'lib/testowl/growl.rb', line 7 def self.grr(title, , seconds, status, files, suffix, identifier) with_terminal_notifier(title, , seconds, status, files, suffix, identifier) || with_growl(title, , seconds, status, files, suffix, identifier) end |
.image_path(name) ⇒ Object
66 67 68 |
# File 'lib/testowl/growl.rb', line 66 def self.image_path(name) File.dirname(__FILE__) + "/../../images/#{name}.png" end |
.with_growl(title, message, seconds, status, files, suffix, identifier) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/testowl/growl.rb', line 38 def self.with_growl(title, , seconds, status, files, suffix, identifier) project = File.(".").split("/").last growlnotify = `which #{Growlnotify}`.chomp if growlnotify == '' if @g_warning_done puts "Skipping growl" else puts "If you install #{Growlnotify} you'll get growl notifications. See the README." @g_warning_done = true end false else = [.gsub("'", "`")] << sprintf("(%0.1f seconds)", seconds) if seconds << "#{files.map{|file| file.sub(/^spec\/[^\/]*\//, '').sub(/_test.rb$/, '')}.join("\n")}\n#{suffix}" << identifier = [] << "-n Watchr" << "--message '#{.join("\n\n")}'" << "--image '#{image_path(status)}'" << "--identifier #{identifier}" # (used for coalescing) title = "TestOwl #{title} (#{project})" system %(#{growlnotify} #{.join(' ')} '#{title}' &) puts true end end |
.with_terminal_notifier(title, message, seconds, status, files, suffix, identifier) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/testowl/growl.rb', line 12 def self.with_terminal_notifier(title, , seconds, status, files, suffix, identifier) project = File.(".").split("/").last terminal_notifier = `which #{TerminalNotifier}`.chomp if terminal_notifier == '' if @tn_warning_done puts "Skipping terminal notifier" else puts "If you install #{TerminalNotifier} you'll get notifications. Trying growl next. See the README." @tn_warning_done = true end false else = [.gsub("'", "`")] << sprintf("(%0.1f seconds)", seconds) if seconds << "#{files.map{|file| file.sub(/^spec\/[^\/]*\//, '').sub(/_test.rb$/, '')}.join("\n")}\n#{suffix}" << identifier = [] << "-message '#{.join("\n\n")}'" << "-group #{identifier}" # (used for coalescing) << "-title 'TestOwl #{title} (#{project})'" system %(#{terminal_notifier} #{.join(' ')} &) puts true end end |