Sha256: cc160b3c43740bc32de844f53af300e31a2f7ebaa1c412c0f5fa7b934aa07aee
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'ruby_gntp' module Pair class Notification class OSXDispatcher < Dispatcher attr_reader :growl, :app_icon NOTIFICATIONS = [{:name => "Session Events", :enabled => true}] def initialize(options = {}) @app_icon = options.delete(:app_icon) super register_growl if Pair.config.growl_enabled? rescue Errno::ECONNREFUSED => except raise Pair::Notification::GNTPError.new("Growl notification transfer protocol is not enabled, either start growl or disable growl via pair config") end def register_growl @growl = GNTP.new(Pair::APPLICATION_NAME) @growl.register application_hash end def session_join(user, session) gntp_notify({ :name => "Session Events", :title => "Pair Message", :text => "#{user} joined session \"#{session}\"", :icon => Pair::ICON_SESSION_JOIN, :sticky => true }) end def session_part(user, session) gntp_notify({ :name => "Session Events", :title => "Pair Message", :text => "#{user} parted session \"#{session}\"", :icon => Pair::ICON_SESSION_JOIN, :sticky => true }) end def gntp_notify(options) if enabled if block_given? yield @growl end if options[:text] options = { :name => "Session Events", :title => "", :icon => @app_icon, :sticky => false }.merge(options) @growl.notify(options) end end end private def application_hash { :app_icon => Pair::ICON_APPLICATION, :notifications => NOTIFICATIONS } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pair-0.0.4 | lib/pair/notification/o_s_x_dispatcher.rb |