lhj-tools 0.2.17 → 0.2.19
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/todo_check_helper.rb +38 -0
- data/lib/lhj/helper/traditional_check_helper.rb +8 -5
- data/lib/lhj/lhj.rb +1 -0
- data/lib/lhj/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 525417a4e958bbc9be94070a3129c48408879197ae4716b3ad969c6058c0139e
|
4
|
+
data.tar.gz: ebe5250b35001d7797f2750ee5b855946f53495a1a6baa562b5ba60cf94d9088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df1d90dba187a4b4028027488a4c530bdf6d137fb17f8bc0c035f96c69891f15967032a6bf6a2748aebcdcbfb667e4c5e34f7c57a0a16511afe4b85f7cb8b9f3
|
7
|
+
data.tar.gz: c54c1d33a33e09e2fe61b3e66a1f36bec5e7f20f0e4eb5c73e3f75556021a57862e25f1a99defb35af593c7f6947ff22973250913e22b353afcae9d896edda0d
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Lhj
|
2
|
+
class TodoCheckHelper
|
3
|
+
def self.check(path, type = 'm,h')
|
4
|
+
all_files = Dir.glob("#{path}/**/*.{#{type}}").reject do |p|
|
5
|
+
p =~ /Pods/
|
6
|
+
end
|
7
|
+
result = []
|
8
|
+
all_files.each do |f|
|
9
|
+
result << handle_file(f)
|
10
|
+
end
|
11
|
+
notify(result.flatten) if result.length.positive?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.handle_file(file)
|
15
|
+
result = []
|
16
|
+
File.open(file, 'r') do |f|
|
17
|
+
f.readlines.each_with_index do |line, idx|
|
18
|
+
next unless line =~ %r{//} && line =~ /todo|TOdo|Todo|TODO/
|
19
|
+
|
20
|
+
result << { file: File.basename(file), idx: idx + 1, todo: line.strip }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.robot_url
|
27
|
+
'https://oapi.dingtalk.com/robot/send?access_token=fe879fd3e7a3b5e59d5719b2384845b7884901919be5a78fe443cbf777869807'
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.notify(result)
|
31
|
+
temp = Lhj::ErbTemplateHelper.load('todo_code_notify')
|
32
|
+
temp_result = Lhj::ErbTemplateHelper.render(temp, { result: result }, '-')
|
33
|
+
puts temp_result
|
34
|
+
Lhj::Dingtalk.post_message_robot(robot_url, 'check code', temp_result)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Lhj
|
2
2
|
class TraditionalCheckHelper
|
3
|
-
def self.check(path, ignore_path, type = 'm,h,pch
|
3
|
+
def self.check(path, ignore_path, type = 'm,h,pch')
|
4
4
|
ignore_file = File.join(ignore_path, '.checkignore')
|
5
5
|
ignore_list = []
|
6
6
|
ignore_list = File.readlines(ignore_file).map { |f| f.gsub(/\n/, '') } if File.exist?(ignore_file)
|
7
7
|
check_ignore(path, type: type, ignore: ignore_list)
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.check_ignore(path, type: 'm,h,pch
|
10
|
+
def self.check_ignore(path, type: 'm,h,pch', ignore: [])
|
11
11
|
result = {}
|
12
12
|
all_files = Dir.glob("#{path}/**/*.{#{type}}").reject do |p|
|
13
13
|
p =~ /Pods/ || ignore.include?(File.basename(p))
|
@@ -18,7 +18,7 @@ module Lhj
|
|
18
18
|
|
19
19
|
result[File.basename(f)] = infos
|
20
20
|
end
|
21
|
-
|
21
|
+
result.keys.each_slice(10) { |a| notify(result.slice(*a)) }
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.show_result(result)
|
@@ -37,10 +37,13 @@ module Lhj
|
|
37
37
|
File.open(file, 'r') do |f|
|
38
38
|
f.readlines.each_with_index do |line, idx|
|
39
39
|
next if line =~ %r{//}
|
40
|
+
next if line =~ /#/
|
41
|
+
next if line.strip =~ /^\*/
|
42
|
+
next if line =~ /log|Log|LOG/
|
40
43
|
next unless line =~ /[\u4e00-\u9fa5]/
|
41
44
|
next unless Lhj::Trans::Helper.instance.contain_zh_hk(line)
|
42
45
|
|
43
|
-
result << { idx: idx, cn: line.strip, hk: Lhj::Trans::Helper.instance.trans_zh_hk_str(line).strip }
|
46
|
+
result << { idx: idx + 1, cn: line.strip, hk: Lhj::Trans::Helper.instance.trans_zh_hk_str(line).strip }
|
44
47
|
end
|
45
48
|
end
|
46
49
|
result
|
@@ -54,7 +57,7 @@ module Lhj
|
|
54
57
|
temp = Lhj::ErbTemplateHelper.load('traditional_code_notify')
|
55
58
|
temp_result = Lhj::ErbTemplateHelper.render(temp, { result: result }, '-')
|
56
59
|
puts temp_result
|
57
|
-
Lhj::Dingtalk.
|
60
|
+
Lhj::Dingtalk.post_message_robot(robot_url, 'check code', temp_result)
|
58
61
|
end
|
59
62
|
|
60
63
|
end
|
data/lib/lhj/lhj.rb
CHANGED
data/lib/lhj/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhj-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
@@ -398,6 +398,7 @@ files:
|
|
398
398
|
- lib/lhj/helper/tb_config.rb
|
399
399
|
- lib/lhj/helper/tb_helper.rb
|
400
400
|
- lib/lhj/helper/team_member_config.rb
|
401
|
+
- lib/lhj/helper/todo_check_helper.rb
|
401
402
|
- lib/lhj/helper/traditional_check_helper.rb
|
402
403
|
- lib/lhj/helper/trans_helper.rb
|
403
404
|
- lib/lhj/helper/vika_config.rb
|