Class: SportNginAwsAuditor::NotifySlack

Inherits:
Object
  • Object
show all
Defined in:
lib/sport_ngin_aws_auditor/notify_slack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ NotifySlack

Returns a new instance of NotifySlack.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 7

def initialize(text)
  self.text = text
  if SportNginAwsAuditor::Config.slack
    self.channel = SportNginAwsAuditor::Config.slack[:channel]
    self.username = SportNginAwsAuditor::Config.slack[:username]
    self.webhook = SportNginAwsAuditor::Config.slack[:webhook]
    self.icon_url = SportNginAwsAuditor::Config.slack[:icon_url]
  else
    puts "To use Slack, you must provide a separate config file. See the README for more information."
  end
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



5
6
7
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 5

def channel
  @channel
end

#icon_emojiObject

Returns the value of attribute icon_emoji.



5
6
7
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 5

def icon_emoji
  @icon_emoji
end

#icon_urlObject

Returns the value of attribute icon_url.



5
6
7
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 5

def icon_url
  @icon_url
end

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 5

def text
  @text
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 5

def username
  @username
end

#webhookObject

Returns the value of attribute webhook.



5
6
7
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 5

def webhook
  @webhook
end

Instance Method Details

#performObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sport_ngin_aws_auditor/notify_slack.rb', line 19

def perform
  if SportNginAwsAuditor::Config.slack
    options = {webhook: webhook,
               channel: channel,
               username: username,
               icon_url: icon_url,
               http_options: {open_timeout: 10}
              }
    Slack::Notifier.new(webhook, options).ping(text)
  end
end