• Stars
    star
    235
  • Rank 171,079 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp

UniformNotifier

CI AwesomeCode Status for flyerhzm/uniform_notifier

uniform_notifier is extracted from bullet, it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, xmpp, airbrake, honeybadger and AppSignal.

Install

install directly

gem install uniform_notifier

if you want to notify by xmpp, you should install xmpp4r first

gem install xmpp4r

if you want to notify by airbrake, you should install airbrake first

gem install airbrake

if you want to notify by Honeybadger, you should install honeybadger first

gem install honeybadger

if you want to notify by rollbar, you should install rollbar first

gem install rollbar

if you want to notify by bugsnag, you should install bugsnag first

gem install bugsnag

if you want to notify by AppSignal, you should install AppSignal first

gem install appsignal

if you want to notify by slack, you should install slack-notifier first

gem install slack-notifier

if you want to notify by terminal-notifier, you must install it first

gem install terminal-notifier

add it into Gemfile (Bundler)

gem "uniform_notifier"

you should add xmpp4r, airbrake, bugsnag, honeybadger, slack-notifier, terminal-notifier gem if you want.

Usage

There are two types of notifications, one is inline_notify, for javascript alert and javascript console notifiers, which returns a string and will be combined, the other is out_of_channel_notify, for rails logger, customized logger, xmpp, which doesn't return anything, just send the message to the notifiers.

By default, all notifiers are disabled, you should enable them first.

# javascript alert
UniformNotifier.alert = true
# javascript alert with options
# the attributes key adds custom attributes to the script tag appended to the body
UniformNotifier.alert = { :attributes => { :nonce => 'mySecret-nonce', 'data-key' => 'value' } }

# javascript console (Safari/Webkit browsers or Firefox w/Firebug installed)
UniformNotifier.console = true
# javascript console with options
# the attributes key adds custom attributes to the script tag appended to the body
UniformNotifier.console = { :attributes => { :nonce => 'mySecret-nonce', 'data-key' => 'value' } }

# rails logger
UniformNotifier.rails_logger = true

# airbrake
UniformNotifier.airbrake = true
# airbrake with options
UniformNotifier.airbrake = { :error_class => Exception }

# AppSignal
UniformNotifier.appsignal = true
# AppSignal with options
UniformNotifier.appsignal = { :namespace => "Background", :tags => { :hostname => "frontend1" } }

# Honeybadger
#
# Reporting live data from development is disabled by default. Ensure
# that the `report_data` option is enabled via configuration.
UniformNotifier.honeybadger = true
# Honeybadger with options
UniformNotifier.honeybadger = { :error_class => 'Exception' }

# rollbar
UniformNotifier.rollbar = true
# rollbar with options (level can be 'debug', 'info', 'warning', 'error' or 'critical')
UniformNotifier.rollbar = { :level => 'warning' }

# bugsnag
UniformNotifier.bugsnag = true
# bugsnag with options
UniformNotifier.bugsnag = { :api_key => 'something' }

# slack
UniformNotifier.slack = true
# slack with options
UniformNotifier.slack = { :webhook_url => 'http://some.slack.url', :channel => '#default', :username => 'notifier' }

# customized logger
logger = File.open('notify.log', 'a+')
logger.sync = true
UniformNotifier.customized_logger = logger

# xmpp
UniformNotifier.xmpp = { :account => '[email protected]',
                         :password => 'password_for_jabber',
                         :receiver => '[email protected]',
                         :show_online_status => true }

# terminal-notifier
UniformNotifier.terminal_notifier = true

# raise an error
UniformNotifier.raise = true # raise a generic exception

class MyExceptionClass < Exception; end
UniformNotifier.raise = MyExceptionClass # raise a custom exception type

UniformNotifier.raise = false # don't raise errors

After that, you can enjoy the notifiers, that's cool!

# the notify message will be notified to rails logger, customized logger or xmpp.
UniformNotifier.active_notifiers.each do |notifier|
  notifier.out_of_channel_notify("customize message")
end

# the notify message will be wrapped by <script type="text/javascript">...</script>,
# you should append the javascript_str at the bottom of http response body.
# for more information, please check https://github.com/flyerhzm/bullet/blob/master/lib/bullet/rack.rb
responses = []
UniformNotifier.active_notifiers.each do |notifier|
  responses << notifier.inline_notify("customize message")
end
javascript_str = responses.join("\n")

XMPP/Jabber Support

To get XMPP support up-and-running, follow the steps below:

  • Install the xmpp4r gem: gem install xmpp4r
  • Make both the sender and the recipient account add each other as contacts. This will require you to manually log into both accounts, add each other as contact and confirm each others contact request.
  • Boot up your application. UniformNotifier will automatically send an XMPP notification when XMPP is turned on.

