lhj-tools 0.1.95 → 0.1.97

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55b9242149da893982e764986c573ac7fb0d44b22500e36e980e9b83fa195054
4
- data.tar.gz: b8345388b62ab38bd0f689269233703bce75eaec0e57b7683f5c1cb776c33e1d
3
+ metadata.gz: 3141a25ce2e0c2b88124dd148417f856317982f1f4da81b9bd43c90ee858b820
4
+ data.tar.gz: 70f7ffc027cbcb03cb1c4b613a2e132cd46e57dbd2833d36ff88aacc395ed636
5
5
  SHA512:
6
- metadata.gz: 9b8fa34d2a6941d63ceea2ef5449b98ce483ab6aa114d7f4fd63ae2ccbba54d32a19055fe0b5f461ad2ed821a2501329893b339519d6b00a3cba2d933255604b
7
- data.tar.gz: e69802cb604ec9cfed945bd02fc8a88c640441d9fbcf71a13ab667085828fe561f5733c3a44e08178f8109f0826c973d6dfad85dd4da5db76d681f7e15a27b26
6
+ metadata.gz: ab33b726b8306c881f3ecbced49a801d1d217cb7a340d88b759e82a4d283f2c18f0db89584296edb8e00ca9abb3c8d212ea82d1ee3cf423b56637b507fa9ba14
7
+ data.tar.gz: b172f1fbe29b4475b777a30dd646d0e01bf83015406cfeb22a161010edb2f62a299cee0db36a7a3a2ee9e4ab40b3583f2a5317da749ef0d1b96bc826b837ff4b
@@ -148,10 +148,10 @@ module Lhj
148
148
  end
149
149
 
150
150
  def push_to_git
151
- Actions.sh('git checkout master')
152
- Actions.sh('git add .')
153
- Actions.sh("git commit -m 'generate yapi code'")
154
- Actions.sh('git push')
151
+ Actions.sh('git checkout master', log: false)
152
+ Actions.sh('git add .', log: false)
153
+ Actions.sh("git commit -m 'generate yapi code'", log: false)
154
+ Actions.sh('git push', log: false)
155
155
  end
156
156
 
157
157
  def notify_robot(upload_info, interface_info, project_info)
@@ -169,7 +169,10 @@ module Lhj
169
169
  })
170
170
  template = Lhj::ErbTemplateHelper.load('oc_code_notify')
171
171
  output = Lhj::ErbTemplateHelper.render(template, temp_vars, '-')
172
- Lhj::Dingtalk.post_message_robot(robot_url, 'yapi generate', output)
172
+ btn_array = [
173
+ { 'title' => '查看Yapi', 'actionURL' => api_url }
174
+ ]
175
+ Lhj::Dingtalk.post_card_message_robot(robot_url, 'yapi generate', output, btn_array)
173
176
  end
174
177
 
175
178
  def interface_url_str
@@ -7,39 +7,39 @@ module Lhj
7
7
 
8
8
  def self.post_message(title, message)
9
9
  robot_url = Lhj::DingTalkConfig.dingtalk_robot
10
- http_body = http_body_message(title, message)
10
+ post_message_robot(robot_url, title, message)
11
+ end
12
+
13
+ def self.post_message_robot(robot_url, title, message)
14
+ http_body = markdown_body_message(title, message)
11
15
  http_post(robot_url, http_body)
12
- post_branch_message(http_body)
13
16
  end
14
17
 
15
18
  def self.post_card_message(title, message, btns)
16
19
  robot_url = Lhj::DingTalkConfig.dingtalk_robot
17
- http_body = action_card_body_message(title, message, btns, :vertical)
18
- http_post(robot_url, http_body)
20
+ post_card_message_robot(robot_url, title, message, btns)
19
21
  end
20
22
 
21
- def self.post_branch_message(http_body)
22
- branch_name = fetch_branch
23
- branch_map = Lhj::DingTalkConfig.git_branch
24
- branch_robot_key = branch_map[branch_name] if branch_map && branch_name
25
- branch_robot_url = Lhj::DingTalkConfig.config[branch_robot_key] if branch_robot_key
26
- http_post(branch_robot_url, http_body) if branch_robot_url
23
+ def self.post_card_message_robot(robot_url, title, message, btns)
24
+ http_body = action_card_body_message(title, message, btns, :vertical)
25
+ http_post(robot_url, http_body)
27
26
  end
28
27
 
29
- def self.http_post(robot_url, http_body)
30
- Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json')
28
+ def self.post_single_card_message(title, message, single_title, single_url)
29
+ robot_url = Lhj::DingTalkConfig.dingtalk_robot
30
+ post_single_card_message_robot(robot_url, title, message, single_title, single_url)
31
31
  end
32
32
 
33
- def self.post_message_robot(robot_url, title, message)
34
- http_body = http_body_message(title, message)
35
- Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json')
33
+ def self.post_single_card_message_robot(robot_url, title, message, single_title, single_url)
34
+ http_body = single_action_card_body_message(title, message, single_title, single_url)
35
+ http_post(robot_url, http_body)
36
36
  end
37
37
 
38
- def self.post_action_card_message_robot(robot_url, title, message, btns)
39
- http_body = action_card_body_message(title, message, btns, :vertical)
38
+ def self.http_post(robot_url, http_body)
40
39
  Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json')
41
40
  end
42
41
 
42
+ # deprecation warnings used: markdown_body_message method
43
43
  def self.http_body_message(title, message)
44
44
  markdown_body_message(title, message)
45
45
  end
@@ -63,9 +63,23 @@ module Lhj
63
63
  }.to_json
64
64
  end
65
65
 
66
- def self.fetch_branch
67
- name = Lhj::Actions.git_branch || ''
68
- name.split('/').last
66
+ def self.single_action_card_body_message(title, message, single_title, single_url)
67
+ {
68
+ 'msgtype' => 'actionCard',
69
+ 'actionCard' => { 'title' => title,
70
+ 'text' => message,
71
+ 'btnOrientation' => '0',
72
+ 'singleTitle' => single_title,
73
+ 'singleURL' => single_url }
74
+ }.to_json
75
+ end
76
+
77
+ # links: [{'title'=>'this is ...', 'messageURL'=>'https://www.dingtalk.com', 'picURL'=>'https://xx.png'}]
78
+ def self.feed_card_body_message(links)
79
+ {
80
+ 'msgtype' => 'feedCard',
81
+ 'feedCard' => links
82
+ }.to_json
69
83
  end
70
84
  end
71
85
  end
@@ -110,7 +110,7 @@ module Lhj
110
110
  end
111
111
 
112
112
  def app_download_url
113
- "https://www.pgyer.com/#{@result['data']['appShortcutUrl']}"
113
+ "https://www.pgyer.com/#{@result['data']['appKey']}"
114
114
  end
115
115
  end
116
116
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.95"
5
+ VERSION = "0.1.97"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.95
4
+ version: 0.1.97
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-13 00:00:00.000000000 Z
11
+ date: 2023-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj