Class: RakeNotifier::Slack

Inherits:
Base
  • Object
show all
Defined in:
lib/rake_notifier/slack.rb

Defined Under Namespace

Classes: Client

Constant Summary collapse

START_LABEL =
":construction: *[START]*"
SUCCESS_LABEL =
":congratulations: *[SUCCESS]*"
FAILED_LABEL =
":x: *[FAILED]*"

Instance Method Summary collapse

Constructor Details

#initialize(token, channel, icon: nil, username: nil) ⇒ Slack

Returns a new instance of Slack.



11
12
13
# File 'lib/rake_notifier/slack.rb', line 11

def initialize(token, channel, icon: nil, username: nil)
  @client = Client.new(token, channel: channel, icon: icon, username: username)
end

Instance Method Details

#completed_task(task, system_exit) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rake_notifier/slack.rb', line 22

def completed_task(task, system_exit)
  label = system_exit.success? ? SUCCESS_LABEL : FAILED_LABEL
  notice <<-EOS.strip_heredoc
    #{label} `$ #{task.reconstructed_command_line}`
    >>> exit #{system_exit.status} from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env}
  EOS
end

#started_task(task) ⇒ Object



15
16
17
18
19
20
# File 'lib/rake_notifier/slack.rb', line 15

def started_task(task)
  notice <<-EOS.strip_heredoc
    #{START_LABEL} `$ #{task.reconstructed_command_line}`
    >>> from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env}
  EOS
end