class UniformNotifier::Xmpp
Public Class Methods
active?()
click to toggle source
# File lib/uniform_notifier/xmpp.rb, line 10 def active? @xmpp end
setup_connection(xmpp_information)
click to toggle source
# File lib/uniform_notifier/xmpp.rb, line 14 def setup_connection(xmpp_information) return unless xmpp_information require 'xmpp4r' @xmpp = xmpp_information @receiver = xmpp_information[:receiver] @password = xmpp_information[:password] @account = xmpp_information[:account] @show_online_status = xmpp_information[:show_online_status] @stay_connected = xmpp_information[:stay_connected].nil? ? true : xmpp_information[:stay_connected] connect if @stay_connected rescue LoadError @xmpp = nil raise NotificationError, 'You must install the xmpp4r gem to use XMPP notification: `gem install xmpp4r`' end
Protected Class Methods
_out_of_channel_notify(data)
click to toggle source
# File lib/uniform_notifier/xmpp.rb, line 34 def _out_of_channel_notify(data) message = data.values.compact.join("\n") notify(message) end
Private Class Methods
connect()
click to toggle source
# File lib/uniform_notifier/xmpp.rb, line 42 def connect jid = Jabber::JID.new(@account) @xmpp = Jabber::Client.new(jid) @xmpp.connect @xmpp.auth(@password) @xmpp.send(presence_status) if @show_online_status end
notify(message)
click to toggle source
# File lib/uniform_notifier/xmpp.rb, line 50 def notify(message) connect unless @stay_connected message = Jabber::Message.new(@receiver, message).set_type(:normal).set_subject('Uniform Notifier') @xmpp.send(message) end
presence_status()
click to toggle source
# File lib/uniform_notifier/xmpp.rb, line 56 def presence_status Jabber::Presence.new.set_status("Uniform Notifier started on #{Time.now}") end