cocoapods-TSPodfileTimeWatch 0.0.2 → 0.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2eae968c21fd848631b14ce12bcd71d0eed5f9058bf31ed01465f928a2d056b
|
4
|
+
data.tar.gz: fe4225acea142dcb9c02487a2a3925ee26a6dfdd3ebf3063a7078d0b6fdfa89e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9213d05f6fcad59348846cfb4d2ea4eb5b37fd94f4282778f28626060234fcdc573da5d8873dc5913c1e1396be92522b100850aec02dd03c95bb0e2131bc00e
|
7
|
+
data.tar.gz: 53459fd618f730609dfa0b7cc86311386601b05db3f71502e55838fd6e7913fad7fb2342f2cf7b559823c1ef99d45c0ed7bc27a320e3cb836e89793891143f72
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -18,39 +18,58 @@ class Dir
|
|
18
18
|
sum
|
19
19
|
end
|
20
20
|
end
|
21
|
-
$
|
21
|
+
$pluginIsVerbose = false
|
22
22
|
$gitSize = 0
|
23
|
+
$gitAllSize = 0
|
23
24
|
$cloneTime = 0
|
25
|
+
$cloneAllTime = 0
|
26
|
+
if ARGV.include?("--verbose")
|
27
|
+
$pluginIsVerbose = true
|
28
|
+
end
|
29
|
+
|
24
30
|
module CocoapodsTSPodfileTimeWatch
|
31
|
+
|
32
|
+
Pod::HooksManager.register("cocoapods-TSPodfileTimeWatch", :post_install) do |context|
|
33
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch gitAllSize: #{$gitAllSize}M\e[0m"
|
34
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch cloneAllTime: #{$cloneAllTime}S\e[0m"
|
35
|
+
if $pluginIsVerbose == true
|
36
|
+
puts "\e[31m 具体的统计数据请在#{Dir.home}/.AllPodsTimeAndSize.csv中查看"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
25
40
|
class Pod::Downloader::Cache
|
26
41
|
# 使用方法别名hook copy_and_clean方法
|
27
42
|
alias :origin_copy_and_clean :copy_and_clean
|
28
43
|
def copy_and_clean(source, destination, spec)
|
29
44
|
# 执行之前的拷贝到cache并且清除git clone临时目录的方法
|
30
45
|
origin_copy_and_clean(source, destination, spec)
|
31
|
-
#
|
32
|
-
if $
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
# 如果是--verbose,则输出详细信息,生成csv
|
47
|
+
if $pluginIsVerbose == true
|
48
|
+
verboseCopy_and_clean(source, destination, spec)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# --verbose输出详细信息,生成在home路劲下AllPodsTimeAndSize.csv的隐藏文件
|
53
|
+
def verboseCopy_and_clean(source, destination, spec)
|
54
|
+
begin
|
55
|
+
# 计算拷贝到的目录下所有文件总大小,单位为M
|
56
|
+
dirSum = Dir.size(destination.to_s)/1000.0/1000.0
|
57
|
+
# 标红输出cache文件大小,单位为M
|
58
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch cachesize #{spec.name}: "+"#{dirSum}"+"M\e[0m"
|
59
|
+
# 计算git clone大小和cache文件大小的差值,如果差值过大,则有优化空间
|
60
|
+
diffSize = $gitSize - dirSum
|
61
|
+
# 标红输出差值
|
62
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch diffSize = #{diffSize}\e[0m"
|
63
|
+
# 统计到csv中
|
64
|
+
CSV.open("#{Dir.home}/.AllPodsTimeAndSize.csv", "ab") do |csv|
|
65
|
+
csv << [spec.name, $cloneTime, $gitSize, dirSum, diffSize]
|
51
66
|
end
|
67
|
+
# 换行
|
68
|
+
puts
|
69
|
+
rescue => exception
|
70
|
+
# 输出拷贝清除方法异常
|
71
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch verboseCopy_and_clean error: #{exception}\e[0m"
|
52
72
|
end
|
53
|
-
$currentPodName = ""
|
54
73
|
$gitSize = 0
|
55
74
|
end
|
56
75
|
end
|
@@ -61,44 +80,49 @@ module CocoapodsTSPodfileTimeWatch
|
|
61
80
|
def clone(force_head = false, shallow_clone = true)
|
62
81
|
# 获取clone执行前时间点
|
63
82
|
time1 = Time.new
|
64
|
-
|
65
83
|
# 执行之前的clone方法
|
66
84
|
origin_clone(force_head, shallow_clone)
|
67
|
-
|
85
|
+
|
86
|
+
# 如果不是--verbose,只输出总耗时,总下载大小
|
68
87
|
# 捕获一下异常,不会因为plugin的原因导致pod失败
|
69
88
|
begin
|
70
89
|
# 获取clone执行后时间点
|
71
|
-
time2 = Time.
|
72
|
-
|
90
|
+
time2 = Time.new
|
73
91
|
# 获取时间差
|
74
92
|
time = time2 - time1
|
75
|
-
|
76
93
|
# 赋值一个给全局变量,之后时间统计要用到
|
77
94
|
$cloneTime = time
|
78
|
-
|
79
|
-
|
80
|
-
start = url.rindex("/") + 1
|
81
|
-
# 获取pod名称
|
82
|
-
podName = url[start, url.length]
|
83
|
-
# 赋值给一个全局变量,之后输出会用到
|
84
|
-
$currentPodName = podName
|
85
|
-
# 标红输出git clone耗时
|
86
|
-
puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone time: #{time}\e[0m"
|
87
|
-
|
95
|
+
# 赋值一个给全局变量,之后时间统计要用到
|
96
|
+
$cloneAllTime = $cloneAllTime + time
|
88
97
|
# 获取git clone下载的文件路径
|
89
98
|
source = target_path.to_s
|
90
99
|
# 计算git clone下载的文件大小,单位为M
|
91
100
|
dirSum = Dir.size(source)/1000.0/1000.0
|
92
101
|
# 赋值给一个全局变量,之后输出会用到
|
93
|
-
$
|
94
|
-
|
95
|
-
|
96
|
-
|
102
|
+
$gitAllSize = $gitAllSize + dirSum
|
103
|
+
# 如果是--verbose,则输出详细信息,生成csv
|
104
|
+
if $pluginIsVerbose == true
|
105
|
+
verboseClone(force_head, shallow_clone, time, dirSum)
|
106
|
+
end
|
97
107
|
rescue => exception
|
98
108
|
# 标红输出git clone hook异常
|
99
109
|
puts "\e[31mCocoapodsTSPodfileTimeWatch clone error: #{exception}\e[0m"
|
100
110
|
end
|
101
|
-
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
# --verbose输出每个库的下载耗时
|
115
|
+
def verboseClone(force_head, shallow_clone, time, dirSum)
|
116
|
+
# 这里只能根据url获取到pod名称的开始index
|
117
|
+
start = url.rindex("/") + 1
|
118
|
+
# 获取pod名称
|
119
|
+
podName = url[start, url.length]
|
120
|
+
# 标红输出git clone耗时
|
121
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone time: #{time}\e[0m"
|
122
|
+
# 赋值给一个全局变量,之后输出会用到
|
123
|
+
$gitSize = dirSum
|
124
|
+
# 标红输出git clone下载文件大小
|
125
|
+
puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone allsize: "+"#{dirSum}"+"M\e[0m"
|
102
126
|
end
|
103
127
|
end
|
104
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-TSPodfileTimeWatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- keai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|