Class: God::Contacts::Hipchat

Inherits:
God::Contact show all
Defined in:
lib/god/contacts/hipchat.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from God::Contact

#group, #info, #name

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

.formatObject

Returns the value of attribute format.



79
80
81
# File 'lib/god/contacts/hipchat.rb', line 79

def format
  @format
end

.fromObject

Returns the value of attribute from.



78
79
80
# File 'lib/god/contacts/hipchat.rb', line 78

def from
  @from
end

.roomObject

Returns the value of attribute room.



78
79
80
# File 'lib/god/contacts/hipchat.rb', line 78

def room
  @room
end

.sslObject

Returns the value of attribute ssl.



78
79
80
# File 'lib/god/contacts/hipchat.rb', line 78

def ssl
  @ssl
end

.tokenObject

Returns the value of attribute token.



78
79
80
# File 'lib/god/contacts/hipchat.rb', line 78

def token
  @token
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



88
89
90
# File 'lib/god/contacts/hipchat.rb', line 88

def from
  @from
end

#roomObject

Returns the value of attribute room.



88
89
90
# File 'lib/god/contacts/hipchat.rb', line 88

def room
  @room
end

#sslObject

Returns the value of attribute ssl.



88
89
90
# File 'lib/god/contacts/hipchat.rb', line 88

def ssl
  @ssl
end

#tokenObject

Returns the value of attribute token.



88
89
90
# File 'lib/god/contacts/hipchat.rb', line 88

def token
  @token
end

Instance Method Details

#notify(message, time, priority, category, host) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/god/contacts/hipchat.rb', line 98

def notify(message, time, priority, category, host)
  body = Hipchat.format.call(message, time, priority, category, host)

  conn = Marshmallow::Connection.new(
    :token => arg(:token),
    :ssl   => arg(:ssl),
    :from  => arg(:from)
  )

  conn.speak(arg(:room), body)

  self.info = "notified hipchat: #{arg(:room)}"
rescue Object => e
  applog(nil, :info, "failed to notify hipchat: #{e.message}")
  applog(nil, :debug, e.backtrace.join("\n"))
end

#valid?Boolean

Returns:

  • (Boolean)


90
91
92
93
94
95
96
# File 'lib/god/contacts/hipchat.rb', line 90

def valid?
  valid = true
  valid &= complain("Attribute 'token' must be specified", self) unless arg(:token)
  valid &= complain("Attribute 'room' must be specified", self) unless arg(:room)
  valid &= complain("Attribute 'from' must be specified", self) unless arg(:from)
  valid
end