itools 0.5.0 → 1.1.5
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/.ruby-version +1 -1
- data/Gemfile.lock +8 -6
- data/README.md +4 -4
- data/bin/itools +8 -0
- data/lib/itools/class_unuse_finder.rb +1 -0
- data/lib/itools/find_unuse_img.rb +2 -0
- data/lib/itools/get_size.rb +4 -2
- data/lib/itools/link_map.rb +12 -4
- data/lib/itools/podfile_tiled.rb +95 -0
- data/lib/itools/version.rb +2 -1
- data/lib/itools.rb +2 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231409dd71fbd6f84598d2270edc928ad0288089b0bdb9536632cc832ed20bae
|
4
|
+
data.tar.gz: a64240894bfa6a17fcf0d4d63050378cf5c8e9cc4f6239ff0329d0cce0eff302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '049cbfd7152daa2944833d1d3f7cae6ef40a00725c2811f02779105919b34a09cf3fe94cf33c034aa1801646e169437eed0808e818282de8d1333b64a1565719'
|
7
|
+
data.tar.gz: d9e790bc02448e7d0c9e0516527333f02ed1a834138a5d35dbfd186e0f83be6ada8e29c83aa1dc0f4733040299f437b2ed0848de8bf0ba69f4e1cd1794c25e44
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.4.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
itools (
|
4
|
+
itools (1.1.5)
|
5
5
|
bundler (~> 1.17)
|
6
6
|
git (~> 1.5)
|
7
7
|
gli (~> 2.17)
|
@@ -11,11 +11,13 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
git (1.
|
15
|
-
|
14
|
+
git (1.7.0)
|
15
|
+
rchardet (~> 1.8)
|
16
|
+
gli (2.20.0)
|
16
17
|
rake (10.5.0)
|
17
|
-
|
18
|
-
|
18
|
+
rchardet (1.8.0)
|
19
|
+
ruby-ole (1.2.12.2)
|
20
|
+
spreadsheet (1.2.6)
|
19
21
|
ruby-ole (>= 1.0)
|
20
22
|
|
21
23
|
PLATFORMS
|
@@ -25,4 +27,4 @@ DEPENDENCIES
|
|
25
27
|
itools!
|
26
28
|
|
27
29
|
BUNDLED WITH
|
28
|
-
1.17.
|
30
|
+
1.17.3
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ SYNOPSIS
|
|
19
19
|
itools [global options] command [command options] [arguments...]
|
20
20
|
|
21
21
|
VERSION
|
22
|
-
0.
|
22
|
+
1.0.0
|
23
23
|
|
24
24
|
GLOBAL OPTIONS
|
25
25
|
--help - Show this message
|
@@ -40,7 +40,7 @@ COMMANDS
|
|
40
40
|
### 功能1:解析LinkMap
|
41
41
|
命令:
|
42
42
|
```shell
|
43
|
-
itools parse LinkMapDemo-LinkMap-normal-arm64.txt
|
43
|
+
itools parse LinkMapDemo-LinkMap-normal-arm64.txt (分析文件夹)
|
44
44
|
# or
|
45
45
|
itools parse /user/Desk/LinkMapDemo-LinkMap-normal-arm64.txt
|
46
46
|
```
|
@@ -56,8 +56,8 @@ Foundation.tbd 24B
|
|
56
56
|
UIKit.tbd 24B
|
57
57
|
Total Size:10.07KB
|
58
58
|
```
|
59
|
-
For more information, see:[https://www.cnblogs.com/zhanggui/p/9991455.html](https://www.cnblogs.com/zhanggui/p/9991455.html)
|
60
|
-
|
59
|
+
For more information, see:[https://www.cnblogs.com/zhanggui/p/9991455.html](https://www.cnblogs.com/zhanggui/p/9991455.html)
|
60
|
+
也可以根据linkmap按照folder解析,即传入第二个参数为分析的引用库目录,例如想查看AFNetWorking中各个文件夹(内容)所占二进制的大小。
|
61
61
|
### 功能2:字符串查找
|
62
62
|
命令
|
63
63
|
```ruby
|
data/bin/itools
CHANGED
@@ -79,4 +79,12 @@ command :pre_commit do |c|
|
|
79
79
|
Itools::GitSets.commit_msg_init(args)
|
80
80
|
end
|
81
81
|
end
|
82
|
+
#本地commit规范化
|
83
|
+
desc "通过执行该命令,可以将podfile.lock中所有的依赖平铺至Podifle中"
|
84
|
+
arg 'podfile.lock'
|
85
|
+
command :podfile_tiled do |c|
|
86
|
+
c.action do |global_options,options, args|
|
87
|
+
Itools::PodfileTiled.podfile_tiled(args)
|
88
|
+
end
|
89
|
+
end
|
82
90
|
exit run(ARGV)
|
@@ -81,11 +81,13 @@ module Itools
|
|
81
81
|
sheet1 = book.create_worksheet
|
82
82
|
sheet1.row(0)[0] = "文件名"
|
83
83
|
sheet1.row(0)[1] = "文件路径"
|
84
|
+
sheet1.row(0)[2] = "文件大小(B)"
|
84
85
|
imags.each_with_index {|item,idx|
|
85
86
|
sheet1.row(idx+1)[0] = item
|
86
87
|
path = imgFinder.get_image_path(item)
|
87
88
|
sheet1.row(idx+1)[1] = path
|
88
89
|
unuse_total_size = unuse_total_size + File.size(path)
|
90
|
+
sheet1.row(idx+1)[2] = File.size(path)
|
89
91
|
puts item
|
90
92
|
}
|
91
93
|
book.write "#{imgFinder.find_path}/search_result.xls"
|
data/lib/itools/get_size.rb
CHANGED
@@ -42,6 +42,7 @@ module Itools
|
|
42
42
|
file_count = 0
|
43
43
|
total_count = 0
|
44
44
|
total_size = 0
|
45
|
+
file_size = 0
|
45
46
|
Find.find(folder) do |filename|
|
46
47
|
if File.file?(filename)
|
47
48
|
total_count = total_count + 1
|
@@ -52,15 +53,16 @@ module Itools
|
|
52
53
|
elsif file_exts.include?(File.extname(filename).delete(".")) #查找指定后缀的文件
|
53
54
|
sum = sum + File.size(filename)
|
54
55
|
file_count = file_count + 1
|
56
|
+
file_size = file_size + File.size(filename)
|
55
57
|
else
|
56
58
|
#不做任何处理
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
if file_exts.size == 0
|
61
|
-
puts "\033[32m文件夹中共#{total_count}个文件,共#{get_show_size(total_size)}\033[0m"
|
63
|
+
puts "\033[32m文件夹中共#{total_count}个文件,共#{get_show_size(total_size)}(#{total_size})\033[0m"
|
62
64
|
else
|
63
|
-
puts "\033[32m文件夹中共#{total_count}个文件,共#{get_show_size(total_size)};找到后缀为(#{file_exts_string})的文件#{file_count}个,共#{get_show_size(
|
65
|
+
puts "\033[32m文件夹中共#{total_count}个文件,共#{get_show_size(total_size)}(#{total_size});找到后缀为(#{file_exts_string})的文件#{file_count}个,共#{get_show_size(file_size)}(#{file_size}).\033[0m"
|
64
66
|
end
|
65
67
|
|
66
68
|
# puts `du -b #{folder} | awk '{print $1}'`.to_i
|
data/lib/itools/link_map.rb
CHANGED
@@ -138,6 +138,11 @@ module Itools
|
|
138
138
|
handle_method_name = "handle_sections"
|
139
139
|
puts "处理Sections..."
|
140
140
|
elsif line.include?("Symbols:") #symbols:和Dead Stripped Symbols处理一样
|
141
|
+
# 这里不处理Dead Stripped Symbols
|
142
|
+
if line.delete('#').strip.include?("Dead Stripped Symbols")
|
143
|
+
puts "不处理处理#{line.delete('#').strip}..."
|
144
|
+
break
|
145
|
+
end
|
141
146
|
puts "处理#{line.delete('#').strip}..."
|
142
147
|
handle_method_name = "handle_symbols"
|
143
148
|
end
|
@@ -227,7 +232,7 @@ module Itools
|
|
227
232
|
# 打印结果
|
228
233
|
sizeResultArr.each do |obj|
|
229
234
|
puts "#{obj.file_name} " + SizeResult.handleSize(obj.size)
|
230
|
-
save_file.puts("#{obj.file_name} #{SizeResult.handleSize(obj.size)}")
|
235
|
+
save_file.puts("#{obj.file_name} #{SizeResult.handleSize(obj.size)}(#{obj.size})")
|
231
236
|
end
|
232
237
|
save_file.puts("总大小为:#{SizeResult.handleSize(total_size)}")
|
233
238
|
save_file.close
|
@@ -301,8 +306,10 @@ module Itools
|
|
301
306
|
File.delete(save_file_path)
|
302
307
|
end
|
303
308
|
save_file = File.new(save_file_path,"w+")
|
309
|
+
o_index = 2
|
304
310
|
size_results.each do |o|
|
305
|
-
|
311
|
+
result_str = "#{' ' * o.space_count}├── #{o.folder_name.split('/').last} #{SizeResult.handleSize(o.size)}(#{o.size})"
|
312
|
+
save_file.puts(result_str)
|
306
313
|
end
|
307
314
|
save_file.close
|
308
315
|
puts "分析结果已经保存为文件,位置为:\n\033[32m#{save_file_path}\033[0m"
|
@@ -313,7 +320,8 @@ module Itools
|
|
313
320
|
space_index = space_index + 2
|
314
321
|
file_name_arr = [] #盛放计算过的类
|
315
322
|
Find.find(file_path) do |file|
|
316
|
-
|
323
|
+
# 不包含图片
|
324
|
+
if File.file?(file) && !(File.extname(file) =~ /(png|gif|jpg|bmp|jpeg)/)
|
317
325
|
file_name = File.basename(file,".*")
|
318
326
|
if !file_name_arr.include?(file_name) && sort_by_obj_files_map[file_name] #没有已经计算过
|
319
327
|
s_result.size = s_result.size + sort_by_obj_files_map[file_name][0].o_size
|
@@ -350,7 +358,7 @@ module Itools
|
|
350
358
|
def self.getSaveFileName(path_para)
|
351
359
|
path = Pathname.new(path_para)
|
352
360
|
# 要保存的地址
|
353
|
-
save_file_path = path.dirname.to_s + "/" + "parse_" + path.basename.to_s + "_result.txt"
|
361
|
+
save_file_path = path.dirname.to_s + "/" + "parse_" + path.basename.to_s + "_result(#{Time.new.strftime("%Y%m%d%H%M%S")}).txt"
|
354
362
|
return save_file_path
|
355
363
|
end
|
356
364
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Itools
|
2
|
+
class PodInfo
|
3
|
+
attr_accessor :pod_name, :pod_version
|
4
|
+
def initialize(name, version)
|
5
|
+
@pod_name = name
|
6
|
+
@pod_version = version
|
7
|
+
end
|
8
|
+
end
|
9
|
+
class PodfileTiled
|
10
|
+
def self.podfile_tiled(args)
|
11
|
+
all_pods = [] #所有依赖的pod
|
12
|
+
exist_pods = [] #当前podfile已经存在的pod
|
13
|
+
need_add_pods = [] #当前需要添加到podfile中的pod
|
14
|
+
pod_tag = 1
|
15
|
+
|
16
|
+
fileInfo = File.open(args[0])
|
17
|
+
|
18
|
+
total_index = 0
|
19
|
+
fileInfo.each_line do |line|
|
20
|
+
line_string = line.delete("\n")
|
21
|
+
if line_string == 'PODS:'
|
22
|
+
# 配置成功,后续请直接使用git commit ,不要加 -m\033[0m
|
23
|
+
puts "\033[32m开始分析依赖\033[0m"
|
24
|
+
pod_tag = 1
|
25
|
+
next
|
26
|
+
elsif line_string == 'DEPENDENCIES:'
|
27
|
+
puts "\033[32m开始分析当前Podfile中已添加的依赖项\033[0m"
|
28
|
+
pod_tag = 2
|
29
|
+
next
|
30
|
+
elsif line_string == 'SPEC REPOS:'
|
31
|
+
pod_tag = 0
|
32
|
+
puts "\033[32mpodfile.lock分析结束\033[0m"
|
33
|
+
end
|
34
|
+
|
35
|
+
if pod_tag == 1 #分析所有pod
|
36
|
+
if line_string[0, 3] == ' -' && !line_string.include?('/')
|
37
|
+
# puts line_string
|
38
|
+
pod_version = line_string[/\((.*?)\)/, 1]
|
39
|
+
pod_name =
|
40
|
+
line_string.gsub(pod_version, '').delete('(').delete(')').delete(
|
41
|
+
':'
|
42
|
+
).delete('-').strip
|
43
|
+
temp_pod = PodInfo.new(pod_name, pod_version)
|
44
|
+
all_pods << temp_pod
|
45
|
+
puts "查找到pod库:#{pod_name}, 版本号为:'#{pod_version}' #{all_pods.length}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if pod_tag == 2 #分析当前podfile已经有的pod
|
50
|
+
pod_name
|
51
|
+
pod_version = line_string[/\((.*?)\)/, 1]
|
52
|
+
if pod_version
|
53
|
+
pod_name =
|
54
|
+
line_string.gsub(pod_version, '').delete('(').delete(')').delete(
|
55
|
+
':'
|
56
|
+
).delete('-').strip
|
57
|
+
else
|
58
|
+
pod_name = line_string.delete('-').lstrip.rstrip
|
59
|
+
end
|
60
|
+
|
61
|
+
if pod_name.length == 0 || pod_name.include?('/')
|
62
|
+
next
|
63
|
+
end
|
64
|
+
temp_pod = PodInfo.new(pod_name, pod_version)
|
65
|
+
if pod_version
|
66
|
+
temp_pod.pod_version = pod_version.delete('=').strip
|
67
|
+
end
|
68
|
+
|
69
|
+
exist_pods << temp_pod
|
70
|
+
puts "Podfile中已包含 #{pod_name}, 版本号为:'#{pod_version}'"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
temp_exist_pods = []
|
74
|
+
all_pods.each do |all_pod|
|
75
|
+
exist_pods.each do |exist_pod|
|
76
|
+
if all_pod.pod_name == exist_pod.pod_name
|
77
|
+
temp_exist_pods << all_pod
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
need_add_pods = all_pods - temp_exist_pods
|
83
|
+
if need_add_pods.length == 0
|
84
|
+
puts "\033[32m恭喜!!!无需平铺,当前已全部平铺\033[0m"
|
85
|
+
else
|
86
|
+
puts "\033[32m以下为要平铺的库,直接复制粘贴至Podfile中即可:\033[0m"
|
87
|
+
need_add_pods.each do |to_add|
|
88
|
+
puts "pod '#{to_add.pod_name}', '#{to_add.pod_version}'"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
data/lib/itools/version.rb
CHANGED
data/lib/itools.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhanggui
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/itools/get_size.rb
|
114
114
|
- lib/itools/git_sets.rb
|
115
115
|
- lib/itools/link_map.rb
|
116
|
+
- lib/itools/podfile_tiled.rb
|
116
117
|
- lib/itools/string_searcher.rb
|
117
118
|
- lib/itools/temple-commit-msg.dat
|
118
119
|
- lib/itools/version.rb
|
@@ -124,7 +125,7 @@ metadata:
|
|
124
125
|
homepage_uri: https://github.com/ScottZg/itools
|
125
126
|
source_code_uri: https://github.com/ScottZg/itools
|
126
127
|
changelog_uri: https://github.com/ScottZg/itools/blob/master/README.md
|
127
|
-
post_install_message:
|
128
|
+
post_install_message:
|
128
129
|
rdoc_options: []
|
129
130
|
require_paths:
|
130
131
|
- lib
|
@@ -139,9 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
|
-
|
143
|
-
|
144
|
-
signing_key:
|
143
|
+
rubygems_version: 3.0.9
|
144
|
+
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: iOS tools
|
147
147
|
test_files: []
|