lhj-tools 0.2.57 → 0.2.59
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/image_oss_check_helper.rb +75 -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: 0b1d113183468cf58d8ce14ef22990c96a507f33716a2da088f56a4157c3d433
|
4
|
+
data.tar.gz: 8972b208acd3e14c5ebc9a5b208485de017524be9e93fdd5643e1fb0528f3898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b47948cc96591c7b6d717b6f9c755448deac600b113fb31407b72e43d5272d2273a8f79af1b8679abfc3c1a35ba53a680b9ae73a7bb7236c290dcd00283f5724
|
7
|
+
data.tar.gz: 79283d6caab2cdb57db0b0cf80096e7aaf1ad114f198fc40e3ff49a542ed679aa38ef87ab15e457ba3b10783c8f62d4e461fdd5971f5cf5e98dc99e38f85db2a
|
@@ -0,0 +1,75 @@
|
|
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
|
+
result
|
18
|
+
# show_result(result)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.show_result(result)
|
22
|
+
result.each do |k, v|
|
23
|
+
puts k
|
24
|
+
v.each do |o|
|
25
|
+
puts "第#{o[:idx]}行:"
|
26
|
+
puts o[:var]
|
27
|
+
puts o[:line]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.handle_file(file)
|
33
|
+
result = []
|
34
|
+
File.open(file, 'r') do |f|
|
35
|
+
oss_var = nil
|
36
|
+
multi_comment = false
|
37
|
+
f.readlines.each_with_index do |line, idx|
|
38
|
+
multi_comment = true if line =~ %r{/\*} && line !~ %r{\*/} && !multi_comment
|
39
|
+
if line !~ %r{/\*} && line =~ %r{\*/} && multi_comment
|
40
|
+
multi_comment = false
|
41
|
+
next
|
42
|
+
end
|
43
|
+
|
44
|
+
next if multi_comment
|
45
|
+
next if line =~ %r{\s*//}
|
46
|
+
|
47
|
+
oss_var = fetch_oss_path(line) if line =~ OSS_PATH_REGEX
|
48
|
+
next unless line =~ SD_IMAGE_OSS_REGEX
|
49
|
+
|
50
|
+
oss_info = fetch_sd_image_url(file, line, idx, oss_var)
|
51
|
+
result << oss_info if oss_info
|
52
|
+
oss_var = nil if oss_info
|
53
|
+
end
|
54
|
+
end
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.fetch_oss_path(line)
|
59
|
+
oss_match = OSS_PATH_REGEX.match(line)
|
60
|
+
oss_match[:var]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.fetch_sd_image_url(file, line, idx, oss_var)
|
64
|
+
url_match = SD_IMAGE_OSS_REGEX.match(line)
|
65
|
+
oss_url = url_match[:url]
|
66
|
+
|
67
|
+
return nil if oss_var && oss_var == oss_url
|
68
|
+
return nil if oss_url =~ /ml_addOssPathIgnoreGif/
|
69
|
+
return nil if oss_url =~ /x-oss-process=style/
|
70
|
+
|
71
|
+
{ idx: idx + 1, line: line.strip, var: oss_url }
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
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.59
|
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-22 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
|