Class: God::Contacts::Jabber
- Inherits:
-
God::Contact
- Object
- God::Contact
- God::Contacts::Jabber
- Defined in:
- lib/god/contacts/jabber.rb
Class Attribute Summary collapse
-
.format ⇒ Object
Returns the value of attribute format.
-
.from_jid ⇒ Object
Returns the value of attribute from_jid.
-
.host ⇒ Object
Returns the value of attribute host.
-
.password ⇒ Object
Returns the value of attribute password.
-
.port ⇒ Object
Returns the value of attribute port.
-
.subject ⇒ Object
Returns the value of attribute subject.
-
.to_jid ⇒ Object
Returns the value of attribute to_jid.
Instance Attribute Summary collapse
-
#from_jid ⇒ Object
Returns the value of attribute from_jid.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#to_jid ⇒ Object
Returns the value of attribute to_jid.
Attributes inherited from God::Contact
Instance Method Summary collapse
Methods inherited from God::Contact
#arg, defaults, #friendly_name, generate, normalize, valid?
Methods included from God::Configurable
#base_name, complain, #complain, #friendly_name, #prepare, #reset
Class Attribute Details
.format ⇒ Object
Returns the value of attribute format.
21 22 23 |
# File 'lib/god/contacts/jabber.rb', line 21 def format @format end |
.from_jid ⇒ Object
Returns the value of attribute from_jid.
20 21 22 |
# File 'lib/god/contacts/jabber.rb', line 20 def from_jid @from_jid end |
.host ⇒ Object
Returns the value of attribute host.
20 21 22 |
# File 'lib/god/contacts/jabber.rb', line 20 def host @host end |
.password ⇒ Object
Returns the value of attribute password.
20 21 22 |
# File 'lib/god/contacts/jabber.rb', line 20 def password @password end |
.port ⇒ Object
Returns the value of attribute port.
20 21 22 |
# File 'lib/god/contacts/jabber.rb', line 20 def port @port end |
.subject ⇒ Object
Returns the value of attribute subject.
20 21 22 |
# File 'lib/god/contacts/jabber.rb', line 20 def subject @subject end |
.to_jid ⇒ Object
Returns the value of attribute to_jid.
20 21 22 |
# File 'lib/god/contacts/jabber.rb', line 20 def to_jid @to_jid end |
Instance Attribute Details
#from_jid ⇒ Object
Returns the value of attribute from_jid.
35 36 37 |
# File 'lib/god/contacts/jabber.rb', line 35 def from_jid @from_jid end |
#host ⇒ Object
Returns the value of attribute host.
35 36 37 |
# File 'lib/god/contacts/jabber.rb', line 35 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
35 36 37 |
# File 'lib/god/contacts/jabber.rb', line 35 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
35 36 37 |
# File 'lib/god/contacts/jabber.rb', line 35 def port @port end |
#subject ⇒ Object
Returns the value of attribute subject.
35 36 37 |
# File 'lib/god/contacts/jabber.rb', line 35 def subject @subject end |
#to_jid ⇒ Object
Returns the value of attribute to_jid.
35 36 37 |
# File 'lib/god/contacts/jabber.rb', line 35 def to_jid @to_jid end |
Instance Method Details
#notify(message, time, priority, category, host) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/god/contacts/jabber.rb', line 47 def notify(, time, priority, category, host) body = Jabber.format.call(, time, priority, category, host) = ::Jabber::Message.new(arg(:to_jid), body) .set_type(:normal) .set_id('1') .set_subject(arg(:subject)) jabber_id = ::Jabber::JID.new("#{arg(:from_jid)}/God") client = ::Jabber::Client.new(jabber_id) client.connect(arg(:host), arg(:port)) client.auth(arg(:password)) client.send() client.close self.info = "sent jabber message to #{self.to_jid}" rescue Object => e if e.respond_to?(:message) applog(nil, :info, "failed to send jabber message to #{arg(:to_jid)}: #{e.}") else applog(nil, :info, "failed to send jabber message to #{arg(:to_jid)}: #{e.class}") end applog(nil, :debug, e.backtrace.join("\n")) end |
#valid? ⇒ Boolean
37 38 39 40 41 42 43 44 45 |
# File 'lib/god/contacts/jabber.rb', line 37 def valid? valid = true valid &= complain("Attribute 'host' must be specified", self) unless arg(:host) valid &= complain("Attribute 'port' must be specified", self) unless arg(:port) valid &= complain("Attribute 'from_jid' must be specified", self) unless arg(:from_jid) valid &= complain("Attribute 'to_jid' must be specified", self) unless arg(:to_jid) valid &= complain("Attribute 'password' must be specified", self) unless arg(:password) valid end |