lhj-tools 0.2.57 → 0.2.58
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/helper/image_oss_check_helper.rb +73 -0
- data/lib/lhj/lhj.rb +1 -0
- data/lib/lhj/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 875d220405250a700a625e00c01066f23218ca09177b843b155165bc4dba3842
|
|
4
|
+
data.tar.gz: 5a4b9e1f653d31a54d6f4cd5a8a40c06d7002f2371d74caa562f5a34a7e2f871
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5380890249c39f87d479383c60da890213ce34d15005f4120ebbb7f33d1819556ff7e071f3e47a53ff14ac504469422fe73afba0fad025a4b06a14859c34d7e5
|
|
7
|
+
data.tar.gz: c64c70794e07142dab6a268922b1508f56699b881fa4baff65ca18d30737bb20417dde791d9c6fb2f04f7760207899734c878ed5ad54c6316dd5a12e7de1833a
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module Lhj
|
|
2
|
+
class ImageOssCheckHelper
|
|
3
|
+
|
|
4
|
+
OSS_PATH_REGEX = /(?<var>[a-zA-Z0-9_]+)\W*=.*ml_addOssPathIgnoreGif:.*/.freeze
|
|
5
|
+
|
|
6
|
+
SD_IMAGE_OSS_REGEX = /sd_setImageWithURL:\s*\[NSURL\s*URLWithString:(?<url>[^\]]+)\]/.freeze
|
|
7
|
+
|
|
8
|
+
def self.check(path, type = 'm')
|
|
9
|
+
all_files = Dir.glob("#{path}/**/*.{#{type}}").reject do |p|
|
|
10
|
+
p =~ /Pods/
|
|
11
|
+
end
|
|
12
|
+
result = {}
|
|
13
|
+
all_files.each do |f|
|
|
14
|
+
infos = handle_file(f)
|
|
15
|
+
result[File.basename(f)] = infos if infos.length.positive?
|
|
16
|
+
end
|
|
17
|
+
show_result(result)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.show_result(result)
|
|
21
|
+
result.each do |k, v|
|
|
22
|
+
puts k
|
|
23
|
+
v.each do |o|
|
|
24
|
+
puts "第#{o[:idx]}行:"
|
|
25
|
+
puts o[:line]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.handle_file(file)
|
|
31
|
+
result = []
|
|
32
|
+
File.open(file, 'r') do |f|
|
|
33
|
+
oss_var = nil
|
|
34
|
+
multi_comment = false
|
|
35
|
+
f.readlines.each_with_index do |line, idx|
|
|
36
|
+
multi_comment = true if line =~ %r{/\*} && line !~ %r{\*/} && !multi_comment
|
|
37
|
+
if line !~ %r{/\*} && line =~ %r{\*/} && multi_comment
|
|
38
|
+
multi_comment = false
|
|
39
|
+
next
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
next if multi_comment
|
|
43
|
+
next if line =~ %r{\s*//}
|
|
44
|
+
|
|
45
|
+
oss_var = fetch_oss_path(line) if line =~ OSS_PATH_REGEX
|
|
46
|
+
next unless line =~ SD_IMAGE_OSS_REGEX
|
|
47
|
+
|
|
48
|
+
oss_info = fetch_sd_image_url(file, line, idx, oss_var)
|
|
49
|
+
result << oss_info if oss_info
|
|
50
|
+
oss_var = nil if oss_info
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
result
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.fetch_oss_path(line)
|
|
57
|
+
oss_match = OSS_PATH_REGEX.match(line)
|
|
58
|
+
oss_match[:var]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.fetch_sd_image_url(file, line, idx, oss_var)
|
|
62
|
+
url_match = SD_IMAGE_OSS_REGEX.match(line)
|
|
63
|
+
oss_url = url_match[:url]
|
|
64
|
+
|
|
65
|
+
return nil if oss_var && oss_var == oss_url
|
|
66
|
+
return nil if oss_url =~ /ml_addOssPathIgnoreGif/
|
|
67
|
+
return nil if oss_url =~ /x-oss-process=style/
|
|
68
|
+
|
|
69
|
+
{ idx: idx + 1, line: line.strip }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
data/lib/lhj/lhj.rb
CHANGED
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.58
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- lihaijian
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-08-
|
|
11
|
+
date: 2023-08-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xcodeproj
|
|
@@ -392,6 +392,7 @@ files:
|
|
|
392
392
|
- lib/lhj/helper/erb_template_helper.rb
|
|
393
393
|
- lib/lhj/helper/git_branch_feature_config.rb
|
|
394
394
|
- lib/lhj/helper/git_helper.rb
|
|
395
|
+
- lib/lhj/helper/image_oss_check_helper.rb
|
|
395
396
|
- lib/lhj/helper/ios_robot_config.rb
|
|
396
397
|
- lib/lhj/helper/jenkins_config.rb
|
|
397
398
|
- lib/lhj/helper/local_config.rb
|