Class: Stoplight::Notifier::HipChat

Inherits:
Base
  • Object
show all
Defined in:
lib/stoplight/notifier/hip_chat.rb

Overview

See Also:

Constant Summary collapse

DEFAULT_OPTIONS =
{
  color: 'purple',
  message_format: 'text',
  notify: true
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hip_chat, room, formatter = nil, options = {}) ⇒ HipChat

Returns a new instance of HipChat

Parameters:

  • hip_chat (::HipChat::Client)
  • room (String)
  • formatter (Proc, nil) (defaults to: nil)
  • options (Hash{Symbol => Object}) (defaults to: {})

Options Hash (options):

  • :color (String)
  • :message_format (String)
  • :notify (Boolean)

29
30
31
32
33
34
# File 'lib/stoplight/notifier/hip_chat.rb', line 29

def initialize(hip_chat, room, formatter = nil, options = {})
  @hip_chat = hip_chat
  @room = room
  @formatter = formatter || Default::FORMATTER
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#formatterProc (readonly)

Returns:

  • (Proc)

14
15
16
# File 'lib/stoplight/notifier/hip_chat.rb', line 14

def formatter
  @formatter
end

#hip_chat::HipChat::Client (readonly)

Returns:

  • (::HipChat::Client)

16
17
18
# File 'lib/stoplight/notifier/hip_chat.rb', line 16

def hip_chat
  @hip_chat
end

#optionsHash{Symbol => Object} (readonly)

Returns:

  • (Hash{Symbol => Object})

18
19
20
# File 'lib/stoplight/notifier/hip_chat.rb', line 18

def options
  @options
end

#roomString (readonly)

Returns:

  • (String)

20
21
22
# File 'lib/stoplight/notifier/hip_chat.rb', line 20

def room
  @room
end

Instance Method Details

#notify(light, from_color, to_color, error) ⇒ Object


36
37
38
39
40
# File 'lib/stoplight/notifier/hip_chat.rb', line 36

def notify(light, from_color, to_color, error)
  message = formatter.call(light, from_color, to_color, error)
  hip_chat[room].send('Stoplight', message, options)
  message
end