notification 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/CHANGES +6 -0
- data/Manifest.txt +13 -0
- data/README +36 -0
- data/Rakefile +29 -0
- data/example.rb +10 -0
- data/lib/gmail_notifier.rb +18 -0
- data/lib/growl_notifier.rb +16 -0
- data/lib/notification.rb +16 -0
- data/lib/sms_notifier.rb +9 -0
- data/test/gmail_notifier_test.rb +34 -0
- data/test/growl_notifier_test.rb +15 -0
- data/test/sms_notifier_test.rb +15 -0
- data/test/test_helper.rb +5 -0
- metadata +95 -0
data/CHANGES
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
CHANGES
|
2
|
+
Manifest.txt
|
3
|
+
README
|
4
|
+
Rakefile
|
5
|
+
example.rb
|
6
|
+
lib/gmail_notifier.rb
|
7
|
+
lib/growl_notifier.rb
|
8
|
+
lib/notification.rb
|
9
|
+
lib/sms_notifier.rb
|
10
|
+
test/gmail_notifier_test.rb
|
11
|
+
test/growl_notifier_test.rb
|
12
|
+
test/sms_notifier_test.rb
|
13
|
+
test/test_helper.rb
|
data/README
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
= Project: Notification
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
Notification is a one stop shop for notification, it knows how to send messages via GMail, SMS,
|
6
|
+
growl, snarl, etc, and all these are exposed in a simple, uniform way.
|
7
|
+
|
8
|
+
== Usage
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'notification'
|
12
|
+
|
13
|
+
gmail = GmailNotifier.new(:name => 'dsls.in.ruby', :password => 'dslsinruby', :to => 'jeremystellsmith@gmail.com')
|
14
|
+
sms = SmsNotifier.new(gmail, '312-953-1193')
|
15
|
+
growl = GrowlNotifier.new
|
16
|
+
|
17
|
+
message = "Hello World"
|
18
|
+
email.notify(message)
|
19
|
+
sms.notify(message)
|
20
|
+
growl.notify(message)
|
21
|
+
|
22
|
+
== Currently Implemented Notifications
|
23
|
+
|
24
|
+
* GMail
|
25
|
+
* SMS (via teleflip)
|
26
|
+
* Growl
|
27
|
+
|
28
|
+
== Contact
|
29
|
+
|
30
|
+
Author:: Jeremy Stell-Smith
|
31
|
+
Email:: jeremystellsmith@gmail.com
|
32
|
+
License:: LGPL License
|
33
|
+
|
34
|
+
== Home Page
|
35
|
+
|
36
|
+
http://onemanswalk.com
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
$: << File.dirname(__FILE__) + "/lib"
|
7
|
+
require 'notification.rb'
|
8
|
+
|
9
|
+
desc "Default Task"
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
desc "Run all tests"
|
13
|
+
task :test => [:test_units]
|
14
|
+
|
15
|
+
Rake::TestTask.new("test_units") do |t|
|
16
|
+
t.test_files = FileList['test/**/*test.rb']
|
17
|
+
t.verbose = false
|
18
|
+
end
|
19
|
+
|
20
|
+
Hoe.new('notification', Notification::VERSION) do |p|
|
21
|
+
p.rubyforge_name = 'notification'
|
22
|
+
p.summary = p.description = p.paragraphs_of('README', 2).first
|
23
|
+
p.url = p.paragraphs_of('README', -1).first.strip
|
24
|
+
p.author = 'Jeremy Stell-Smith'
|
25
|
+
p.email = 'jeremystellsmith@gmail.com'
|
26
|
+
p.changes = p.paragraphs_of('CHANGES', 0..1).join("\n\n")
|
27
|
+
p.test_globs = ['test/**/*_test.rb']
|
28
|
+
p.extra_deps = ['gmailer','>= 0.1.5'],['ruby-growl','>= 1.0.1'],['mocha','>= 0.3.2']
|
29
|
+
end
|
data/example.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$: << File.dirname(__FILE__) + '/lib'
|
2
|
+
require "notification"
|
3
|
+
|
4
|
+
gmail = GmailNotifier.new(:name => 'dsls.in.ruby', :password => 'dslsinruby', :to => 'jeremystellsmith@gmail.com')
|
5
|
+
sms = SmsNotifier.new(gmail, '404-242-9929')
|
6
|
+
growl = GrowlNotifier.new
|
7
|
+
|
8
|
+
#sms.notify('hey neal, whats up?')
|
9
|
+
#gmail.notify('hello world')
|
10
|
+
#growl.notify('holy cow')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'gmailer'
|
2
|
+
|
3
|
+
class GmailNotifier
|
4
|
+
def initialize(options)
|
5
|
+
@name, @password = options.delete(:name), options.delete(:password)
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def notify(message, options = {})
|
10
|
+
options[:body] = message
|
11
|
+
options[:subject] = message if !options.has_key? :subject
|
12
|
+
@options.each {|k,v| options[k] = v if !options.has_key? k }
|
13
|
+
|
14
|
+
GMailer.connect(@name, @password) do |g|
|
15
|
+
g.send(options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'ruby-growl'
|
2
|
+
|
3
|
+
class GrowlNotifier
|
4
|
+
def initialize(options = {})
|
5
|
+
@application = options[:application] || 'ruby-growl'
|
6
|
+
@to = options[:to]
|
7
|
+
end
|
8
|
+
|
9
|
+
def notify(message, options = {})
|
10
|
+
to = options[:to] || @to || 'localhost'
|
11
|
+
notification_type = "#{@application} notification"
|
12
|
+
|
13
|
+
g = Growl.new to, @application, [notification_type]
|
14
|
+
g.notify notification_type, @application, message
|
15
|
+
end
|
16
|
+
end
|
data/lib/notification.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Notification
|
2
|
+
VERSION = "0.1"
|
3
|
+
end
|
4
|
+
|
5
|
+
def safe_require file
|
6
|
+
require file
|
7
|
+
rescue LoadError
|
8
|
+
puts "#{file} is not available"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
|
13
|
+
safe_require 'gmail_notifier'
|
14
|
+
safe_require 'sms_notifier'
|
15
|
+
safe_require 'growl_notifier'
|
16
|
+
|
data/lib/sms_notifier.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require "notification"
|
3
|
+
|
4
|
+
class GmailNotifierTest < Test::Unit::TestCase
|
5
|
+
def xtest_send_to_gmail
|
6
|
+
gmail = GmailNotifier.new(:name => 'dsls.in.ruby', :password => 'dslsinruby', :to => 'jeremystellsmith@gmail.com')
|
7
|
+
gmail.notify('hello world')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_default_stuff
|
11
|
+
g = Object.new
|
12
|
+
GMailer.expects(:connect).with('user', 'pass').yields(g)
|
13
|
+
g.expects(:send).with(:subject => 'Hello World', :body => 'Hello World', :to => 'out@yahoo.com')
|
14
|
+
|
15
|
+
gmail = GmailNotifier.new(:name => 'user', :password => 'pass', :to => 'out@yahoo.com')
|
16
|
+
gmail.notify("Hello World")
|
17
|
+
|
18
|
+
g.verify
|
19
|
+
GMailer.verify
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_set_options_in_notify
|
23
|
+
g = Object.new
|
24
|
+
GMailer.expects(:connect).yields(g)
|
25
|
+
g.expects(:send).with(:subject => 'Sup', :body => 'You', :to => 'in@yahoo.com', :files => ['some.txt', 'who.rb'])
|
26
|
+
|
27
|
+
gmail = GmailNotifier.new(:name => 'user', :password => 'pass', :to => 'out@yahoo.com')
|
28
|
+
gmail.notify("You", :to => 'in@yahoo.com', :files => ['some.txt', 'who.rb'], :subject => 'Sup')
|
29
|
+
|
30
|
+
g.verify
|
31
|
+
GMailer.verify
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require "notification"
|
3
|
+
|
4
|
+
class GrowlNotifierTest < Test::Unit::TestCase
|
5
|
+
def test_default_stuff
|
6
|
+
g = Object.new
|
7
|
+
Growl.expects(:new).returns(g)
|
8
|
+
g.expects(:notify)
|
9
|
+
|
10
|
+
growl = GrowlNotifier.new
|
11
|
+
growl.notify('help')
|
12
|
+
|
13
|
+
g.verify
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require "notification"
|
3
|
+
|
4
|
+
class SmsNotifierTest < Test::Unit::TestCase
|
5
|
+
def test_notifier
|
6
|
+
email = Object.new
|
7
|
+
email.expects(:notify).with('some message', :to => '3129531193@teleflip.com', :subject => nil)
|
8
|
+
|
9
|
+
sms = SmsNotifier.new(email, '312-953-1193')
|
10
|
+
|
11
|
+
sms.notify('some message')
|
12
|
+
|
13
|
+
email.verify
|
14
|
+
end
|
15
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: notification
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.1"
|
7
|
+
date: 2007-03-21 00:00:00 -07:00
|
8
|
+
summary: Notification is a one stop shop for notification, it knows how to send messages via GMail, SMS, growl, snarl, etc, and all these are exposed in a simple, uniform way.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: jeremystellsmith@gmail.com
|
12
|
+
homepage: http://onemanswalk.com
|
13
|
+
rubyforge_project: notification
|
14
|
+
description: Notification is a one stop shop for notification, it knows how to send messages via GMail, SMS, growl, snarl, etc, and all these are exposed in a simple, uniform way.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Jeremy Stell-Smith
|
31
|
+
files:
|
32
|
+
- CHANGES
|
33
|
+
- Manifest.txt
|
34
|
+
- README
|
35
|
+
- Rakefile
|
36
|
+
- example.rb
|
37
|
+
- lib/gmail_notifier.rb
|
38
|
+
- lib/growl_notifier.rb
|
39
|
+
- lib/notification.rb
|
40
|
+
- lib/sms_notifier.rb
|
41
|
+
- test/gmail_notifier_test.rb
|
42
|
+
- test/growl_notifier_test.rb
|
43
|
+
- test/sms_notifier_test.rb
|
44
|
+
- test/test_helper.rb
|
45
|
+
test_files:
|
46
|
+
- test/gmail_notifier_test.rb
|
47
|
+
- test/growl_notifier_test.rb
|
48
|
+
- test/sms_notifier_test.rb
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
extra_rdoc_files: []
|
52
|
+
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
dependencies:
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: gmailer
|
62
|
+
version_requirement:
|
63
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.1.5
|
68
|
+
version:
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ruby-growl
|
71
|
+
version_requirement:
|
72
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.0.1
|
77
|
+
version:
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mocha
|
80
|
+
version_requirement:
|
81
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.3.2
|
86
|
+
version:
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: hoe
|
89
|
+
version_requirement:
|
90
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.2.0
|
95
|
+
version:
|