Class: Capistrano::Dingtalk::Messaging::Markdown

Inherits:
Base
  • Object
show all
Defined in:
lib/capistrano/dingtalk/messaging/markdown.rb

Instance Method Summary collapse

Methods inherited from Base

#build_at_dict, #build_msg_json, #message_for, #message_for_failed, #message_for_reverted, #message_for_reverting, #message_for_updated, #message_for_updating

Methods included from Helpers

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

Constructor Details

#initialize(info) ⇒ Markdown

Returns a new instance of Markdown.



5
6
7
# File 'lib/capistrano/dingtalk/messaging/markdown.rb', line 5

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

Instance Method Details

#build_hash(action) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/capistrano/dingtalk/messaging/markdown.rb', line 25

def build_hash(action)
  {
    msgtype: "markdown",
    markdown: {
      title: message_for(action),
      text: markdown_load(action)
    }
  }
end

#markdown(action) ⇒ Object



20
21
22
23
# File 'lib/capistrano/dingtalk/messaging/markdown.rb', line 20

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

#markdown_load(action) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/capistrano/dingtalk/messaging/markdown.rb', line 9

def markdown_load(action)
  "
  ### #{application}
  action: #{action}
  deployer: `#{deployer}`
  branch: `#{branch}`
  stage: `#{stage}`"
end