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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1522e2e897fadad490a8c1b9baaff75d7472a3d7deeadf7bdb790ff310bcd56d
4
- data.tar.gz: fa96344cdf3abd706ac13f0b349a3c9b0eb3e745d4da0befb1dc0ef4fcc0d57f
3
+ metadata.gz: 0b1d113183468cf58d8ce14ef22990c96a507f33716a2da088f56a4157c3d433
4
+ data.tar.gz: 8972b208acd3e14c5ebc9a5b208485de017524be9e93fdd5643e1fb0528f3898
5
5
  SHA512:
6
- metadata.gz: f8c8b06eb183abc0969c0ec0d09fccff56c2977ccc3f55923e49180759ac36dbce014f1a98297afd84e93f5befc8eda5f219c09e9792d65780b8af8949d25134
7
- data.tar.gz: 9d7caf469da443e5be5b0aa963848cc0ce9f5eac7ae60542d67bdafee2841a7aa3bc8bfa0aca0f4f6422417e3144d300f5341ac38f39aaaf6052d4a8e0ff8eec
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
@@ -31,6 +31,7 @@ module Lhj
31
31
  require 'lhj/helper/bugly_helper'
32
32
  require 'lhj/helper/traditional_check_helper'
33
33
  require 'lhj/helper/todo_check_helper'
34
+ require 'lhj/helper/image_oss_check_helper'
34
35
 
35
36
  class Error < StandardError; end
36
37
 
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.57'
4
+ VERSION = '0.2.59'
5
5
  end
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.57
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-14 00:00:00.000000000 Z
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