Sha256: e5ee6a576636c55148d7bae7da4bbbc8b11c0d186561e078d9e582e932ddd09f

Contents?: true

Size: 700 Bytes

Versions: 5

Compression:

Stored size: 700 Bytes

Contents

module SlackMessaging
  class NotifySlack
    attr_accessor :text, :channel, :webhook_url, :username, :icon_url, :icon_emoji

    def initialize(text)
      self.text = text
      self.channel = SlackMessaging::Config.slack[:channel]
      self.webhook_url = SlackMessaging::Config.slack[:webhook_url]
      self.username = SlackMessaging::Config.slack[:username] || 'MessageMe'
      self.icon_emoji = SlackMessaging::Config.slack[:icon_emoji] || ':mailbox_with_mail'
    end

    def perform
      options = {
        channel: channel,
        username: username,
        icon_emoji: icon_emoji,
        text: text
      }

      HTTParty.post(webhook_url, body: options.to_json)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack_messaging-2.2.0 lib/slack_messaging/notify_slack.rb
slack_messaging-2.1.1 lib/slack_messaging/notify_slack.rb
slack_messaging-2.1.0 lib/slack_messaging/notify_slack.rb
slack_messaging-2.0.0 lib/slack_messaging/notify_slack.rb
slack_messaging-1.4.0 lib/slack_messaging/notify_slack.rb