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(options = {}) ⇒ Base

Returns a new instance of Base.



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

def initialize(options = {})
  @options = options.dup

  @env = options.delete(:env)
  @team = options.delete(:team)
  @channel = options.delete(:channel)
  @token = options.delete(:token)
  @webhook = options.delete(:webhook)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#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



55
56
57
# File 'lib/slackistrano/messaging/base.rb', line 55

def channels_for(action)
  @channel
end

#payload_for(action) ⇒ Object



61
62
63
64
# File 'lib/slackistrano/messaging/base.rb', line 61

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

#payload_for_failedObject



49
50
51
52
53
# File 'lib/slackistrano/messaging/base.rb', line 49

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

#payload_for_revertedObject



43
44
45
46
47
# File 'lib/slackistrano/messaging/base.rb', line 43

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

#payload_for_revertingObject



31
32
33
34
35
# File 'lib/slackistrano/messaging/base.rb', line 31

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

#payload_for_updatedObject



37
38
39
40
41
# File 'lib/slackistrano/messaging/base.rb', line 37

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

#payload_for_updatingObject



25
26
27
28
29
# File 'lib/slackistrano/messaging/base.rb', line 25

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

#via_slackbot?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/slackistrano/messaging/base.rb', line 66

def via_slackbot?
  @webhook.nil?
end