lhj-tools 0.2.75 → 0.2.77
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/ios_api_available_check_helper.rb +43 -11
- data/lib/lhj/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: '088cfbc6342f8a22645d61e41d2ba447ba8068e85d79b991a483f5c24867bea5'
|
4
|
+
data.tar.gz: d86e6f1ca4e2454614b238acb6535947d5d52c807e4d61631fcfe302d7fbb502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddcb696ee92dc1ea3c49a582bf4216405934aa6dd5eb075c4f1279f0d843d55fe6781a62e8d9dab48ab703d81e0bd35f530cce2e0222356ddc45a4c0485d2f37
|
7
|
+
data.tar.gz: 00f66ccc50f946a9327dc70ad9cc7676047be4c0c9b31e30e49cdaa6ce16477cfb547130277b29d8f4e0bfb394cc8a9d83806150781dabc3b2f96afcce61d451
|
@@ -2,7 +2,8 @@
|
|
2
2
|
module Lhj
|
3
3
|
class IosApiAvailableCheckHelper
|
4
4
|
|
5
|
-
API_AVAILABLE_KEY_BEGIN_REGEX = /@available
|
5
|
+
API_AVAILABLE_KEY_BEGIN_REGEX = /@available/.freeze
|
6
|
+
BLOCK_KEY_BEGIN_REGEX = /\^/.freeze
|
6
7
|
|
7
8
|
def self.check(path, type = 'm')
|
8
9
|
all_files = Dir.glob("#{path}/**/*.{#{type}}").reject do |p|
|
@@ -10,9 +11,13 @@ module Lhj
|
|
10
11
|
end
|
11
12
|
result = {}
|
12
13
|
all_files.each do |f|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
file_name = File.basename(f)
|
15
|
+
wrapper_map = find_available_wrapper(f)
|
16
|
+
# block循环引用提醒
|
17
|
+
handle_block_notify(file_name, wrapper_map[:blocks]) if wrapper_map[:blocks].length.positive?
|
18
|
+
# 处理高版本api提示
|
19
|
+
infos = handle_available_file(f, wrapper_map[:avails])
|
20
|
+
result[file_name] = infos if infos.length.positive?
|
16
21
|
end
|
17
22
|
# result
|
18
23
|
# show_result(result)
|
@@ -30,10 +35,12 @@ module Lhj
|
|
30
35
|
end
|
31
36
|
|
32
37
|
def self.find_available_wrapper(file)
|
33
|
-
|
38
|
+
available_lines = []
|
39
|
+
block_lines = []
|
34
40
|
File.open(file, 'r') do |f|
|
35
41
|
multi_comment = false
|
36
42
|
available_idx = 0
|
43
|
+
block_idx = 0
|
37
44
|
f.readlines.each_with_index do |line, idx|
|
38
45
|
multi_comment = true if line =~ %r{/\*} && line !~ %r{\*/} && !multi_comment
|
39
46
|
if line !~ %r{/\*} && line =~ %r{\*/} && multi_comment
|
@@ -43,17 +50,42 @@ module Lhj
|
|
43
50
|
|
44
51
|
next if multi_comment
|
45
52
|
next if line =~ %r{\s*//}
|
46
|
-
next unless line =~ API_AVAILABLE_KEY_BEGIN_REGEX || available_idx.positive?
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
if line =~ API_AVAILABLE_KEY_BEGIN_REGEX || available_idx.positive?
|
55
|
+
available_idx += 1 if line =~ /\{/
|
56
|
+
available_idx -= 1 if line =~ /\}/
|
57
|
+
available_lines << { idx: idx }
|
58
|
+
end
|
59
|
+
if (line =~ BLOCK_KEY_BEGIN_REGEX && line !~ /^\s*[+-]/ && line !~ /dispatch_get_main_queue/) || block_idx.positive?
|
60
|
+
line_position = block_idx.zero? ? :start : :process
|
61
|
+
block_idx += 1 if line =~ /\{/
|
62
|
+
block_idx -= 1 if line =~ /\}/
|
63
|
+
line_position = :end if block_idx.zero?
|
64
|
+
block_lines << { idx: idx, line: line, position: line_position }
|
65
|
+
end
|
51
66
|
end
|
52
67
|
end
|
53
|
-
|
68
|
+
{ avails: available_lines, blocks: block_lines }
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.handle_block_notify(file_name, wrapper_lines)
|
72
|
+
arr = wrapper_lines.filter { |l| l[:position] != :start }
|
73
|
+
arr.filter! { |l| l[:position] != :end }
|
74
|
+
arr.filter! { |l| l[:line] =~ /self/ || l[:line] =~ /\W+_/ }
|
75
|
+
arr.filter! { |l| l[:line] !~ /\^/ }
|
76
|
+
arr.filter! { |l| l[:line] !~ /weak/ }
|
77
|
+
arr.filter! { |l| l[:line] !~ /strong/ }
|
78
|
+
return if arr.empty?
|
79
|
+
|
80
|
+
puts "源文件:#{file_name}"
|
81
|
+
arr.each do |l|
|
82
|
+
puts "第#{l[:idx] + 1}行:"
|
83
|
+
puts l[:line].strip
|
84
|
+
end
|
85
|
+
puts "\n"
|
54
86
|
end
|
55
87
|
|
56
|
-
def self.
|
88
|
+
def self.handle_available_file(file, wrapper_lines)
|
57
89
|
result = []
|
58
90
|
File.open(file, 'r') do |f|
|
59
91
|
multi_comment = false
|
data/lib/lhj/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.2.
|
4
|
+
version: 0.2.77
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|