Class: God::Contacts::Campfire

Inherits:
God::Contact show all
Defined in:
lib/god/contacts/campfire.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



83
84
85
# File 'lib/god/contacts/campfire.rb', line 83

def format
  @format
end

.roomObject

Returns the value of attribute room



82
83
84
# File 'lib/god/contacts/campfire.rb', line 82

def room
  @room
end

.sslObject

Returns the value of attribute ssl



82
83
84
# File 'lib/god/contacts/campfire.rb', line 82

def ssl
  @ssl
end

.subdomainObject

Returns the value of attribute subdomain



82
83
84
# File 'lib/god/contacts/campfire.rb', line 82

def subdomain
  @subdomain
end

.tokenObject

Returns the value of attribute token



82
83
84
# File 'lib/god/contacts/campfire.rb', line 82

def token
  @token
end

Instance Attribute Details

#roomObject

Returns the value of attribute room



92
93
94
# File 'lib/god/contacts/campfire.rb', line 92

def room
  @room
end

#sslObject

Returns the value of attribute ssl



92
93
94
# File 'lib/god/contacts/campfire.rb', line 92

def ssl
  @ssl
end

#subdomainObject

Returns the value of attribute subdomain



92
93
94
# File 'lib/god/contacts/campfire.rb', line 92

def subdomain
  @subdomain
end

#tokenObject

Returns the value of attribute token



92
93
94
# File 'lib/god/contacts/campfire.rb', line 92

def token
  @token
end

Instance Method Details

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



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/god/contacts/campfire.rb', line 102

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

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

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

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

#valid?Boolean

Returns:

  • (Boolean)


94
95
96
97
98
99
100
# File 'lib/god/contacts/campfire.rb', line 94

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