Class: SlackNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/slackbot/slack_notifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ SlackNotifier

Returns a new instance of SlackNotifier.



5
6
7
8
9
# File 'lib/capistrano/slackbot/slack_notifier.rb', line 5

def initialize(args = {})
  @team = args.fetch(:team) { raise ArgumentError, "slack team not set!" }
  @token = args.fetch(:token) { raise ArgumentError, "slack token not set!" }
  @options = args.fetch(:options) { {} }
end

Instance Method Details

#notify(text) ⇒ Object



11
12
13
14
15
# File 'lib/capistrano/slackbot/slack_notifier.rb', line 11

def notify(text)
  payload = { text: text }.merge(@options)

  connection.post url, payload.to_json
end