Class: Capistrano::DeployHooks::Messengers::Mattermost
- Inherits:
-
Object
- Object
- Capistrano::DeployHooks::Messengers::Mattermost
- Extended by:
- Forwardable
- Defined in:
- lib/capistrano/deploy_hooks/messengers/mattermost.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #application ⇒ Object
- #branch ⇒ Object
- #deployer ⇒ Object
-
#initialize(cap, opts) ⇒ Mattermost
constructor
A new instance of Mattermost.
- #payload_for_failed ⇒ Object
- #payload_for_reverted ⇒ Object
- #payload_for_reverting ⇒ Object
- #payload_for_updated ⇒ Object
- #payload_for_updating ⇒ Object
- #payloads_for(action) ⇒ Object
- #stage ⇒ Object
- #webhook_for(_) ⇒ Object
Constructor Details
#initialize(cap, opts) ⇒ Mattermost
Returns a new instance of Mattermost.
10 11 12 13 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 10 def initialize(cap, opts) @cap = cap @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
8 9 10 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 8 def opts @opts end |
Instance Method Details
#application ⇒ Object
60 61 62 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 60 def application fetch(:application) end |
#branch ⇒ Object
56 57 58 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 56 def branch fetch(:branch) end |
#deployer ⇒ Object
52 53 54 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 52 def deployer ENV["USER"] || ENV["USERNAME"] end |
#payload_for_failed ⇒ Object
44 45 46 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 44 def payload_for_failed { text: "#{deployer} has failed to #{ ? 'deploy' : 'rollback'} branch #{branch} of #{application} to #{stage}" } end |
#payload_for_reverted ⇒ Object
40 41 42 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 40 def payload_for_reverted { text: "#{deployer} has finished rolling back branch of #{application} to #{stage}" } end |
#payload_for_reverting ⇒ Object
32 33 34 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 32 def payload_for_reverting { text: "#{deployer} has started rolling back branch #{branch} of #{application} to #{stage}" } end |
#payload_for_updated ⇒ Object
36 37 38 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 36 def payload_for_updated { text: "#{deployer} has finished deploying branch #{branch} of #{application} to #{stage}" } end |
#payload_for_updating ⇒ Object
28 29 30 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 28 def payload_for_updating { text: "#{deployer} has started deploying branch #{branch} of #{application} to #{stage}" } end |
#payloads_for(action) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 15 def payloads_for(action) method = "payload_for_#{action}" return if !respond_to?(method) pl = (opts[:payload] || {}).merge(username: "Capistrano").merge(send(method)) channels = Array(opts[:channels]) payloads = channels.map{ |c| pl.merge(channel: c) } payloads = [pl] if payloads.empty? payloads end |
#stage ⇒ Object
64 65 66 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 64 def stage fetch(:stage, '') end |
#webhook_for(_) ⇒ Object
48 49 50 |
# File 'lib/capistrano/deploy_hooks/messengers/mattermost.rb', line 48 def webhook_for(_) opts[:webhook_uri] end |