Class: Slackistrano::Messaging::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Helpers
Defined in:
lib/slackistrano/messaging/base.rb

Direct Known Subclasses

Default, Deprecated, Null

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#application, #branch, #deployer, #elapsed_time, #icon_emoji, #icon_url, #stage, #username

Constructor Details

#initialize(env: nil, team: nil, channel: nil, token: nil, webhook: nil) ⇒ Base

Returns a new instance of Base.



15
16
17
18
19
20
21
# File 'lib/slackistrano/messaging/base.rb', line 15

def initialize(env: nil, team: nil, channel: nil, token: nil, webhook: nil)
  @env = env
  @team = team
  @channel = channel
  @token = token
  @webhook = webhook
end

Instance Attribute Details

#teamObject (readonly)

Returns the value of attribute team.



13
14
15
# File 'lib/slackistrano/messaging/base.rb', line 13

def team
  @team
end

#tokenObject (readonly)

Returns the value of attribute token.



13
14
15
# File 'lib/slackistrano/messaging/base.rb', line 13

def token
  @token
end

#webhookObject (readonly)

Returns the value of attribute webhook.



13
14
15
# File 'lib/slackistrano/messaging/base.rb', line 13

def webhook
  @webhook
end

Instance Method Details

#channels_for(action) ⇒ Object



53
54
55
# File 'lib/slackistrano/messaging/base.rb', line 53

def channels_for(action)
  @channel
end

#payload_for(action) ⇒ Object



59
60
61
62
# File 'lib/slackistrano/messaging/base.rb', line 59

def payload_for(action)
  method = "payload_for_#{action}"
  respond_to?(method) && send(method)
end

#payload_for_failedObject



47
48
49
50
51
# File 'lib/slackistrano/messaging/base.rb', line 47

def payload_for_failed
  {
    text: "#{deployer} has failed to #{deploying? ? 'deploy' : 'rollback'} branch #{branch} of #{application} to #{stage}"
  }
end

#payload_for_revertedObject



41
42
43
44
45
# File 'lib/slackistrano/messaging/base.rb', line 41

def payload_for_reverted
  {
    text: "#{deployer} has finished rolling back branch of #{application} to #{stage}"
  }
end

#payload_for_revertingObject



29
30
31
32
33
# File 'lib/slackistrano/messaging/base.rb', line 29

def payload_for_reverting
  {
    text: "#{deployer} has started rolling back branch #{branch} of #{application} to #{stage}"
  }
end

#payload_for_updatedObject



35
36
37
38
39
# File 'lib/slackistrano/messaging/base.rb', line 35

def payload_for_updated
  {
    text: "#{deployer} has finished deploying branch #{branch} of #{application} to #{stage}"
  }
end

#payload_for_updatingObject



23
24
25
26
27
# File 'lib/slackistrano/messaging/base.rb', line 23

def payload_for_updating
  {
    text: "#{deployer} has started deploying branch #{branch} of #{application} to #{stage}"
  }
end

#via_slackbot?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/slackistrano/messaging/base.rb', line 64

def via_slackbot?
  @webhook.nil?
end