growl-glue 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2008-07-04
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/bin/growl_notify.sh
6
+ lib/growl_glue/autotest.rb
7
+ lib/growl_glue/commands.rb
8
+ lib/growl_glue/config.rb
9
+ lib/growl_glue/util.rb
10
+ lib/growl_glue.rb
11
+ lib/img/fail.png
12
+ lib/img/ok.png
data/README.txt ADDED
@@ -0,0 +1,109 @@
1
+ == DESCRIPTION:
2
+
3
+ Simplifies Growl configuration for Autotest.
4
+
5
+ == Autotest Features:
6
+
7
+ * Easy configuration of growl notifications in ~/.autotest
8
+ * Comes bundled with sample green/red images, or you can supply your own
9
+ * Ability to specify OS X speech options (e.g. "Oh No!", if test failure)
10
+ * RSpec support
11
+ * Test::Unit support
12
+
13
+ == Autotest Growl Integration:
14
+
15
+ The Autotest growl configuration should happen in ~/.autotest. To get up and running very quickly with basic notifications + images:
16
+
17
+ require 'growl_glue'
18
+ GrowlGlue::Autotest.initialize
19
+
20
+
21
+ If you wish to customize, further, you simply need to supply your own block, to which the GrowlGlue configuration object will be passed:
22
+
23
+ require 'growl_glue'
24
+ GrowlGlue::Autotest.initialize do |config|
25
+ ...
26
+ end
27
+
28
+ It is recommended that you use network notifications due to a bug in Growl on OS X 10.5. Inside of the Growl Preferences pane, on the Network tab, make sure the "Listen for incoming notifications" checkbox is checked, and then *restart Growl*. Then configure GrowlGlue inside of the setup block:
29
+
30
+ config.notification :use_network_notifications => true
31
+
32
+ OS X Speech:
33
+
34
+ config.say :success => "Great Job!", :failure => "WTF mate?"
35
+
36
+ If you have *sndplay* compiled and in the path, you can have different sounds played based on test success or failure. The "location" below is optional, as it defaults to "/System/Library/Sounds":
37
+
38
+ config.sound :success => "Glass.aiff"
39
+ config.sound :failure => "Basso.aiff"
40
+ config.sound :location => "/System/Library/Sounds/" (optional)
41
+
42
+ GrowlGlue comes with success and error images it will use on test success and error, respectively.
43
+ If you wish to supply your own, for example:
44
+
45
+ config.image :success => "~/Library/autotest/success.png"
46
+ config.image :failure => "~/Library/autotest/failure.png"
47
+
48
+ By default, "Tests Passed" and "Tests Failed" will be used as the growl titles. You can supply your own, though:
49
+
50
+ config.title :success => "Love", :failure => "Hatred"
51
+
52
+ As an example, this is what I normally use:
53
+
54
+ GrowlGlue::Autotest.initialize do |config|
55
+
56
+ config.notification :use_network_notifications => true
57
+ config.title :success => "Love", :failure => "Hate"
58
+ config.say :failure => "Something is horribly wrong!"
59
+
60
+ end
61
+
62
+
63
+ == REQUIREMENTS:
64
+
65
+ * Growl 1.1.4 (may work on previous versions but not tested)
66
+ * Growlnotify Extra installed
67
+
68
+ == OPTIONAL:
69
+
70
+ * sndplay (for #sound notification)
71
+
72
+ == INSTALL:
73
+
74
+ * sudo gem install growl_glue -y
75
+ * Download Growl from http://growl.info
76
+ * After installing Growl, install the Growlnotify Extra included in the DMG
77
+ * After Growl is installed, configure your ~/.autotest file as described above
78
+
79
+ == BUGS / ISSUES:
80
+
81
+ Please let me know (gluedtomyseat@gmail.com) if you encounter any issues. You can also follow or fork development on the github project:
82
+
83
+ http://github.com/oculardisaster/growl-glue/tree/master
84
+
85
+
86
+ == LICENSE:
87
+
88
+ (The MIT License)
89
+
90
+ Copyright (c) 2008 Nimble Technique, LLC
91
+
92
+ Permission is hereby granted, free of charge, to any person obtaining
93
+ a copy of this software and associated documentation files (the
94
+ 'Software'), to deal in the Software without restriction, including
95
+ without limitation the rights to use, copy, modify, merge, publish,
96
+ distribute, sublicense, and/or sell copies of the Software, and to
97
+ permit persons to whom the Software is furnished to do so, subject to
98
+ the following conditions:
99
+
100
+ The above copyright notice and this permission notice shall be
101
+ included in all copies or substantial portions of the Software.
102
+
103
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
104
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
105
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
106
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
107
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
108
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
109
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/growl_glue.rb'
6
+
7
+ Hoe.new('growl-glue', GrowlGlue::VERSION) do |p|
8
+ # p.rubyforge_name = 'GrowlGluex' # if different than lowercase project name
9
+ p.developer('Collin VanDyck', 'gluedtomyseat@gmail.com')
10
+ p.remote_rdoc_dir = '' # Release to root
11
+ p.description = "Easy configuration of Growl + Autotest"
12
+ p.summary = "Easy configuration of Growl + Autotest"
13
+
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ # growlnotify leopard bug workaround
3
+ list_args()
4
+ {
5
+ for p in "$@"
6
+ do
7
+ if [ "${p:0:1}" == "-" ];then
8
+ echo -n "$p "
9
+ else
10
+ echo -n "\"$p\" "
11
+ fi
12
+ done
13
+ }
14
+ argstr=$(list_args "${@:$?}")
15
+ echo "-H localhost $argstr" | xargs `which growlnotify`
@@ -0,0 +1,113 @@
1
+ module GrowlGlue
2
+ class Autotest
3
+ [Util, Commands].each { |cls| extend cls }
4
+
5
+ ERROR_PRI = 2
6
+
7
+ def self.initialize
8
+ @config = Config.new
9
+
10
+ @config.sound :location => "/System/Library/Sounds/"
11
+ @config.commands :safe_growlnotify => File.join(gem_home_dir, "lib", "bin", "growl_notify.sh")
12
+
13
+ @config.image :failure => File.join(gem_home_dir, "lib", "img", "fail.png")
14
+ @config.image :success => File.join(gem_home_dir, "lib", "img", "ok.png")
15
+
16
+ @config.title :success => "Tests Passed"
17
+ @config.title :failure => "Tests Failed"
18
+
19
+ yield @config if block_given?
20
+
21
+ add_hook
22
+ end
23
+
24
+ private
25
+
26
+ def self.gem_home_dir
27
+ File.join File.dirname(__FILE__), "..", ".."
28
+ end
29
+
30
+ def self.add_hook
31
+ ::Autotest.add_hook :ran_command do |at|
32
+ with([at.results].flatten.join("\n")) do |results|
33
+ process_results(results)
34
+ end
35
+ end
36
+ end
37
+
38
+ def self.growl(title, msg, img=nil, pri=1, sticky="")
39
+ command = []
40
+
41
+ if @config.option(:notification, :use_network_notifications)
42
+ command << @config.option(:commands, :safe_growlnotify)
43
+ else
44
+ command << "growlnotify"
45
+ end
46
+ command << "--image #{img}" if img
47
+ command << "-n autotest"
48
+ command << "-p #{pri}"
49
+ command << "-m #{msg.inspect}"
50
+ command << title
51
+ command << sticky
52
+ command.join(" ")
53
+ end
54
+
55
+ def self.say(msg)
56
+ if msg
57
+ "say '#{msg.gsub(/'/,"")}'"
58
+ end
59
+ end
60
+
61
+ def self.sndplay(sound)
62
+ location = @config.option :sound, :location
63
+ if sound and location
64
+ "sndplay #{location}/#{sound} > /dev/null 2>&1"
65
+ end
66
+ end
67
+
68
+ def self.notify(title, msg, img=nil, pri=1)
69
+ with_commands do |commands|
70
+ commands << growl(title, msg, img, pri)
71
+
72
+ if pri == ERROR_PRI
73
+ commands << say(@config.option(:say, :failure))
74
+ commands << sndplay(@config.option(:sound, :failure))
75
+ else
76
+ commands << say(@config.option(:say, :success))
77
+ commands << sndplay(@config.option(:sound, :success))
78
+ end
79
+ end
80
+ end
81
+
82
+ # handles rspec results
83
+ def self.rspec_results(results)
84
+ output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
85
+ if output
86
+ if $~[2].to_i > 0
87
+ notify @config.option(:title, :failure), "#{output}", @config.option(:image, :failure), 2
88
+ else
89
+ notify @config.option(:title, :success), "#{output}", @config.option(:image, :success)
90
+ end
91
+ end
92
+ end
93
+
94
+ # handles test::unit results
95
+ def self.test_results(results)
96
+ output = results.slice(/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures?,\s*(\d+)\s+errors?/)
97
+ if output
98
+ if (($~[3].to_i > 0) or ($~[4].to_i > 0))
99
+ notify @config.option(:title, :failure), "#{output}", @config.option(:image, :failure), 2
100
+ else
101
+ notify @config.option(:title, :success), "#{output}", @config.option(:image, :success)
102
+ end
103
+ end
104
+ end
105
+
106
+ def self.process_results(results)
107
+ rspec_results(results)
108
+ test_results(results)
109
+ end
110
+
111
+
112
+ end
113
+ end
@@ -0,0 +1,13 @@
1
+ module GrowlGlue
2
+ module Commands
3
+ extend Util
4
+
5
+ def with_commands
6
+ with([]) do |commands|
7
+ yield commands
8
+ commands.compact.each { |command| system(command) }
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ module GrowlGlue
2
+
3
+ class Config
4
+ attr_reader :options
5
+
6
+ def initialize
7
+ @options={}
8
+ end
9
+
10
+ # returns a nested option value
11
+ def option(*keys)
12
+ option = @options
13
+ until keys.empty? or option.nil?
14
+ option = option[keys.shift]
15
+ end
16
+ option
17
+ end
18
+
19
+ def method_missing(name, *args, &block)
20
+ self.set_options(name, *args)
21
+ end
22
+
23
+ def set_options(key, opts)
24
+ @options[key] ||= {}
25
+ @options[key].merge!(opts)
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,10 @@
1
+ module GrowlGlue
2
+ module Util
3
+
4
+ def with(obj)
5
+ yield obj
6
+ obj
7
+ end
8
+
9
+ end
10
+ end
data/lib/growl_glue.rb ADDED
@@ -0,0 +1,8 @@
1
+ %w(util commands config autotest).each do |file|
2
+ require File.join(File.dirname(__FILE__), "growl_glue/#{file}.rb")
3
+ end
4
+
5
+ module GrowlGlue
6
+ VERSION = '1.0.0'
7
+
8
+ end
data/lib/img/fail.png ADDED
Binary file
data/lib/img/ok.png ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: growl-glue
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Collin VanDyck
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPDCCAiSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBEMRYwFAYDVQQDDA1nbHVl
14
+ ZHRvbXlzZWF0MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
15
+ FgNjb20wHhcNMDgwNzA1MTQxMDQ0WhcNMDkwNzA1MTQxMDQ0WjBEMRYwFAYDVQQD
16
+ DA1nbHVlZHRvbXlzZWF0MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJ
17
+ k/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCxzsxS
18
+ Gbn4WqVr0ASyg1uLNePFDCItoIBO2aTOdPOqdYe3U7Fd2MiWjRy1Z7+vtgTGOw2t
19
+ AoyknDBba+Bydm3MB3I3KP6l71LZ5ZYmCQzPvgcFjWbQnJSG5ofROUM5zjZbVx3P
20
+ ochIBNVQlwXGDMCdT568KcWAkR5lUlrGl5IoTwezeT05d8k9xZlivP1tmMSMgMTg
21
+ DY+9ymQXpTxGiQ29Kc1APfQEgOR48HIS3uGaXXclsdYouA02Uj3Yv/z+yzKZI9UH
22
+ MQUiAcqXWc1wxYslYmztTEJGmAQ8nrkP1EJP3t2A62nLPaH1c+ouz48ujWRH4/tV
23
+ vpwvCwYvR54o2lZpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
24
+ A1UdDgQWBBTgKbCB/wIXhLeePx2M+tvzr3XMvjANBgkqhkiG9w0BAQUFAAOCAQEA
25
+ pIU5PinqCLyUTisCNPvwwcz5mJQ1Z+OBLh4K4HGoZs2Tu3oNpEtKkNfgEiVTh3Dg
26
+ 9BlFxVgAZZABNLrBKLkTlYtvjyYEIL3DFPU1Hh4sqAGTd67RXZ5Uen+ldO+bXYT8
27
+ IB+pt7uev+4hvCUROqRlWQcYVfxXlYpuH4pAYAKmx55x6jcp8mKlHb/CJ52hPEam
28
+ i6nPl4R+RQ/Qg5Q99OuWDww5Pt5xOY50sOrDD+momkdf1KHPiQix6zB3WCy2QUn+
29
+ AVD9HizuKv4ppv+434afNyHlctXAnJbVzCLwBIxjiaeUi2Wtbo+0NhccuFSXVCrR
30
+ jA8FHf4HdyRgbrpT6Mws7g==
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2008-07-05 00:00:00 -04:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ type: :development
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.7.0
45
+ version:
46
+ description: Easy configuration of Growl + Autotest
47
+ email:
48
+ - gluedtomyseat@gmail.com
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ extra_rdoc_files:
54
+ - History.txt
55
+ - Manifest.txt
56
+ - README.txt
57
+ files:
58
+ - History.txt
59
+ - Manifest.txt
60
+ - README.txt
61
+ - Rakefile
62
+ - lib/bin/growl_notify.sh
63
+ - lib/growl_glue/autotest.rb
64
+ - lib/growl_glue/commands.rb
65
+ - lib/growl_glue/config.rb
66
+ - lib/growl_glue/util.rb
67
+ - lib/growl_glue.rb
68
+ - lib/img/fail.png
69
+ - lib/img/ok.png
70
+ has_rdoc: true
71
+ homepage: Simplifies Growl configuration for Autotest.
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --main
75
+ - README.txt
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: growl-glue
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: Easy configuration of Growl + Autotest
97
+ test_files: []
98
+
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ #|N�S.�28�p*�R����B��McFe���d���7o�����p���J�� aU>mf��
2
+ Sy�v۸��'���g�a��#����� ����Y�J�$"&�=��+Z4��t���$(�" �s�Vj5�ҙ���W