growl_notify 0.0.1
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/.gitignore +4 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +2 -0
- data/Readme.md +67 -0
- data/growl_notify.gemspec +26 -0
- data/lib/growl_notify.rb +70 -0
- data/lib/growl_notify/version.rb +3 -0
- data/spec/growl_icon.png +0 -0
- data/spec/growl_notify_spec.rb +92 -0
- data/spec/spec_helper.rb +1 -0
- metadata +122 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Scott Davis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/Readme.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# GrowlNotify
|
2
|
+
|
3
|
+
This gem is based on the rp-appscript bindings to applescript
|
4
|
+
|
5
|
+
Benefits over all other growl gems:
|
6
|
+
|
7
|
+
1. The user doesn't need to do anything but install the gem - no growl settings need to be changed and `growlnotify` cli doesn't need to be installed
|
8
|
+
2. Thats about it
|
9
|
+
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
### Configuring
|
14
|
+
|
15
|
+
GrowlNotify.config do |config|
|
16
|
+
config.notifications = ["Compass Application", "Someother Notification"]
|
17
|
+
config.default_notifications = ["Compass Application"]
|
18
|
+
config.application_name = "My Application" #this shoes up in the growl applications list in systems settings
|
19
|
+
end
|
20
|
+
|
21
|
+
You can also set a globally scoped icon:
|
22
|
+
|
23
|
+
GrowlNotify.config do |config|
|
24
|
+
config.notifications = ["Compass Application", "Someother Notification"]
|
25
|
+
config.default_notifications = ["Compass Application"]
|
26
|
+
config.application_name = "My Application" #this shoes up in the growl applications list in systems settings
|
27
|
+
config.icon = File.join("SOME PATH")
|
28
|
+
end
|
29
|
+
|
30
|
+
### Using
|
31
|
+
|
32
|
+
#### Notification levels:
|
33
|
+
|
34
|
+
1. very_low: `GrowlNotify.very_low(:title => 'HELLO WORLD', :description => 'Man that was cool')`
|
35
|
+
2. moderate: `GrowlNotify.moderate(:title => 'HELLO WORLD', :description => 'Man that was cool')`
|
36
|
+
3. normal: `GrowlNotify.normal(:title => 'HELLO WORLD', :description => 'Man that was cool')`
|
37
|
+
4. high: `GrowlNotify.high(:title => 'HELLO WORLD', :description => 'Man that was cool')`
|
38
|
+
5. emergency: `GrowlNotify.emergency(:title => 'HELLO WORLD', :description => 'Man that was cool')`
|
39
|
+
|
40
|
+
#### Sticky messages
|
41
|
+
|
42
|
+
`GrowlNotify.sticky!(:title => 'HELLO WORLD', :description => 'Man that was cool')`
|
43
|
+
|
44
|
+
#### Options
|
45
|
+
|
46
|
+
{:title => 'no title', :application_name => "My Application", :description => 'no description', :sticky => false, :priority => 0, :with_name => "Compass Application", :icon => <file path>}
|
47
|
+
|
48
|
+
1. title - Title of message box
|
49
|
+
2. description - Body of your message
|
50
|
+
3. icon - Icon to show - pretty much all image formats are supported
|
51
|
+
4. priority - importance of message from -2 very_low .. 2 emergency
|
52
|
+
5. sticky - boolean if want the message to stick to the screen
|
53
|
+
6. application_name - This is set from configs but you can override it
|
54
|
+
7. with_name - must me one of your set default notifications by default its set to the first one
|
55
|
+
|
56
|
+
|
57
|
+
## Aurthor
|
58
|
+
|
59
|
+
GrowlNotify is written by [Scott Davis](http://sdavis.info)
|
60
|
+
|
61
|
+
Scott is a Developer for the Space Telescope Science Institute in Baltimore, MD - [Hubble Space Telescope](http://hubblesite.org)
|
62
|
+
|
63
|
+
[Twitter](http://twitter.com/jetviper21)
|
64
|
+
|
65
|
+
## Copyright
|
66
|
+
|
67
|
+
Copyright (c) 2011 Scott Davis. See LICENSE.txt for further details.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "growl_notify/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "growl_notify"
|
7
|
+
s.version = GrowlNotify::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Scott Davis"]
|
10
|
+
s.email = ["jetviper21@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/jetviper21/growl_notify"
|
12
|
+
s.summary = %q{Growl.info Library that uses applescipt bindings to interface with growl}
|
13
|
+
s.description = <<-DESC
|
14
|
+
This gem is based on the rp-appscript bindings to applescript
|
15
|
+
Benefits over all other growl gems: The user doesn't need to do anything but install the gem - no growl settings need to be changed and growlnotify cli doesn't need to be installed
|
16
|
+
DESC
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
s.add_dependency 'rb-appscript'
|
23
|
+
s.add_development_dependency 'rspec'
|
24
|
+
s.add_development_dependency 'autotest'
|
25
|
+
|
26
|
+
end
|
data/lib/growl_notify.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'appscript'
|
2
|
+
|
3
|
+
class GrowlNotify
|
4
|
+
|
5
|
+
class << self
|
6
|
+
include Appscript
|
7
|
+
|
8
|
+
attr_accessor :application_name, :default_notifications, :notifications, :icon
|
9
|
+
@application_name = "Ruby Growl"
|
10
|
+
@default_notifications = []
|
11
|
+
@notifications = []
|
12
|
+
@icon = nil
|
13
|
+
|
14
|
+
def config(&block)
|
15
|
+
block.call(self)
|
16
|
+
register
|
17
|
+
end
|
18
|
+
|
19
|
+
def reset!
|
20
|
+
[:application_name, :default_notifications, :notifications, :icon].each do |meth|
|
21
|
+
send(:"#{meth}=", nil)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def register
|
26
|
+
app("GrowlHelperApp").register(:all_notifications => @notifications, :as_application => @application_name, :default_notifications => @default_notifications)
|
27
|
+
end
|
28
|
+
|
29
|
+
def send_notification(options= {})
|
30
|
+
defaults = {:title => 'no title', :application_name => @application_name, :description => 'no description', :sticky => false, :priority => 0, :with_name => notifications.first}
|
31
|
+
local_icon = @icon
|
32
|
+
local_icon = options.delete(:icon) if options.include?(:icon)
|
33
|
+
if local_icon
|
34
|
+
defaults.merge!(:image_from_location => local_icon)
|
35
|
+
end
|
36
|
+
app("GrowlHelperApp").notify(defaults.merge(options))
|
37
|
+
end
|
38
|
+
|
39
|
+
def very_low(options={})
|
40
|
+
options.merge!(:priority => -2)
|
41
|
+
send_notification(options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def moderate(options={})
|
45
|
+
options.merge!(:priority => -1)
|
46
|
+
send_notification(options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def normal(options={})
|
50
|
+
options.merge!(:priority => 0)
|
51
|
+
send_notification(options)
|
52
|
+
end
|
53
|
+
|
54
|
+
def high(options={})
|
55
|
+
options.merge!(:priority => 1)
|
56
|
+
send_notification(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def emergency(options={})
|
60
|
+
options.merge!(:priority => 2)
|
61
|
+
send_notification(options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def sticky!(options={})
|
65
|
+
options.merge!(:sticky => true)
|
66
|
+
send_notification(options)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/spec/growl_icon.png
ADDED
Binary file
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
ICON = File.join(File.expand_path('../', __FILE__), 'growl_icon.png')
|
3
|
+
describe GrowlNotify do
|
4
|
+
it "should reset the configs" do
|
5
|
+
GrowlNotify.config do |config|
|
6
|
+
config.notifications = config.default_notifications = ["foo"]
|
7
|
+
config.application_name = config.notifications.first
|
8
|
+
end
|
9
|
+
GrowlNotify.notifications.should == ["foo"]
|
10
|
+
GrowlNotify.reset!
|
11
|
+
GrowlNotify.notifications.should be_nil
|
12
|
+
end
|
13
|
+
after :each do
|
14
|
+
GrowlNotify.reset!
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'default' do
|
18
|
+
before do
|
19
|
+
GrowlNotify.config do |config|
|
20
|
+
config.notifications = config.default_notifications = ["Compass Application"]
|
21
|
+
config.application_name = config.notifications.first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should send a growl notification with icon" do
|
26
|
+
GrowlNotify.send_notification(:title => 'GrowlNotify Spec', :description => 'This is my descripton', :icon => ICON).should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'no icon' do
|
31
|
+
before do
|
32
|
+
GrowlNotify.config do |config|
|
33
|
+
config.notifications = config.default_notifications = ["Compass Application"]
|
34
|
+
config.application_name = config.notifications.first
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should send a growl notification with icon" do
|
39
|
+
GrowlNotify.send_notification(:title => 'GrowlNotify Spec', :description => 'This is my descripton no icon').should be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'config with icon' do
|
44
|
+
before do
|
45
|
+
GrowlNotify.config do |config|
|
46
|
+
config.notifications = config.default_notifications = ["Compass Application"]
|
47
|
+
config.application_name = config.notifications.first
|
48
|
+
config.icon = ICON
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should send a growl notification with icon" do
|
53
|
+
GrowlNotify.send_notification(:title => 'GrowlNotify Spec', :description => 'This is my descripton with a global icon').should be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "helper methods" do
|
58
|
+
before do
|
59
|
+
GrowlNotify.config do |config|
|
60
|
+
config.notifications = config.default_notifications = ["Compass Application"]
|
61
|
+
config.application_name = config.notifications.first
|
62
|
+
config.icon = ICON
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should send 'very low'" do
|
67
|
+
GrowlNotify.very_low(:title => 'GrowlNotify Spec', :description => 'This is my "very_low" message').should be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should send 'moderate'" do
|
71
|
+
GrowlNotify.moderate(:title => 'GrowlNotify Spec', :description => 'This is my "moderate" message').should be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should send 'normal'" do
|
75
|
+
GrowlNotify.normal(:title => 'GrowlNotify Spec', :description => 'This is my "normal" message').should be_nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should send 'high'" do
|
79
|
+
GrowlNotify.high(:title => 'GrowlNotify Spec', :description => 'This is my "high" message').should be_nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should send 'emergency'" do
|
83
|
+
GrowlNotify.emergency(:title => 'GrowlNotify Spec', :description => 'This is my "emergency" message').should be_nil
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should send 'sticky'" do
|
87
|
+
GrowlNotify.sticky!(:title => 'GrowlNotify Spec', :description => 'This is my "Sticky!" message').should be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'growl_notify'
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: growl_notify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Scott Davis
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-17 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rb-appscript
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: autotest
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: " This gem is based on the rp-appscript bindings to applescript\n Benefits over all other growl gems: The user doesn't need to do anything but install the gem - no growl settings need to be changed and growlnotify cli doesn't need to be installed\n"
|
64
|
+
email:
|
65
|
+
- jetviper21@gmail.com
|
66
|
+
executables: []
|
67
|
+
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
72
|
+
files:
|
73
|
+
- .gitignore
|
74
|
+
- .rspec
|
75
|
+
- Gemfile
|
76
|
+
- LICENSE.txt
|
77
|
+
- Rakefile
|
78
|
+
- Readme.md
|
79
|
+
- growl_notify.gemspec
|
80
|
+
- lib/growl_notify.rb
|
81
|
+
- lib/growl_notify/version.rb
|
82
|
+
- spec/growl_icon.png
|
83
|
+
- spec/growl_notify_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: https://github.com/jetviper21/growl_notify
|
87
|
+
licenses: []
|
88
|
+
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
version: "0"
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 1.5.2
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: Growl.info Library that uses applescipt bindings to interface with growl
|
119
|
+
test_files:
|
120
|
+
- spec/growl_icon.png
|
121
|
+
- spec/growl_notify_spec.rb
|
122
|
+
- spec/spec_helper.rb
|