uniform_notifier 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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +20 -0
- data/README.md +71 -0
- data/Rakefile +2 -0
- data/lib/uniform_notifier/base.rb +21 -0
- data/lib/uniform_notifier/customized_logger.rb +24 -0
- data/lib/uniform_notifier/growl.rb +38 -0
- data/lib/uniform_notifier/javascript_alert.rb +13 -0
- data/lib/uniform_notifier/javascript_console.rb +25 -0
- data/lib/uniform_notifier/rails_logger.rb +12 -0
- data/lib/uniform_notifier/version.rb +3 -0
- data/lib/uniform_notifier/xmpp.rb +50 -0
- data/lib/uniform_notifier.rb +33 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/uniform_notifier/customized_logger_spec.rb +22 -0
- data/spec/uniform_notifier/growl_spec.rb +29 -0
- data/spec/uniform_notifier/javascript_alert_spec.rb +16 -0
- data/spec/uniform_notifier/javascript_console_spec.rb +25 -0
- data/spec/uniform_notifier/rails_logger_spec.rb +20 -0
- data/spec/uniform_notifier/xmpp_spec.rb +51 -0
- data/uniform_notifier.gemspec +25 -0
- metadata +137 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
uniform_notifier (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rspec (2.1.0)
|
11
|
+
rspec-core (~> 2.1.0)
|
12
|
+
rspec-expectations (~> 2.1.0)
|
13
|
+
rspec-mocks (~> 2.1.0)
|
14
|
+
rspec-core (2.1.0)
|
15
|
+
rspec-expectations (2.1.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.1.0)
|
18
|
+
ruby-growl (3.0)
|
19
|
+
xmpp4r (0.5)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
rspec
|
26
|
+
ruby-growl
|
27
|
+
uniform_notifier!
|
28
|
+
xmpp4r
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Richard Huang (flyerhzm@gmail.com)
|
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/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
UniformNotifier
|
2
|
+
===============
|
3
|
+
|
4
|
+
uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, and xmpp.
|
5
|
+
|
6
|
+
Install
|
7
|
+
-------
|
8
|
+
|
9
|
+
1. install directly
|
10
|
+
|
11
|
+
gem install uniform_notifier
|
12
|
+
|
13
|
+
if you want to notify by growl or xmpp, you should install them first
|
14
|
+
|
15
|
+
gem install ruby-growl
|
16
|
+
gem install xmpp4r
|
17
|
+
|
18
|
+
2. add it into Gemfile (Bundler)
|
19
|
+
|
20
|
+
gem "uniform_notifier"
|
21
|
+
|
22
|
+
you should add ruby-growl and xmpp4r gem if you want.
|
23
|
+
|
24
|
+
Usage
|
25
|
+
-----
|
26
|
+
|
27
|
+
There are two types of notifications, one is <code>inline_notify</code>, for javascript alert and javascript console notifiers, which returns a string and will be combined, the other is <code>out_of_channel_notify</code>, for rails logger, customized logger, growl and xmpp, which doesn't return anything, just send the message to the notifiers.
|
28
|
+
|
29
|
+
By default, all notifiers are disabled, you should enable them first.
|
30
|
+
|
31
|
+
# javascript alert
|
32
|
+
UniformNotifier.alert = true
|
33
|
+
|
34
|
+
# javascript console
|
35
|
+
UniformNotifier.console = true
|
36
|
+
|
37
|
+
# rails logger
|
38
|
+
UniformNotifier.rails_logger = true
|
39
|
+
|
40
|
+
# customized logger
|
41
|
+
logger = File.open('notify.log', 'a+')
|
42
|
+
logger.sync = true
|
43
|
+
UniformNotifier.customized_logger = logger
|
44
|
+
|
45
|
+
# growl without password
|
46
|
+
UniformNotifier.growl = true
|
47
|
+
# growl with passowrd
|
48
|
+
UniformNotifier.growl = { :password => 'growl password' }
|
49
|
+
|
50
|
+
# xmpp
|
51
|
+
UniformNotifier.xmpp = { :account => 'bullets_account@jabber.org',
|
52
|
+
:password => 'bullets_password_for_jabber',
|
53
|
+
:receiver => 'your_account@jabber.org',
|
54
|
+
:show_online_status => true }
|
55
|
+
|
56
|
+
After that, you can enjoy the notifiers, that's cool!
|
57
|
+
|
58
|
+
# the notify message will be notified to rails logger, customized logger, growl or xmpp.
|
59
|
+
UniformNotifier.active_notfiiers.out_of_channel_notify(notify_message)
|
60
|
+
|
61
|
+
# the notify message will be wrapped by <script type="text/javascript">...</script>,
|
62
|
+
# you should append the javascript_str at the bottom of http response body.
|
63
|
+
# for more information, please check https://github.com/flyerhzm/bullet/blob/master/lib/bullet/rack.rb
|
64
|
+
responses = []
|
65
|
+
UniformNotifier.active_notifiers.each do |notifier|
|
66
|
+
responses << notifier.inline_notify(notify_message)
|
67
|
+
end
|
68
|
+
javascript_str = responses.join("\n")
|
69
|
+
|
70
|
+
|
71
|
+
[0]: https://github.com/flyerhzm/bullet
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module UniformNotifier
|
2
|
+
class Base
|
3
|
+
def self.active?
|
4
|
+
false
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.inline_notify( message )
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.out_of_channel_notify( message )
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.wrap_js_association( message )
|
14
|
+
<<-CODE
|
15
|
+
<script type="text/javascript">/*<![CDATA[*/
|
16
|
+
#{message}
|
17
|
+
/*]]>*/</script>
|
18
|
+
CODE
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module UniformNotifier
|
2
|
+
class CustomizedLogger < Base
|
3
|
+
@logger = nil
|
4
|
+
|
5
|
+
def self.active?
|
6
|
+
@logger
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.out_of_channel_notify( message )
|
10
|
+
return unless active?
|
11
|
+
@logger.warn message
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.setup(logdev)
|
15
|
+
require 'logger'
|
16
|
+
|
17
|
+
@logger = Logger.new( logdev )
|
18
|
+
|
19
|
+
def @logger.format_message( severity, timestamp, progname, msg )
|
20
|
+
"#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}[#{severity}] #{msg}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module UniformNotifier
|
2
|
+
class Growl < Base
|
3
|
+
@growl = nil
|
4
|
+
|
5
|
+
def self.active?
|
6
|
+
@growl
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.out_of_channel_notify( message )
|
10
|
+
return unless active?
|
11
|
+
notify( message )
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.setup_connection( growl )
|
15
|
+
require 'ruby-growl'
|
16
|
+
@password = growl == true ? nil : growl[:password]
|
17
|
+
@growl = connect
|
18
|
+
|
19
|
+
notify 'Uniform Notifier Growl has been turned on'
|
20
|
+
rescue LoadError
|
21
|
+
@growl = nil
|
22
|
+
raise NotificationError.new( 'You must install the ruby-growl gem to use Growl notification: `gem install ruby-growl`' )
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def self.connect
|
27
|
+
::Growl.new 'localhost',
|
28
|
+
'uniform_notifier',
|
29
|
+
[ 'uniform_notifier' ],
|
30
|
+
nil,
|
31
|
+
@password
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.notify( message )
|
35
|
+
@growl.notify( 'uniform_notifier', 'Uniform Notifier', message )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module UniformNotifier
|
2
|
+
class JavascriptConsole < Base
|
3
|
+
def self.active?
|
4
|
+
UniformNotifier.console
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.inline_notify( message )
|
8
|
+
return unless active?
|
9
|
+
|
10
|
+
code = <<-CODE
|
11
|
+
if (typeof(console) !== 'undefined' && console.log) {
|
12
|
+
if (console.groupCollapsed && console.groupEnd) {
|
13
|
+
console.groupCollapsed(#{"Uniform Notifier".inspect});
|
14
|
+
console.log(#{message.inspect});
|
15
|
+
console.groupEnd();
|
16
|
+
} else {
|
17
|
+
console.log(#{message.inspect});
|
18
|
+
}
|
19
|
+
}
|
20
|
+
CODE
|
21
|
+
|
22
|
+
wrap_js_association code
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module UniformNotifier
|
2
|
+
class Xmpp < Base
|
3
|
+
@receiver = nil
|
4
|
+
@xmpp = nil
|
5
|
+
@password = nil
|
6
|
+
|
7
|
+
def self.active?
|
8
|
+
@xmpp
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.out_of_channel_notify( message )
|
12
|
+
return unless active?
|
13
|
+
notify( message )
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.setup_connection( xmpp_information )
|
17
|
+
require 'xmpp4r'
|
18
|
+
|
19
|
+
@receiver = xmpp_information[:receiver]
|
20
|
+
@password = xmpp_information[:password]
|
21
|
+
@account = xmpp_information[:account]
|
22
|
+
@show_online_status = xmpp_information[:show_online_status]
|
23
|
+
|
24
|
+
connect
|
25
|
+
rescue LoadError
|
26
|
+
@xmpp = nil
|
27
|
+
raise NotificationError.new( 'You must install the xmpp4r gem to use XMPP notification: `gem install xmpp4r`' )
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def self.connect
|
32
|
+
jid = Jabber::JID.new( @account )
|
33
|
+
@xmpp = Jabber::Client.new( jid )
|
34
|
+
@xmpp.connect
|
35
|
+
@xmpp.auth( @password )
|
36
|
+
@xmpp.send( presence_status ) if @show_online_status
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.notify( message )
|
40
|
+
message = Jabber::Message.new( @receiver, message ).
|
41
|
+
set_type( :normal ).
|
42
|
+
set_subject( 'Uniform Notifier' )
|
43
|
+
@xmpp.send( message )
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.presence_status
|
47
|
+
Jabber::Presence.new.set_status( "Uniform Notifier started on #{Time.now}" )
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'uniform_notifier/base'
|
2
|
+
require 'uniform_notifier/javascript_alert'
|
3
|
+
require 'uniform_notifier/javascript_console'
|
4
|
+
require 'uniform_notifier/growl'
|
5
|
+
require 'uniform_notifier/xmpp'
|
6
|
+
require 'uniform_notifier/rails_logger'
|
7
|
+
require 'uniform_notifier/customized_logger'
|
8
|
+
|
9
|
+
module UniformNotifier
|
10
|
+
class NotificationError < StandardError; end
|
11
|
+
|
12
|
+
class <<self
|
13
|
+
attr_accessor :alert, :console, :growl, :rails_logger, :xmpp
|
14
|
+
|
15
|
+
NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, Xmpp, RailsLogger, CustomizedLogger]
|
16
|
+
|
17
|
+
def active_notifiers
|
18
|
+
NOTIFIERS.select { |notifier| notifier.active? }
|
19
|
+
end
|
20
|
+
|
21
|
+
def growl=(growl)
|
22
|
+
UniformNotifier::Growl.setup_connection(growl)
|
23
|
+
end
|
24
|
+
|
25
|
+
def xmpp=(xmpp)
|
26
|
+
UniformNotifier::Xmpp.setup_connection(xmpp)
|
27
|
+
end
|
28
|
+
|
29
|
+
def customized_logger=(logdev)
|
30
|
+
UniformNotifier::CustomizedLogger.setup(logdev)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe UniformNotifier::CustomizedLogger do
|
4
|
+
it "should not notify to customized logger" do
|
5
|
+
UniformNotifier::CustomizedLogger.out_of_channel_notify("notify rails logger").should be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should notify to customized logger" do
|
9
|
+
logger = File.open( 'test.log', 'a+' )
|
10
|
+
logger.sync = true
|
11
|
+
|
12
|
+
now = Time.now
|
13
|
+
Time.stub!(:now).and_return(now)
|
14
|
+
UniformNotifier.customized_logger = logger
|
15
|
+
UniformNotifier::CustomizedLogger.out_of_channel_notify("notify rails logger")
|
16
|
+
|
17
|
+
logger.seek(0)
|
18
|
+
logger.read.should == "#{now.strftime("%Y-%m-%d %H:%M:%S")}[WARN] notify rails logger"
|
19
|
+
|
20
|
+
File.delete('test.log')
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ruby-growl'
|
3
|
+
|
4
|
+
describe UniformNotifier::Growl do
|
5
|
+
|
6
|
+
it "should not notify growl" do
|
7
|
+
UniformNotifier::Growl.out_of_channel_notify('notify growl').should be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should notify growl without password" do
|
11
|
+
growl = double('growl')
|
12
|
+
Growl.should_receive(:new).with('localhost', 'uniform_notifier', ['uniform_notifier'], nil, nil).and_return(growl)
|
13
|
+
growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
|
14
|
+
growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password').ordered
|
15
|
+
|
16
|
+
UniformNotifier.growl = true
|
17
|
+
UniformNotifier::Growl.out_of_channel_notify('notify growl without password')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should notify growl with password" do
|
21
|
+
growl = double('growl')
|
22
|
+
Growl.should_receive(:new).with('localhost', 'uniform_notifier', ['uniform_notifier'], nil, '123456').and_return(growl)
|
23
|
+
growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
|
24
|
+
growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
25
|
+
|
26
|
+
UniformNotifier.growl = { :password => '123456' }
|
27
|
+
UniformNotifier::Growl.out_of_channel_notify('notify growl with password')
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe UniformNotifier::JavascriptAlert do
|
4
|
+
it "should not notify message" do
|
5
|
+
UniformNotifier::JavascriptAlert.inline_notify("javascript alert!").should be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should notify message" do
|
9
|
+
UniformNotifier.alert = true
|
10
|
+
UniformNotifier::JavascriptAlert.inline_notify("javascript alert!").should == <<-CODE
|
11
|
+
<script type="text/javascript">/*<![CDATA[*/
|
12
|
+
alert( "javascript alert!" );
|
13
|
+
/*]]>*/</script>
|
14
|
+
CODE
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe UniformNotifier::JavascriptConsole do
|
4
|
+
it "should not notify message" do
|
5
|
+
UniformNotifier::JavascriptConsole.inline_notify("javascript console!").should be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should notify message" do
|
9
|
+
UniformNotifier.console = true
|
10
|
+
UniformNotifier::JavascriptConsole.inline_notify("javascript console!").should == <<-CODE
|
11
|
+
<script type="text/javascript">/*<![CDATA[*/
|
12
|
+
if (typeof(console) !== 'undefined' && console.log) {
|
13
|
+
if (console.groupCollapsed && console.groupEnd) {
|
14
|
+
console.groupCollapsed(#{"Uniform Notifier".inspect});
|
15
|
+
console.log(#{"javascript console!".inspect});
|
16
|
+
console.groupEnd();
|
17
|
+
} else {
|
18
|
+
console.log(#{"javascript console!".inspect});
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
/*]]>*/</script>
|
23
|
+
CODE
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
class Rails
|
4
|
+
# mock Rails
|
5
|
+
end
|
6
|
+
|
7
|
+
describe UniformNotifier::RailsLogger do
|
8
|
+
it "should not notify rails logger" do
|
9
|
+
UniformNotifier::RailsLogger.out_of_channel_notify("notify rails logger").should be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should notify rails logger" do
|
13
|
+
logger = double("logger")
|
14
|
+
Rails.should_receive(:logger).and_return(logger)
|
15
|
+
logger.should_receive(:warn).with("notify rails logger")
|
16
|
+
|
17
|
+
UniformNotifier.rails_logger = true
|
18
|
+
UniformNotifier::RailsLogger.out_of_channel_notify("notify rails logger")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xmpp4r'
|
3
|
+
|
4
|
+
describe UniformNotifier::Xmpp do
|
5
|
+
it "should not notify xmpp" do
|
6
|
+
UniformNotifier::Xmpp.out_of_channel_notify("notify xmpp").should be_nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should notify xmpp without online status" do
|
10
|
+
jid = double("jid")
|
11
|
+
xmpp = double("xmpp")
|
12
|
+
Jabber::JID.should_receive(:new).with('from@gmail.com').and_return(jid)
|
13
|
+
Jabber::Client.should_receive(:new).with(jid).and_return(xmpp)
|
14
|
+
xmpp.should_receive(:connect)
|
15
|
+
xmpp.should_receive(:auth).with('123456')
|
16
|
+
|
17
|
+
message = double("message")
|
18
|
+
Jabber::Message.should_receive(:new).with('to@gmail.com', 'notify xmpp').and_return(message)
|
19
|
+
message.should_receive(:set_type).with(:normal).and_return(message)
|
20
|
+
message.should_receive(:set_subject).with('Uniform Notifier').and_return(message)
|
21
|
+
xmpp.should_receive(:send).with(message)
|
22
|
+
|
23
|
+
UniformNotifier.xmpp = {:account => 'from@gmail.com', :password => '123456', :receiver => 'to@gmail.com', :show_online_status => false}
|
24
|
+
UniformNotifier::Xmpp.out_of_channel_notify('notify xmpp')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should notify xmpp with online status" do
|
28
|
+
jid = double("jid")
|
29
|
+
xmpp = double("xmpp")
|
30
|
+
Jabber::JID.should_receive(:new).with('from@gmail.com').and_return(jid)
|
31
|
+
Jabber::Client.should_receive(:new).with(jid).and_return(xmpp)
|
32
|
+
xmpp.should_receive(:connect)
|
33
|
+
xmpp.should_receive(:auth).with('123456')
|
34
|
+
|
35
|
+
presence = double("presence")
|
36
|
+
now = Time.now
|
37
|
+
Time.stub!(:now).and_return(now)
|
38
|
+
Jabber::Presence.should_receive(:new).and_return(presence)
|
39
|
+
presence.should_receive(:set_status).with("Uniform Notifier started on #{now}").and_return(presence)
|
40
|
+
xmpp.should_receive(:send).with(presence)
|
41
|
+
|
42
|
+
message = double("message")
|
43
|
+
Jabber::Message.should_receive(:new).with('to@gmail.com', 'notify xmpp').and_return(message)
|
44
|
+
message.should_receive(:set_type).with(:normal).and_return(message)
|
45
|
+
message.should_receive(:set_subject).with('Uniform Notifier').and_return(message)
|
46
|
+
xmpp.should_receive(:send).with(message)
|
47
|
+
|
48
|
+
UniformNotifier.xmpp = {:account => 'from@gmail.com', :password => '123456', :receiver => 'to@gmail.com', :show_online_status => true}
|
49
|
+
UniformNotifier::Xmpp.out_of_channel_notify('notify xmpp')
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "uniform_notifier/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "uniform_notifier"
|
7
|
+
s.version = UniformNotifier::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Richard Huang"]
|
10
|
+
s.email = ["flyerhzm@gmail.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/uniform_notifier"
|
12
|
+
s.summary = %q{uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp}
|
13
|
+
s.description = %q{uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp}
|
14
|
+
|
15
|
+
s.rubyforge_project = "uniform_notifier"
|
16
|
+
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "ruby-growl"
|
19
|
+
s.add_development_dependency "xmpp4r"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uniform_notifier
|
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
|
+
- Richard Huang
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-19 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
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: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: ruby-growl
|
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: xmpp4r
|
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: uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp
|
64
|
+
email:
|
65
|
+
- flyerhzm@gmail.com
|
66
|
+
executables: []
|
67
|
+
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
72
|
+
files:
|
73
|
+
- .gitignore
|
74
|
+
- Gemfile
|
75
|
+
- Gemfile.lock
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- lib/uniform_notifier.rb
|
80
|
+
- lib/uniform_notifier/base.rb
|
81
|
+
- lib/uniform_notifier/customized_logger.rb
|
82
|
+
- lib/uniform_notifier/growl.rb
|
83
|
+
- lib/uniform_notifier/javascript_alert.rb
|
84
|
+
- lib/uniform_notifier/javascript_console.rb
|
85
|
+
- lib/uniform_notifier/rails_logger.rb
|
86
|
+
- lib/uniform_notifier/version.rb
|
87
|
+
- lib/uniform_notifier/xmpp.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/uniform_notifier/customized_logger_spec.rb
|
90
|
+
- spec/uniform_notifier/growl_spec.rb
|
91
|
+
- spec/uniform_notifier/javascript_alert_spec.rb
|
92
|
+
- spec/uniform_notifier/javascript_console_spec.rb
|
93
|
+
- spec/uniform_notifier/rails_logger_spec.rb
|
94
|
+
- spec/uniform_notifier/xmpp_spec.rb
|
95
|
+
- uniform_notifier.gemspec
|
96
|
+
has_rdoc: true
|
97
|
+
homepage: http://rubygems.org/gems/uniform_notifier
|
98
|
+
licenses: []
|
99
|
+
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project: uniform_notifier
|
126
|
+
rubygems_version: 1.3.7
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp
|
130
|
+
test_files:
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
- spec/uniform_notifier/customized_logger_spec.rb
|
133
|
+
- spec/uniform_notifier/growl_spec.rb
|
134
|
+
- spec/uniform_notifier/javascript_alert_spec.rb
|
135
|
+
- spec/uniform_notifier/javascript_console_spec.rb
|
136
|
+
- spec/uniform_notifier/rails_logger_spec.rb
|
137
|
+
- spec/uniform_notifier/xmpp_spec.rb
|