Class: Capistrano::Dingtalk::Messaging::Base

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

Direct Known Subclasses

Markdown, Text

Instance Method Summary collapse

Methods included from Helpers

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

Constructor Details

#initialize(info) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 11

def initialize(info)
  @info = info || {}
end

Instance Method Details

#build_at_dictObject



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

def build_at_dict
  at = {}
  at["at"] = @info[:at_all]
  at["atMobiles"] = @info[:at_mobiles]
  at
end

#build_hash(action) ⇒ Object



49
50
51
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 49

def build_hash(action)
  # implements on children
end

#build_msg_json(action) ⇒ Object



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

def build_msg_json(action)
  build_hash(action).merge(build_at_dict).to_json
end

#message_for(action) ⇒ Object



37
38
39
40
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 37

def message_for(action)
  method = "message_for_#{action}"
  respond_to?(method) && send(method)
end

#message_for_failedObject



31
32
33
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 31

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

#message_for_revertedObject



27
28
29
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 27

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

#message_for_revertingObject



19
20
21
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 19

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

#message_for_updatedObject



23
24
25
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 23

def message_for_updated
  "#{deployer} has finished deploying branch #{branch} of #{application} to #{stage}"
end

#message_for_updatingObject



15
16
17
# File 'lib/capistrano/dingtalk/messaging/base.rb', line 15

def message_for_updating
  "#{deployer} has started deploying branch #{branch} of #{application} to #{stage}"
end