GithubHelp home page GithubHelp logo

clockwerx / uniform_notifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flyerhzm/uniform_notifier

0.0 3.0 0.0 94 KB

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

License: MIT License

uniform_notifier's Introduction

UniformNotifier

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

Install

install directly

gem install uniform_notifier

if you want to notify by growl < v1.3, you should install ruby-growl first

gem install ruby-growl

if you want to notify by growl v1.3+, you should install ruby_gntp first

gem install ruby_gntp

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

add it into Gemfile (Bundler)

gem "uniform_notifier"

you should add ruby-growl, ruby_gntp, xmpp4r, airbrake 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, growl and 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 console (Safari/Webkit browsers or Firefox w/Firebug installed)
UniformNotifier.console = true

# rails logger
UniformNotifier.rails_logger = true

# airbrake
UniformNotifier.airbrake = true

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

# growl without password
UniformNotifier.growl = true
# growl with passowrd
UniformNotifier.growl = { :password => 'growl password' }

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

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

# the notify message will be notified to rails logger, customized logger, growl or xmpp.
UniformNotifier.active_notifiers.each do |notifier|
  notifier.out_of_channel_notify(args.join("\n"))
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(notify_message)
end
javascript_str = responses.join("\n")

Growl Support

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

  • For Growl < v1.3, install the ruby-growl gem: gem install ruby-growl
  • For Growl v1.3+, install the ruby_gntp gem: gem install ruby_gntp
  • Open the Growl preference pane in Systems Preferences
  • Click the "Network" tab
  • 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 UniformNotifier.growl_password = { :password => 'growl password' } in the config file.
  • Restart Growl ("General" tab -> Stop Growl -> Start Growl)
  • 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.

Ruby 1.9 issue

ruby-growl gem has an issue about md5 in ruby 1.9, if you use growl and ruby 1.9, check this gist

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.

uniform_notifier's People

Contributors

flyerhzm avatar ijcd avatar ssoroka avatar tinogomes avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.