autometal-growl 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +15 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +56 -0
- data/Rakefile +22 -0
- data/autometal-growl.gemspec +47 -0
- data/bin/install_growl +15 -0
- data/lib/growl.rb +43 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/shellscripts/growl +241 -0
- data/tasks/install.rake +17 -0
- data/test/test_growl.rb +26 -0
- data/test/test_helper.rb +3 -0
- metadata +124 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
autometal-growl.gemspec
|
7
|
+
bin/install_growl
|
8
|
+
lib/growl.rb
|
9
|
+
script/console
|
10
|
+
script/destroy
|
11
|
+
script/generate
|
12
|
+
shellscripts/growl
|
13
|
+
tasks/install.rake
|
14
|
+
test/test_growl.rb
|
15
|
+
test/test_helper.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
= autometal-growl
|
2
|
+
|
3
|
+
* http://github.com/Achillefs/growl
|
4
|
+
* http://humbuckercode.co.uk/licks/gems/growl
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Creates a Growl notification with a custom title and body.
|
9
|
+
|
10
|
+
=== Available options:
|
11
|
+
:sticky: Make a sticky notification. Default is false
|
12
|
+
:title: Notification title. Defaults to 'Script Notification'
|
13
|
+
|
14
|
+
=== Example
|
15
|
+
%W[rubygems growl].each { |r| require r }
|
16
|
+
msg = "1 inch man - Gimme more"
|
17
|
+
notification = Autometal::Growl.new(msg, :title => "Welcome to Sky Valley")
|
18
|
+
notification.transmit!
|
19
|
+
|
20
|
+
== REQUIREMENTS:
|
21
|
+
|
22
|
+
Depends on Bob Harris' growl Shell script http://hints.macworld.com/dlfiles/growl_sh.txt
|
23
|
+
|
24
|
+
== INSTALL:
|
25
|
+
|
26
|
+
sudo gem install growl
|
27
|
+
|
28
|
+
After installation, please run:
|
29
|
+
sudo install_growl
|
30
|
+
|
31
|
+
This will install the required shellscript
|
32
|
+
|
33
|
+
== LICENSE:
|
34
|
+
|
35
|
+
(The MIT License)
|
36
|
+
|
37
|
+
Copyright (c) 2010 Achillefs Charmpilas
|
38
|
+
|
39
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
40
|
+
a copy of this software and associated documentation files (the
|
41
|
+
'Software'), to deal in the Software without restriction, including
|
42
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
43
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
44
|
+
permit persons to whom the Software is furnished to do so, subject to
|
45
|
+
the following conditions:
|
46
|
+
|
47
|
+
The above copyright notice and this permission notice shall be
|
48
|
+
included in all copies or substantial portions of the Software.
|
49
|
+
|
50
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
51
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
52
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
53
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
54
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
55
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
56
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/growl'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'autometal-growl' do
|
14
|
+
self.developer 'Achillefs Charmpilas', 'ac@humbuckercode.co.uk'
|
15
|
+
self.post_install_message = File.read("PostInstall.txt")
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'newgem/tasks'
|
20
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
21
|
+
|
22
|
+
task :default => [:install, :test]
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{autometal-growl}
|
5
|
+
s.version = "1.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Achillefs Charmpilas"]
|
9
|
+
s.date = %q{2010-09-16}
|
10
|
+
s.default_executable = %q{install_growl}
|
11
|
+
s.description = %q{Creates a Growl notification with a custom title and body.}
|
12
|
+
s.email = ["ac@humbuckercode.co.uk"]
|
13
|
+
s.executables = ["install_growl"]
|
14
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
|
15
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "bin/install_growl", "lib/growl.rb", "script/console", "script/destroy", "script/generate", "shellscripts/growl", "tasks/install.rake", "test/test_growl.rb", "test/test_helper.rb"]
|
16
|
+
s.homepage = %q{http://github.com/Achillefs/growl}
|
17
|
+
s.post_install_message = %q{
|
18
|
+
Thanks for installing growl.
|
19
|
+
|
20
|
+
Please run +sudo install_growl+ to complete the installation
|
21
|
+
|
22
|
+
For more information, see http://humbuckercode.co.uk/licks/gems/growl
|
23
|
+
|
24
|
+
}
|
25
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
s.rubyforge_project = %q{autometal-growl}
|
28
|
+
s.rubygems_version = %q{1.3.7}
|
29
|
+
s.summary = %q{Creates a Growl notification with a custom title and body.}
|
30
|
+
s.test_files = ["test/test_growl.rb", "test/test_helper.rb"]
|
31
|
+
|
32
|
+
if s.respond_to? :specification_version then
|
33
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
34
|
+
s.specification_version = 3
|
35
|
+
|
36
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
37
|
+
s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
|
38
|
+
s.add_development_dependency(%q<hoe>, [">= 2.6.2"])
|
39
|
+
else
|
40
|
+
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
|
41
|
+
s.add_dependency(%q<hoe>, [">= 2.6.2"])
|
42
|
+
end
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
|
45
|
+
s.add_dependency(%q<hoe>, [">= 2.6.2"])
|
46
|
+
end
|
47
|
+
end
|
data/bin/install_growl
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
puts "Checking for existing +growl+ installation..."
|
3
|
+
test_cmd = %[G_TITLE="Autometal::Growl" growl -nosticky "+growl+ correctly installed and executable."]
|
4
|
+
result = system test_cmd
|
5
|
+
unless result
|
6
|
+
File.open(File.join("/","usr","local","bin","growl"),"w") do |f|
|
7
|
+
f.puts File.read("./shellscripts/growl")
|
8
|
+
f.chmod 0755
|
9
|
+
end
|
10
|
+
system test_cmd
|
11
|
+
puts "Installation complete."
|
12
|
+
else
|
13
|
+
puts "+growl+ is present, exiting."
|
14
|
+
end
|
15
|
+
puts "Done."
|
data/lib/growl.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
module Autometal # :nodoc:
|
5
|
+
class GrowlException < Exception # :nodoc:
|
6
|
+
def initialize
|
7
|
+
raise "Something went wrong. Make sure +growl+ is in your path by running +sudo install_growl+"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Creates a Growl notification with a custom title and body.
|
12
|
+
# Depends on Bob Harris' growl Shell script +http://hints.macworld.com/dlfiles/growl_sh.txt+
|
13
|
+
# You will need to download, install, make executable and include the script path in your path.
|
14
|
+
#
|
15
|
+
# Refer to +http://hints.macworld.com/dlfiles/growl_sh.txt+ for installation details
|
16
|
+
#
|
17
|
+
# = Available options:
|
18
|
+
# :sticky: Make a sticky notification. Default is false
|
19
|
+
# :title: Notification title. Defaults to 'Script Notification'
|
20
|
+
#
|
21
|
+
# = Example
|
22
|
+
# notification = Autometal::Growl.new(msg, :title => "Welcome to Sky Valley")
|
23
|
+
# notification.transmit!
|
24
|
+
class Growl
|
25
|
+
VERSION = "1.0.0"
|
26
|
+
attr_accessor :body, :sticky, :title
|
27
|
+
def initialize body, opts = {}
|
28
|
+
raise ArgumentError.new("Please provide a notification body") if [nil, false, ""].include?(body)
|
29
|
+
@title = opts.delete(:title) || "Script notification"
|
30
|
+
@body = body
|
31
|
+
@sticky = opts[:sticky] == nil ? true : opts.delete(:sticky)
|
32
|
+
end
|
33
|
+
|
34
|
+
def transmit!
|
35
|
+
response = execute_shell_command
|
36
|
+
raise Autometal::GrowlException.new unless response
|
37
|
+
end
|
38
|
+
private
|
39
|
+
def execute_shell_command
|
40
|
+
system %[G_TITLE="#{title}" growl #{sticky ? "-sticky" : "-nosticky"} "#{body}"]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/growl.rb'}"
|
9
|
+
puts "Loading growl gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/shellscripts/growl
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#-----------------------------------------------------------------------------
|
3
|
+
# growl - Send the a message to Mac OS X Growl <http://growl.info> via a
|
4
|
+
# Unix shell script.
|
5
|
+
#
|
6
|
+
# And if this is a Linux or Windows_NT box, use ssh to forward the
|
7
|
+
# growl notice to my Mac OS X workstation (taking advantage of
|
8
|
+
# previously exchanged ssh so no additional authentication is
|
9
|
+
# needed).
|
10
|
+
#
|
11
|
+
# This script should be somewhere in your PATH. I like to use
|
12
|
+
# $HOME/bin for personal scripts, and /usr/local/bin for system
|
13
|
+
# wide scripts, with appropriate entries added to PATH. The script
|
14
|
+
# needs to be executable:
|
15
|
+
#
|
16
|
+
# chmod +x $HOME/bin/growl
|
17
|
+
#
|
18
|
+
# The basics for the Growl Applescript came from the Growl
|
19
|
+
# documentation at:
|
20
|
+
# <http://growl.info/documentation/applescript-support.php>
|
21
|
+
#-----------------------------------------------------------------------------
|
22
|
+
# Bob Harris - 2-Jun-2007
|
23
|
+
#-----------------------------------------------------------------------------
|
24
|
+
|
25
|
+
|
26
|
+
#--- usage -------------------------------------------------------------------
|
27
|
+
usage()
|
28
|
+
{
|
29
|
+
echo 1>&2 ""
|
30
|
+
echo 1>&2 "Usage: growl [options] \"message to display\""
|
31
|
+
echo 1>&2 ""
|
32
|
+
echo 1>&2 " -sticky - Stays on screen until dismissed [Default]."
|
33
|
+
echo 1>&2 " -nosticky - Goes away after several seconds."
|
34
|
+
echo 1>&2 " -priority n - Priority -2,-1,0,1,2 [Default: 0]"
|
35
|
+
echo 1>&2 " -verylow - priority [-2]"
|
36
|
+
echo 1>&2 " -moderate - priority [-1]"
|
37
|
+
echo 1>&2 " -normal - priority [0] [Default]"
|
38
|
+
echo 1>&2 " -high - priority [1]"
|
39
|
+
echo 1>&2 " -emergency - priority [2]"
|
40
|
+
echo 1>&2 ""
|
41
|
+
echo 1>&2 " Interesting environment variables:"
|
42
|
+
echo 1>&2 " G_TITLE - Used as the Growl message title."
|
43
|
+
echo 1>&2 " G_APPLICATION_NAME - Used by Growl to manage a set of"
|
44
|
+
echo 1>&2 " G_WITH_NAME message configurations."
|
45
|
+
echo 1>&2 " See System Preferences -> Growl"
|
46
|
+
echo 1>&2 " G_ALL_NAMES - Used to specify 'ALL' the possible"
|
47
|
+
echo 1>&2 " G_WITH_NAME values this"
|
48
|
+
echo 1>&2 " G_APPLICATION_NAME will ever use."
|
49
|
+
echo 1>&2 " Specify something like:"
|
50
|
+
echo 1>&2 " G_ALL_NAMES='\"class1\",\"class2\"'"
|
51
|
+
echo 1>&2 " export G_ALL_NAMES"
|
52
|
+
echo 1>&2 " G_WITH_NAME - Used by Growl to associate a"
|
53
|
+
echo 1>&2 " message with a set of Growl"
|
54
|
+
echo 1>&2 " notification settings, such as"
|
55
|
+
echo 1>&2 " message style and colors associated"
|
56
|
+
echo 1>&2 " with different priorities. See"
|
57
|
+
echo 1>&2 " System preferences -> Growl"
|
58
|
+
echo 1>&2 " Specify something like:"
|
59
|
+
echo 1>&2 " G_WITH_NAME='class2'"
|
60
|
+
echo 1>&2 " export G_WITH_NAME"
|
61
|
+
echo 1>&2 " If G_WITH_NAME is not in"
|
62
|
+
echo 1>&2 " G_ALL_NAMES, nothing will be"
|
63
|
+
echo 1>&2 " displayed"
|
64
|
+
echo 1>&2 " G_APPLICATION_ICON - Display this application's icon in"
|
65
|
+
echo 1>&2 " the Growl message (default is"
|
66
|
+
echo 1>&2 " Terminal.app, as this is a shell"
|
67
|
+
echo 1>&2 " script generated Growl notice)."
|
68
|
+
echo 1>&2 ""
|
69
|
+
exit 1
|
70
|
+
}
|
71
|
+
|
72
|
+
|
73
|
+
#--- defaults ----------------------------------------------------------------
|
74
|
+
defaults()
|
75
|
+
{
|
76
|
+
#
|
77
|
+
# These 2 variables are used when this script notices that it is on a Linux
|
78
|
+
# or Windows_NT system, then this script uses ssh to forward the request to
|
79
|
+
# my Mac OS X workstation. This assumes that ssh keys have been exchanged
|
80
|
+
# between the systems so that no passwords are needed. If you don't know
|
81
|
+
# what this means, then do a Google search for something like
|
82
|
+
# "ssh nopassword key" and you should turn up a number of guides for
|
83
|
+
# configuring ssh.
|
84
|
+
#
|
85
|
+
G_REMOTE="${G_REMOTE:-juggle-mac.us.oracle.com}" # assumes ssh exchanged keys
|
86
|
+
G_REMOTE_GROWL="${G_REMOTE_GROWL:-bin/growl}" # growl script remote location
|
87
|
+
|
88
|
+
#
|
89
|
+
# G_APPLICATION_NAME is the name Growl will use in the Growl System
|
90
|
+
# Preferences to provide defaults for Display, and to collect each of your
|
91
|
+
# notification classes (See G_ALL_NAMES below).
|
92
|
+
#
|
93
|
+
G_APPLICATION_NAME="${G_APPLICATION_NAME:-Shell Script Growl Message}"
|
94
|
+
#
|
95
|
+
# G_ALL_NAMES contains a list of all the notification classes to be
|
96
|
+
# associated with the G_APPLICATION_NAME. Each notification class can have
|
97
|
+
# its own default Display, Priority, and Stickness settings in the Growl
|
98
|
+
# System Preferences.
|
99
|
+
#
|
100
|
+
G_ALL_NAMES="${G_ALL_NAMES:-\"Shell Script Growl Message\",\"Growl Message\"}"
|
101
|
+
#
|
102
|
+
# The default notification class this message should use, must be in the
|
103
|
+
# G_ALL_NAMES list above.
|
104
|
+
#
|
105
|
+
G_WITH_NAME="${G_WITH_NAME:-Shell Script Growl Message}" # default notification
|
106
|
+
#
|
107
|
+
G_TITLE="${G_TITLE:-Shell Script Growl Message}" # default title
|
108
|
+
G_APPLICATION_ICON="${G_APPLICATION_ICON:-Terminal.app}" # default icon to use
|
109
|
+
G_STICKY="${G_STICKY:-yes}" # default sticky setting
|
110
|
+
G_PRIORITY="${G_PRIORITY:-0}" # default priority (normal)
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
#--- growl -------------------------------------------------------------------
|
115
|
+
# notify v : Post a notification to be displayed via Growl
|
116
|
+
# notify
|
117
|
+
# with name string : name of the notification to display
|
118
|
+
# title string : title of the notification to display
|
119
|
+
# description string : full text of the notification to display
|
120
|
+
# application name string : name of the application posting the
|
121
|
+
# notification.
|
122
|
+
# [image from location location_reference]
|
123
|
+
# : Location of the image file to use for this
|
124
|
+
# notification. Accepts aliases, paths and
|
125
|
+
# file:/// URLs.
|
126
|
+
# [icon of file location_reference]
|
127
|
+
# : Location of the file whose icon should be
|
128
|
+
# used as the image for this notification.
|
129
|
+
# Accepts aliases, paths and file:/// URLs.
|
130
|
+
# e.g. 'file:///Applications'.
|
131
|
+
# [icon of application string]
|
132
|
+
# : Name of the application whose icon should
|
133
|
+
# be used for this notification. For
|
134
|
+
# example, 'Mail.app'.
|
135
|
+
# [image Image] : TIFF Image to be used for the
|
136
|
+
# notification.
|
137
|
+
# [pictImage Picture] : PICT Image to be used for the
|
138
|
+
# notification.
|
139
|
+
# [sticky boolean] : whether or not the notification displayed
|
140
|
+
# should time out. Defaults to 'no'.
|
141
|
+
# [priority integer] : The priority of the notification, from -2
|
142
|
+
# (low) to 0 (normal) to 2 (emergency).
|
143
|
+
#
|
144
|
+
growl()
|
145
|
+
{
|
146
|
+
typeset description="$*"
|
147
|
+
|
148
|
+
osascript <<EOD
|
149
|
+
-- From <http://growl.info/documentation/applescript-support.php>
|
150
|
+
--
|
151
|
+
tell application "GrowlHelperApp"
|
152
|
+
-- Make a list of all the notification types that this script will ever send:
|
153
|
+
set the allNotificationsList to {${G_ALL_NAMES}}
|
154
|
+
|
155
|
+
-- Make a list of the notifications that will be enabled by default.
|
156
|
+
-- Those not enabled by default can be enabled later in the 'Applications'
|
157
|
+
-- tab of the growl prefpane.
|
158
|
+
set the enabledNotificationsList to {"${G_WITH_NAME}"}
|
159
|
+
|
160
|
+
-- Register our script with growl. You can optionally (as here) set a
|
161
|
+
-- default icon for this script's notifications.
|
162
|
+
register as application "${G_APPLICATION_NAME}" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "${G_APPLICATION_ICON}"
|
163
|
+
|
164
|
+
-- Send a Notification...
|
165
|
+
notify with name "${G_WITH_NAME}" title "${G_TITLE}" description "${description}" application name "${G_APPLICATION_NAME}" sticky ${G_STICKY} priority ${G_PRIORITY}
|
166
|
+
|
167
|
+
end tell
|
168
|
+
EOD
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
#--- main --------------------------------------------------------------------
|
173
|
+
#{
|
174
|
+
if [[ $# = 0 ]]; then
|
175
|
+
#
|
176
|
+
# No arguments, so give the usage message.
|
177
|
+
#
|
178
|
+
usage
|
179
|
+
exit 1
|
180
|
+
fi
|
181
|
+
while [[ "X$1" = X-* ]]
|
182
|
+
do
|
183
|
+
if [[ "X$1" = X-nos* ]]; then
|
184
|
+
G_STICKY=no
|
185
|
+
elif [[ "X$1" = X-s* ]]; then
|
186
|
+
G_STICKY=yes
|
187
|
+
elif [[ "X$1" = X-p* ]]; then
|
188
|
+
G_PRIORITY="$2"
|
189
|
+
G_TITLE="${G_TITLE:-Priority $2}"
|
190
|
+
OPTIONS="$OPTIONS $1"
|
191
|
+
shift
|
192
|
+
elif [[ "X$1" = X-v* ]]; then
|
193
|
+
G_PRIORITY="-2"
|
194
|
+
G_TITLE="${G_TITLE:-Very Low Priority}"
|
195
|
+
elif [[ "X$1" = X-m* ]]; then
|
196
|
+
G_PRIORITY="-1"
|
197
|
+
G_TITLE="${G_TITLE:-Moderate Priority}"
|
198
|
+
elif [[ "X$1" = X-n* ]]; then
|
199
|
+
G_PRIORITY="0"
|
200
|
+
G_TITLE="${G_TITLE:-Normal Priority}"
|
201
|
+
elif [[ "X$1" = X-h* ]]; then
|
202
|
+
G_PRIORITY="1"
|
203
|
+
G_TITLE="${G_TITLE:-High Priority}"
|
204
|
+
elif [[ "X$1" = X-e* ]]; then
|
205
|
+
G_PRIORITY="2"
|
206
|
+
G_TITLE="${G_TITLE:-Emergency Priority}"
|
207
|
+
else
|
208
|
+
break;
|
209
|
+
fi
|
210
|
+
OPTIONS="$OPTIONS $1"
|
211
|
+
shift
|
212
|
+
done
|
213
|
+
|
214
|
+
#
|
215
|
+
# If any of the option variables have not been set yet, then apply the
|
216
|
+
# default values now.
|
217
|
+
#
|
218
|
+
defaults
|
219
|
+
|
220
|
+
UNAME=$(uname)
|
221
|
+
if [[ "$UNAME" = Darwin ]]; then
|
222
|
+
#
|
223
|
+
# I'm assuming this is one of my systems where I have Growl
|
224
|
+
# installed.
|
225
|
+
#
|
226
|
+
growl "$*"
|
227
|
+
elif [[ "$UNAME" = *Linux* || "$UNAME" = *Windows_NT* ]]; then
|
228
|
+
#
|
229
|
+
# Must be one of the development systems I work on, so lets ship
|
230
|
+
# this request to my Mac OS X workstation.
|
231
|
+
#
|
232
|
+
ssh ${G_REMOTE} ${G_REMOTE_GROWL} $OPTIONS "$*"
|
233
|
+
else
|
234
|
+
#
|
235
|
+
# I don't know what this is, so I'll just try to Growl anyway. It
|
236
|
+
# will most likely fail (no osascript would be my guess), but what
|
237
|
+
# do I have to loose at this point!
|
238
|
+
#
|
239
|
+
growl "$*"
|
240
|
+
fi
|
241
|
+
#}
|
data/tasks/install.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc "Install +growl+ executable script if necessary"
|
2
|
+
task :install do
|
3
|
+
puts "Checking for existing +growl+ installation..."
|
4
|
+
test_cmd = %[G_TITLE="Autometal::Growl" growl -nosticky "+growl+ correctly installed and executable."]
|
5
|
+
result = system test_cmd
|
6
|
+
unless result
|
7
|
+
File.open(File.join("/","usr","local","bin","growl"),"w") do |f|
|
8
|
+
f.puts File.read("./shellscripts/growl")
|
9
|
+
f.chmod 0755
|
10
|
+
end
|
11
|
+
system test_cmd
|
12
|
+
puts "Installation complete."
|
13
|
+
else
|
14
|
+
puts "+growl+ is present, exiting."
|
15
|
+
end
|
16
|
+
puts "Done."
|
17
|
+
end
|
data/test/test_growl.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestGrowl < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@notification = Autometal::Growl.new("body", :title => "Test Suite", :sticky => false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_executable
|
10
|
+
test_cmd = %[G_TITLE="+growl+ Test suite" growl -nosticky "The executable script is in place and accessible"]
|
11
|
+
assert system(test_cmd), true
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_cannot_initialize_notiication_without_body
|
15
|
+
["",nil,false].each do |fail|
|
16
|
+
assert_raises ArgumentError do
|
17
|
+
Autometal::Growl.new(fail)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_notification_transmission
|
23
|
+
@notification.body = "Assert nothing raised on Autometal::Growl#transmit"
|
24
|
+
assert_nothing_raised { @notification.transmit! }
|
25
|
+
end
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autometal-growl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Achillefs Charmpilas
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-17 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rubyforge
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 4
|
34
|
+
version: 2.0.4
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hoe
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 19
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 6
|
49
|
+
- 2
|
50
|
+
version: 2.6.2
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
description: Creates a Growl notification with a custom title and body.
|
54
|
+
email:
|
55
|
+
- ac@humbuckercode.co.uk
|
56
|
+
executables:
|
57
|
+
- install_growl
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files:
|
61
|
+
- History.txt
|
62
|
+
- Manifest.txt
|
63
|
+
- PostInstall.txt
|
64
|
+
files:
|
65
|
+
- History.txt
|
66
|
+
- Manifest.txt
|
67
|
+
- PostInstall.txt
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- autometal-growl.gemspec
|
71
|
+
- bin/install_growl
|
72
|
+
- lib/growl.rb
|
73
|
+
- script/console
|
74
|
+
- script/destroy
|
75
|
+
- script/generate
|
76
|
+
- shellscripts/growl
|
77
|
+
- tasks/install.rake
|
78
|
+
- test/test_growl.rb
|
79
|
+
- test/test_helper.rb
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/Achillefs/growl
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message: |+
|
85
|
+
|
86
|
+
Thanks for installing growl.
|
87
|
+
|
88
|
+
Please run +sudo install_growl+ to complete the installation
|
89
|
+
|
90
|
+
For more information, see http://humbuckercode.co.uk/licks/gems/growl
|
91
|
+
|
92
|
+
rdoc_options:
|
93
|
+
- --main
|
94
|
+
- README.rdoc
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project: autometal-growl
|
118
|
+
rubygems_version: 1.3.7
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: Creates a Growl notification with a custom title and body.
|
122
|
+
test_files:
|
123
|
+
- test/test_growl.rb
|
124
|
+
- test/test_helper.rb
|