samflores-autotest-notification 1.8.2 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{autotest-notification}
5
- s.version = "1.8.2"
5
+ s.version = "1.9.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Carlos Brando", "Rodrigo Urubatan", "Alexandre da Silva", "Carlos J\303\272nior", "Davis Zanetti Cabral", "Marcos Tapaj\303\263s", "Thiago Pradi", "Oz\303\251ias Sant'ana", "Samuel Flores", "Diego Carrion"]
9
- s.date = %q{2009-02-03}
9
+ s.date = %q{2009-04-02}
10
10
  s.description = %q{This gem set the autotest (ZenTest) to send messages to software as Growl, LibNotify, and Snarl, displaying a window with the results.}
11
11
  s.email = ["autotest-notification@carlosbrando.com"]
12
12
  s.executables = ["an-install", "an-uninstall", "playsound"]
@@ -49,7 +49,7 @@ BANNER
49
49
 
50
50
  opts.on("-d", "--doom",
51
51
  "Special Doom Edition.",
52
- "Only for Mac.") { |OPTIONS[:doom]| OPTIONS[:doom] = true }
52
+ "Only for Mac/Cygwin.") { |OPTIONS[:doom]| OPTIONS[:doom] = true }
53
53
 
54
54
  opts.on("-b", "--buuf",
55
55
  "Special Buuf Images.",
@@ -65,11 +65,11 @@ BANNER
65
65
 
66
66
  opts.on("--success-sound=PATH", String,
67
67
  "Sound to play on success.",
68
- "Only for Mac") { |OPTIONS[:sound][:success]| }
68
+ "Only for Mac/Cygwin.") { |OPTIONS[:sound][:success]| }
69
69
 
70
70
  opts.on("--failure-sound=PATH", String,
71
71
  "Sound to play on success.",
72
- "Only for Mac") { |OPTIONS[:sound][:failure]| }
72
+ "Only for Mac/Cygwin.") { |OPTIONS[:sound][:failure]| }
73
73
 
74
74
  opts.on("-h", "--help",
75
75
  "Show this help message.") { puts opts; exit }
@@ -103,4 +103,4 @@ f.write("FAILURE_SOUND = '#{OPTIONS[:sound][:failure]}'\n")
103
103
  f.close
104
104
 
105
105
  puts "\nAs from now all tests will be notified automatically."
106
- puts "" # a blank line
106
+ puts "" # a blank line
@@ -65,7 +65,7 @@ module AutotestNotification
65
65
  when /darwin/
66
66
  Mac.notify(title, msg, img, total, failures, priority)
67
67
  when /cygwin/
68
- Cygwin.notify(title, msg, img)
68
+ Cygwin.notify(title, msg, img, total, failures)
69
69
  when /mswin/
70
70
  Windows.notify(title, msg, img)
71
71
  end
@@ -1,14 +1,34 @@
1
1
  module AutotestNotification
2
2
  class Cygwin
3
+ @last_test_failed = false
4
+
3
5
  class << self
4
- def notify(title, msg, img)
6
+ def notify(title, msg, img, total = 1, failures = 0)
5
7
  img = get_image_path(img).strip
6
8
  system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{Config.expiration_in_seconds}"
9
+ play(SUCCESS_SOUND) if AutotestNotification.const_defined?("SUCCESS_SOUND") && !SUCCESS_SOUND.empty? && failures == 0
10
+ play(FAILURE_SOUND) if AutotestNotification.const_defined?("FAILURE_SOUND") && !FAILURE_SOUND.empty? && failures > 0
11
+ say(total, failures) if DOOM_EDITION
7
12
  end
8
13
 
9
14
  def get_image_path(img)
10
15
  `cygpath -m #{img}`
11
16
  end
17
+
18
+ def say(total, failures)
19
+ if failures > 0
20
+ Doom.play_sound(total, failures)
21
+ @last_test_failed = true
22
+ elsif @last_test_failed
23
+ Doom.play_sound(total, failures)
24
+ @last_test_failed = false
25
+ end
26
+ end
27
+
28
+ def play(sound_file)
29
+ system "cp #{sound_file} /dev/dsp"
30
+ end
31
+
12
32
  end
13
33
  end
14
34
  end
@@ -13,6 +13,8 @@ module AutotestNotification
13
13
  `#{File.expand_path(File.dirname(__FILE__) + "/../../bin/")}/playsound #{sound_file}`
14
14
  when /linux/
15
15
  system("/usr/bin/mplayer #{sound_file} > /dev/null 2> /dev/null")
16
+ when /cygwin/
17
+ system "cp #{sound_file} /dev/dsp"
16
18
  end
17
19
  end
18
20
 
@@ -6,8 +6,8 @@ module AutotestNotification
6
6
 
7
7
  def notify(title, msg, img, total = 1, failures = 0, priority = 0)
8
8
  system "growlnotify -n autotest --image #{img} #{'-s ' if ((failures > 0) and STICKY)}-p #{priority} -m '#{msg}' -t #{title}"
9
- play(SUCCESS_SOUND) unless SUCCESS_SOUND.empty? or failures > 0
10
- play(FAILURE_SOUND) unless FAILURE_SOUND.empty? or failures == 0
9
+ play(SUCCESS_SOUND) if AutotestNotification.const_defined?("SUCCESS_SOUND") && !SUCCESS_SOUND.empty? && failures == 0
10
+ play(FAILURE_SOUND) if AutotestNotification.const_defined?("FAILURE_SOUND") && !FAILURE_SOUND.empty? && failures > 0
11
11
  say(total, failures) if SPEAKING
12
12
  end
13
13
 
@@ -1,8 +1,8 @@
1
1
  module AutotestNotification #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 8
5
- TINY = 2
4
+ MINOR = 9
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -38,7 +38,7 @@ class TestMac < Test::Unit::TestCase
38
38
  end
39
39
 
40
40
  def test_success_sound_is_played_when_specified_and_test_success
41
- AutotestNotification.const_set :SUCCESS_SOUND, sound_path
41
+ AutotestNotification.const_set :SUCCESS_SOUND, sound_path
42
42
  AutotestNotification::Mac.expects(:play).with(sound_path)
43
43
  AutotestNotification::Mac.notify("title", "msg", "image", 1, 0)
44
44
  end
@@ -16,7 +16,7 @@ class TestAutotestNotification < Test::Unit::TestCase
16
16
  end
17
17
 
18
18
  def test_notify_when_os_is_cygwin
19
- AutotestNotification::Cygwin.expects(:notify).with(@title, @msg, @image)
19
+ AutotestNotification::Cygwin.expects(:notify).with(@title, @msg, @image, @total, @failures)
20
20
  verify_to("cygwin")
21
21
  end
22
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samflores-autotest-notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2009-02-03 00:00:00 -08:00
21
+ date: 2009-04-02 00:00:00 -07:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency