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: b2c95827caec46a6b1b8c54326bb767cb81f842e4d667be7f0399096c880afbf
4
- data.tar.gz: a19c65824ed8c42822c9d8259c40e4b7c4a4342b9ac0385a627e1f4c35ee0850
3
+ metadata.gz: e2eae968c21fd848631b14ce12bcd71d0eed5f9058bf31ed01465f928a2d056b
4
+ data.tar.gz: fe4225acea142dcb9c02487a2a3925ee26a6dfdd3ebf3063a7078d0b6fdfa89e
5
5
  SHA512:
6
- metadata.gz: cd53beb57f9923d149b05266bcf196adc22f85042471d1430a381920099f8faf63621819e95c0f06d5e84a5d202536d320b9cb1ae7b2a5a21d6e15581608651a
7
- data.tar.gz: dc45f39767c040e90fec488fba632e0655d5aa32f0b2785025f13d27a743298e4390c1f95821fd3e128ebd053afe85c57313d88205a1346cc1e4ee8396badfd5
6
+ metadata.gz: e9213d05f6fcad59348846cfb4d2ea4eb5b37fd94f4282778f28626060234fcdc573da5d8873dc5913c1e1396be92522b100850aec02dd03c95bb0e2131bc00e
7
+ data.tar.gz: 53459fd618f730609dfa0b7cc86311386601b05db3f71502e55838fd6e7913fad7fb2342f2cf7b559823c1ef99d45c0ed7bc27a320e3cb836e89793891143f72
@@ -24,7 +24,7 @@ module Pod
24
24
  Longer description of cocoapods-TSPodfileTimeWatch.
25
25
  DESC
26
26
 
27
- self.arguments = 'NAME'
27
+ self.arguments = []
28
28
 
29
29
  def initialize(argv)
30
30
  @name = argv.shift_argument
@@ -1,3 +1,3 @@
1
1
  module CocoapodsTspodfiletimewatch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -18,39 +18,58 @@ class Dir
18
18
  sum
19
19
  end
20
20
  end
21
- $currentPodName = ""
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
- # 如果拷贝清除方法的pod名称与之前git clone记录下来的名称相同,则执行统计
32
- if $currentPodName.include? spec.name
33
- begin
34
- # 计算拷贝到的目录下所有文件总大小,单位为M
35
- dirSum = Dir.size(destination.to_s)/1000.0/1000.0
36
- # 标红输出cache文件大小,单位为M
37
- puts "\e[31mCocoapodsTSPodfileTimeWatch cachesize #{spec.name}: "+"#{dirSum}"+"M\e[0m"
38
- # 计算git clone大小和cache文件大小的差值,如果差值过大,则有优化空间
39
- diffSize = $gitSize - dirSum
40
- # 标红输出差值
41
- puts "\e[31mCocoapodsTSPodfileTimeWatch diffSize = #{diffSize}\e[0m"
42
- # 统计到csv中
43
- CSV.open("#{Dir.home}/Desktop/AllPodsTimeAndSize.csv", "ab") do |csv|
44
- csv << [spec.name, $cloneTime, $gitSize, dirSum, diffSize]
45
- end
46
- # 换行
47
- puts
48
- rescue => exception
49
- # 输出拷贝清除方法异常
50
- puts "\e[31mCocoapodsTSPodfileTimeWatch copy_and_clean error: #{exception}\e[0m"
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.now
72
-
90
+ time2 = Time.new
73
91
  # 获取时间差
74
92
  time = time2 - time1
75
-
76
93
  # 赋值一个给全局变量,之后时间统计要用到
77
94
  $cloneTime = time
78
-
79
- # 这里只能根据url获取到pod名称的开始index
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
- $gitSize = dirSum
94
-
95
- # 标红输出git clone下载文件大小
96
- puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone allsize: "+"#{dirSum}"+"M\e[0m"
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.2
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-10-22 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler