Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 119 lines (80 sloc) 4.431 kb
8f6acee @flyerhzm add README and LICENSE
authored
1 UniformNotifier
2 ===============
3
ef41a17 @kosmatov update README
kosmatov authored
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, xmpp and airbrake.
8f6acee @flyerhzm add README and LICENSE
authored
5
6 Install
7 -------
8
8591843 @flyerhzm update README
authored
9 ### install directly
8f6acee @flyerhzm add README and LICENSE
authored
10
11 gem install uniform_notifier
12
471a467 @flyerhzm update README for growl_gntp
authored
13 if you want to notify by growl < v1.3, you should install ruby-growl first
8f6acee @flyerhzm add README and LICENSE
authored
14
15 gem install ruby-growl
471a467 @flyerhzm update README for growl_gntp
authored
16
17 if you want to notify by growl v1.3+, you should install ruby_gntp first
18
19 gem install ruby_gntp
20
21 if you want to notify by xmpp, you should install xmpp4r first
22
8f6acee @flyerhzm add README and LICENSE
authored
23 gem install xmpp4r
24
ef41a17 @kosmatov update README
kosmatov authored
25 if you want to notify by airbrake, you should install airbrake first
26
27 gem install airbrake
28
8591843 @flyerhzm update README
authored
29 ### add it into Gemfile (Bundler)
8f6acee @flyerhzm add README and LICENSE
authored
30
31 gem "uniform_notifier"
32
ef41a17 @kosmatov update README
kosmatov authored
33 you should add ruby-growl, ruby_gntp, xmpp4r, airbrake gem if you want.
8f6acee @flyerhzm add README and LICENSE
authored
34
35 Usage
36 -----
37
97499e4 @flyerhzm update README
authored
38 There are two types of notifications,
39 one is <code>inline_notify</code>, for javascript alert and javascript console notifiers, which returns a string and will be combined,
40 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.
8f6acee @flyerhzm add README and LICENSE
authored
41
42 By default, all notifiers are disabled, you should enable them first.
43
44 # javascript alert
45 UniformNotifier.alert = true
46
7476786 @flyerhzm update README
authored
47 # javascript console (Safari/Webkit browsers or Firefox w/Firebug installed)
8f6acee @flyerhzm add README and LICENSE
authored
48 UniformNotifier.console = true
49
50 # rails logger
51 UniformNotifier.rails_logger = true
52
ef41a17 @kosmatov update README
kosmatov authored
53 # airbrake
54 UniformNotifier.airbrake = true
55
8f6acee @flyerhzm add README and LICENSE
authored
56 # customized logger
57 logger = File.open('notify.log', 'a+')
58 logger.sync = true
59 UniformNotifier.customized_logger = logger
60
61 # growl without password
62 UniformNotifier.growl = true
63 # growl with passowrd
64 UniformNotifier.growl = { :password => 'growl password' }
65
66 # xmpp
7476786 @flyerhzm update README
authored
67 UniformNotifier.xmpp = { :account => 'sender_account@jabber.org',
68 :password => 'password_for_jabber',
69 :receiver => 'recipient_account@jabber.org',
8f6acee @flyerhzm add README and LICENSE
authored
70 :show_online_status => true }
71
72 After that, you can enjoy the notifiers, that's cool!
73
74 # the notify message will be notified to rails logger, customized logger, growl or xmpp.
a7fd30c @flyerhzm update README
authored
75 UniformNotifier.active_notifiers.each do |notifier|
76 notifier.out_of_channel_notify(args.join("\n"))
77 end
8f6acee @flyerhzm add README and LICENSE
authored
78
79 # the notify message will be wrapped by <script type="text/javascript">...</script>,
80 # you should append the javascript_str at the bottom of http response body.
81 # for more information, please check https://github.com/flyerhzm/bullet/blob/master/lib/bullet/rack.rb
82 responses = []
83 UniformNotifier.active_notifiers.each do |notifier|
84 responses << notifier.inline_notify(notify_message)
85 end
86 javascript_str = responses.join("\n")
87
7476786 @flyerhzm update README
authored
88 Growl Support
89 -------------
8f6acee @flyerhzm add README and LICENSE
authored
90
7476786 @flyerhzm update README
authored
91 To get Growl support up-and-running, follow the steps below:
92
70a8f4c @ijcd Add support for ruby_gntp which is needed for Growl v1.3+
ijcd authored
93 * For Growl < v1.3, install the ruby-growl gem: <code>gem install ruby-growl</code>
94 * For Growl v1.3+, install the ruby_gntp gem: <code>gem install ruby_gntp</code>
7476786 @flyerhzm update README
authored
95 * Open the Growl preference pane in Systems Preferences
96 * Click the "Network" tab
97 * Make sure both "Listen for incoming notifications" and "Allow remote application registration" are checked. *Note*: If you set a password, you will need to set <code>UniformNotifier.growl_password = { :password => 'growl password' }</code> in the config file.
98 * Restart Growl ("General" tab -> Stop Growl -> Start Growl)
99 * Boot up your application. UniformNotifier will automatically send a Growl notification when Growl is turned on. If you do not see it when your application loads, make sure it is enabled in your initializer and double-check the steps above.
100
101 ### Ruby 1.9 issue
102
103 ruby-growl gem has an issue about md5 in ruby 1.9, if you use growl and ruby 1.9, check this [gist][1]
104
105 XMPP/Jabber Support
106 -------------------
107
108 To get XMPP support up-and-running, follow the steps below:
109
110 * Install the xmpp4r gem: <code>gem install xmpp4r</code>
111 * Make both the sender and the recipient account add each other as contacts.
112 This will require you to manually log into both accounts, add each other
113 as contact and confirm each others contact request.
114 * Boot up your application. UniformNotifier will automatically send an XMPP notification when XMPP is turned on.
115
116
117 [0]: https://github.com/flyerhzm/bullet
cdc5934 @flyerhzm fix typo
authored
118 [1]: https://gist.github.com/300184
Something went wrong with that request. Please try again.