More Repositories

1

bullet

help to kill N+1 queries and unused eager loading
Ruby
7,081
star
2

rails_best_practices

a code metric tool for rails projects
Ruby
4,163
star
3

switch_user

Easily switch current user
Ruby
732
star
4

chinese_pinyin

translate chinese hanzi to pinyin
Ruby
430
star
5

activemerchant_patch_for_china

A rails plugin to add an active_merchant patch for china online payment platform including alipay (ๆ”ฏไป˜ๅฎ), 99bill (ๅฟซ้’ฑ) and tenpay (่ดขไป˜้€š)
Ruby
305
star
6

css_sprite

automatically css sprite
Ruby
242
star
7

rails-bestpractices.com

HTML
200
star
8

redis-sentinel

another redis automatic master/slave failover solution for ruby by using built-in redis sentinel (deprecated)
Ruby
188
star
9

eager_group

fix n+1 aggregate sql functions for rails
Ruby
122
star
10

seo_checker

check your website if it is seo.
Ruby
117
star
11

simple_cacheable

a simple cache implementation for rails
Ruby
91
star
12

code_analyzer

code analyzer tool which is extracted from rails_best_practices
Ruby
86
star
13

resque-restriction

resque-restriction is an extension to resque queue system that restricts the execution number of certain jobs in a period time.
Ruby
86
star
14

rfetion

rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.
Ruby
61
star
15

chinese_regions

provides all chinese regions, cities and districts
Ruby
60
star
16

mongoid-eager-loading

eager loading for mongoid (DEPRECATED)
Ruby
54
star
17

rails-brakeman.com

online security check for rails projects
Ruby
52
star
18

contactlist

java api to retrieve contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah, 189 and 139) and im(msn)
Java
49
star
19

regexp_crawler

A crawler which uses regular expression to catch data from website.
Ruby
45
star
20

chinese_permalink

This plugin adds a capability for AR model to create a seo permalink with your chinese text. It will translate your chinese text to english url based on google translate.
Ruby
41
star
21

apis-bench

Ruby
34
star
22

sitemap

This plugin will generate a sitemap.xml from sitemap.rb whose format is very similar to routes.rb
Ruby
32
star
23

twitter_connect

facebook connect style twitter oauth
Ruby
30
star
24

taobao

Ruby Client Library for Taobao Open Platform
Ruby
27
star
25

huangzhimin.com

my homepage
HTML
24
star
26

railsbp.com

railsbp.com
JavaScript
23
star
27

multiple_mailers

extend actionmailer to allow one smtp account per mailer class.
Ruby
23
star
28

contactlist-client

The contactlist-client gem is a ruby client to contactlist service which retrieves contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah, 189 and 139) and im(msn)
Ruby
20
star
29

donatecn

demo for activemerchant_patch_for_china
Ruby
17
star
30

monitor

Monitor gem can display ruby methods call stack on browser based on unroller
JavaScript
17
star
31

authlogic_renren_connect

Extension of the Authlogic library to add Renren Connect support built upon the renren plugin
Ruby
5
star
32

rails3-template

rails3 template includes a lot of useful plugins/gems
Ruby
5
star
33

nodeslide

node.js related slideshows [deprecated], move to nodeslide.heroku.com
JavaScript
4
star
34

rubyslide.com

collect ruby rails related presentations [deprecated], moved to rubyslide.heroku.com
Ruby
4
star
35

visual_partial

This plugin provides a way that you can see all the partial pages rendered. So it can prevent you from using partial page too much, which hurts the performance.
Ruby
4
star
36

codelinestatistics

The code line statistics takes files and directories from GUI, counts the total files, total sizes of files, total lines, lines of codes, lines of comments and lines of blanks in the files, displays the results and can also export results to html file.
Ruby
4
star
37

clock_chrome_extension

google chrome extension to display multiple clock analogs for multiple timezones
2
star
38

dotfiles

Vim Script
2
star
39

showoff-understanding-mongoid

My understanding mongoid showoff presentation
Ruby
2
star
40

enough_fields

only select specified fields used
Ruby
2
star
41

skype_archive

company hackathon
Ruby
1
star
42

bullet_test

Ruby
1
star
43

play_skype

JavaScript
1
star
44

test_code_analyzer

test code for code_analyzer gem
Ruby
1
star
45

blog.huangzhimin.com

HTML
1
star
46

test_error

raise an error to test if exception_notification really works.
Ruby
1
star
47

try-ripper

code mirror of try-ripper.heroku.com
CSS
1
star