lhj-tools 0.1.89 → 0.1.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lhj/command/yapi/yapi_init.rb +20 -6
- data/lib/lhj/helper/dingtalk_helper.rb +6 -2
- data/lib/lhj/helper/oss_helper.rb +10 -0
- data/lib/lhj/tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ff9380c967d2d9a660c0bc2985aa7593c56fdaed4178c1b6fc82f79aafa383e
|
|
4
|
+
data.tar.gz: 9e6c8e22f31276d5811595f35392183bc6e61f064f1c298f529f23a7d356d622
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9f5d70b9483a20908898da0142cccb579cf3034ac18d53ff251e9b48fc632b1a5bbdbe6b4e341be52ba13fe9329018028b21e288239aff4569f790710823818
|
|
7
|
+
data.tar.gz: 4a108b85e0434399ef97ecd13c77535a499f67695edf38de2b26a8ccb1fdb741c33a9ced7f22a326fcb557c6a5806af90d06e7aa5b640598002fdc9703453f71
|
|
@@ -21,7 +21,7 @@ module Lhj
|
|
|
21
21
|
login_btn&.click
|
|
22
22
|
window.resize_to(200, 500)
|
|
23
23
|
# 2.获取cookies
|
|
24
|
-
wait = Selenium::WebDriver::Wait.new(timeout:
|
|
24
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 120)
|
|
25
25
|
need_notify = true
|
|
26
26
|
wait.until do
|
|
27
27
|
res = {}
|
|
@@ -31,24 +31,38 @@ module Lhj
|
|
|
31
31
|
res[:token] = cookie[:value] if cookie[:name] == '_yapi_token'
|
|
32
32
|
end
|
|
33
33
|
if need_notify
|
|
34
|
-
|
|
34
|
+
time = Time.now
|
|
35
|
+
file_name = "#{time.strftime('%Y%m%d%H%M%S')}.png"
|
|
36
|
+
# file_name = 'qrcode.png'
|
|
35
37
|
file = File.join(Lhj::Config.instance.home_dir, file_name)
|
|
36
38
|
driver.save_screenshot(file)
|
|
37
|
-
Lhj::OSS::Helper.instance.
|
|
38
|
-
|
|
39
|
+
callback_param = gen_http_body("#{Lhj::OSS::Helper.instance.url_path}/#{file_name}")
|
|
40
|
+
Lhj::OSS::Helper.instance.upload_file_callback(file_name, file, callback_param)
|
|
39
41
|
need_notify = false
|
|
40
42
|
end
|
|
41
43
|
return res if res.values.count == 3
|
|
42
44
|
end
|
|
43
45
|
end
|
|
44
46
|
|
|
47
|
+
def gen_http_body(url)
|
|
48
|
+
template = Lhj::ErbTemplateHelper.load('yapi_qr_code_notify')
|
|
49
|
+
output = Lhj::ErbTemplateHelper.render(template, { url: url }, nil)
|
|
50
|
+
body = Lhj::Dingtalk.http_body_message('yapi qrcode', output)
|
|
51
|
+
{
|
|
52
|
+
url: robot_url,
|
|
53
|
+
query: { access_token: 'fe879fd3e7a3b5e59d5719b2384845b7884901919be5a78fe443cbf777869807' },
|
|
54
|
+
body: body,
|
|
55
|
+
content_type: 'application/json'
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
45
59
|
def robot_url
|
|
46
|
-
'https://oapi.dingtalk.com/robot/send
|
|
60
|
+
'https://oapi.dingtalk.com/robot/send'
|
|
47
61
|
end
|
|
48
62
|
|
|
49
63
|
def notify_robot(url)
|
|
50
64
|
template = Lhj::ErbTemplateHelper.load('yapi_qr_code_notify')
|
|
51
|
-
output = Lhj::ErbTemplateHelper.render(template, { url: url },
|
|
65
|
+
output = Lhj::ErbTemplateHelper.render(template, { url: url }, nil)
|
|
52
66
|
Lhj::Dingtalk.post_message_robot(robot_url, 'yapi qrcode', output)
|
|
53
67
|
end
|
|
54
68
|
|
|
@@ -7,7 +7,7 @@ module Lhj
|
|
|
7
7
|
|
|
8
8
|
def self.post_message(title, message)
|
|
9
9
|
robot_url = Lhj::DingTalkConfig.dingtalk_robot
|
|
10
|
-
http_body =
|
|
10
|
+
http_body = http_body_message(title, message)
|
|
11
11
|
http_post(robot_url, http_body)
|
|
12
12
|
post_branch_message(http_body)
|
|
13
13
|
end
|
|
@@ -25,10 +25,14 @@ module Lhj
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def self.post_message_robot(robot_url, title, message)
|
|
28
|
-
http_body =
|
|
28
|
+
http_body = http_body_message(title, message)
|
|
29
29
|
Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json')
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def self.http_body_message(title, message)
|
|
33
|
+
{ 'msgtype' => 'markdown', 'markdown' => { 'title' => title, 'text' => message } }.to_json
|
|
34
|
+
end
|
|
35
|
+
|
|
32
36
|
def self.fetch_branch
|
|
33
37
|
name = Lhj::Actions.git_branch || ''
|
|
34
38
|
name.split('/').last
|
|
@@ -19,6 +19,16 @@ module Lhj
|
|
|
19
19
|
@bucket.put_object(key, :file => file)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def upload_file_callback(key, file, callback_param = {})
|
|
23
|
+
callback = Aliyun::OSS::Callback.new(callback_param)
|
|
24
|
+
@bucket.put_object(key, { file: file, callback: callback })
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def put_object(key, opts = {}, &block)
|
|
28
|
+
args = opts.dup
|
|
29
|
+
@bucket.put_object(key, args, &block)
|
|
30
|
+
end
|
|
31
|
+
|
|
22
32
|
def down_load(key, file, &block)
|
|
23
33
|
@bucket.get_object(key, :file => file, &block)
|
|
24
34
|
end
|
data/lib/lhj/tools/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.1.91
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- lihaijian
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-12-
|
|
11
|
+
date: 2022-12-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xcodeproj
|