/
base.rb
73 lines (57 loc) · 1.64 KB
/
base.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'forwardable'
require_relative 'helpers'
module Slackistrano
module Messaging
class Base
include Helpers
extend Forwardable
def_delegators :env, :fetch
attr_reader :team, :token, :webhook
def initialize(env: nil, team: nil, channel: nil, token: nil, webhook: nil)
@env = env
@team = team
@channel = channel
@token = token
@webhook = webhook
end
def payload_for_updating
{
text: "#{deployer} has started deploying branch #{branch} of #{application} to #{stage}"
}
end
def payload_for_reverting
{
text: "#{deployer} has started rolling back branch #{branch} of #{application} to #{stage}"
}
end
def payload_for_updated
{
text: "#{deployer} has finished deploying branch #{branch} of #{application} to #{stage}"
}
end
def payload_for_reverted
{
text: "#{deployer} has finished rolling back branch of #{application} to #{stage}"
}
end
def payload_for_failed
{
text: "#{deployer} has failed to #{deploying? ? 'deploy' : 'rollback'} branch #{branch} of #{application} to #{stage}"
}
end
def channels_for(action)
@channel
end
################################################################################
def payload_for(action)
method = "payload_for_#{action}"
respond_to?(method) && send(method)
end
def via_slackbot?
@webhook.nil?
end
end
end
end
require_relative 'default'
require_relative 'deprecated'