lhj-tools 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/helper/pgyer_helper.rb +5 -1
- data/lib/lhj/helper/tb_helper.rb +49 -2
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d246c747ed42f7359b79c279b864539a2d318b744f68994a015960d9abff5d20
|
4
|
+
data.tar.gz: 58f16be0521a715eb2c8d16928f3f7818009272b1150e58fbad3ee56ca62388b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e71dbbe12bd70a4a42323d30ef9c40cee0c7cab5834273ca1359241df01fd3875a63a06419a398e91625184e93cb62893567fc5ecdbbb9f021acb95536eef62
|
7
|
+
data.tar.gz: 5f6514ecff7d90d4e4e0d5132abde517fdcd8bb36dc800fcd9eda7ea74e5da5ac0be6f1b04cd97321fc62974a3bc27079b2eaaaad0d55e9ba041294953b2d2f2
|
@@ -3,6 +3,7 @@ require 'faraday_middleware'
|
|
3
3
|
require 'lhj/helper/pgyer_config'
|
4
4
|
require 'lhj/command/yapi/formatters/service'
|
5
5
|
require 'lhj/config'
|
6
|
+
require_relative 'tb_config'
|
6
7
|
|
7
8
|
module Lhj
|
8
9
|
# pgyer upload
|
@@ -48,7 +49,10 @@ module Lhj
|
|
48
49
|
puts 'begin upload'
|
49
50
|
response = http_client.post API_HOST, params
|
50
51
|
@result = response.body
|
51
|
-
puts
|
52
|
+
puts @result
|
53
|
+
if @result['data'] && @result['data']['appUpdateDescription']
|
54
|
+
@result['data']['appUpdateDescription'] = Lhj::TbHelper.trans_tb(@result['data']['appUpdateDescription'])
|
55
|
+
end
|
52
56
|
rescue Faraday::TimeoutError
|
53
57
|
puts 'upload fail'
|
54
58
|
end
|
data/lib/lhj/helper/tb_helper.rb
CHANGED
@@ -1,7 +1,54 @@
|
|
1
1
|
require 'lhj/helper/tb_config'
|
2
|
+
require 'jwt'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'json'
|
2
6
|
|
3
7
|
module Lhj
|
4
|
-
#
|
5
|
-
class
|
8
|
+
# tb upload
|
9
|
+
class TbHelper
|
10
|
+
|
11
|
+
SEARCH_API_URL = 'https://open.teambition.com/api/task/tqlsearch'.freeze
|
12
|
+
|
13
|
+
def self.trans_tb(note)
|
14
|
+
str = note
|
15
|
+
if /#.+#/ =~ note
|
16
|
+
note.scan(/#[^#]+#/) do |m|
|
17
|
+
res_body = req_with_task(m.match(/\d+/)[0])
|
18
|
+
if res_body['code'].to_i == 200
|
19
|
+
url_str = "[#{res_body['result'][0]['content']}](https://www.teambition.com/task/#{res_body['result'][0]['taskId']})"
|
20
|
+
str = str.gsub(m, url_str)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
str
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.req_with_task(id)
|
28
|
+
now = Time.now.to_i
|
29
|
+
payload = {
|
30
|
+
_appId: Lhj::TBConfig.tb_app_id,
|
31
|
+
iat: now,
|
32
|
+
exp: now + 3600
|
33
|
+
}
|
34
|
+
token = JWT.encode(payload, Lhj::TBConfig.tb_app_key)
|
35
|
+
|
36
|
+
url = URI(SEARCH_API_URL)
|
37
|
+
https = Net::HTTP.new(url.host, url.port)
|
38
|
+
https.use_ssl = true
|
39
|
+
|
40
|
+
request = Net::HTTP::Post.new(url)
|
41
|
+
request['authorization'] = "Bearer #{token}"
|
42
|
+
request['x-tenant-id'] = Lhj::TBConfig.tb_tenant_id
|
43
|
+
request['x-tenant-type'] = 'organization'
|
44
|
+
request['Content-Type'] = 'application/json'
|
45
|
+
req_body = {
|
46
|
+
"tql": "projectId=#{Lhj::TBConfig.projectId} AND uniqueId=#{id}"
|
47
|
+
}
|
48
|
+
request.body = JSON.dump(req_body)
|
49
|
+
|
50
|
+
response = https.request(request)
|
51
|
+
JSON.parse(response.read_body)
|
52
|
+
end
|
6
53
|
end
|
7
54
|
end
|
data/lib/lhj/tools/version.rb
CHANGED
data/lib/lhj/tools.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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -262,6 +262,26 @@ dependencies:
|
|
262
262
|
- - "<"
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: 3.0.0
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: jwt
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: 2.1.0
|
272
|
+
- - "<"
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: '3'
|
275
|
+
type: :runtime
|
276
|
+
prerelease: false
|
277
|
+
version_requirements: !ruby/object:Gem::Requirement
|
278
|
+
requirements:
|
279
|
+
- - ">="
|
280
|
+
- !ruby/object:Gem::Version
|
281
|
+
version: 2.1.0
|
282
|
+
- - "<"
|
283
|
+
- !ruby/object:Gem::Version
|
284
|
+
version: '3'
|
265
285
|
description: lhj tools.
|
266
286
|
email:
|
267
287
|
- sanan.li@qq.com
|