Class: PubsubNotifier::SlackClient

Inherits:
Client::Base show all
Defined in:
lib/pubsub_notifier/slack_client.rb

Defined Under Namespace

Classes: Config

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Client::Base

config, configure

Constructor Details

#initialize(options = {}) ⇒ SlackClient

Returns a new instance of SlackClient.



9
10
11
12
13
# File 'lib/pubsub_notifier/slack_client.rb', line 9

def initialize(options = {})
  @channel    = options.delete(:channel)    || default_channel
  @username   = options.delete(:username)   || default_username
  @icon_emoji = options.delete(:icon_emoji) || default_icon_emoji
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



7
8
9
# File 'lib/pubsub_notifier/slack_client.rb', line 7

def channel
  @channel
end

#icon_emojiObject (readonly)

Returns the value of attribute icon_emoji.



7
8
9
# File 'lib/pubsub_notifier/slack_client.rb', line 7

def icon_emoji
  @icon_emoji
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/pubsub_notifier/slack_client.rb', line 7

def username
  @username
end

Instance Method Details

#notify_failure(message) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/pubsub_notifier/slack_client.rb', line 25

def notify_failure(message)
  post_slack(
    attachments: [{
      text:      message,
      color:     "danger",
      mrkdwn_in: ["text"],
    }],
  )
end

#notify_success(message) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/pubsub_notifier/slack_client.rb', line 15

def notify_success(message)
  post_slack(
    attachments: [{
      text:      message,
      color:     "good",
      mrkdwn_in: ["text"],
    }],
  )
end