Class: Pod::Downloader::Git
- Inherits:
-
Object
- Object
- Pod::Downloader::Git
- Defined in:
- lib/cocoapods_plugin.rb
Instance Method Summary collapse
- #clone(force_head = false, shallow_clone = true) ⇒ Object
-
#origin_clone ⇒ Object
使用方法别名hook clone方法.
-
#verboseClone(force_head, shallow_clone, time, dirSum) ⇒ Object
–verbose输出每个库的下载耗时.
Instance Method Details
#clone(force_head = false, shallow_clone = true) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cocoapods_plugin.rb', line 104 def clone(force_head = false, shallow_clone = true) # 获取clone执行前时间点 time1 = Time.new # 执行之前的clone方法 origin_clone(force_head, shallow_clone) # 如果不是--verbose,只输出总耗时,总下载大小 # 捕获一下异常,不会因为plugin的原因导致pod失败 begin # 获取clone执行后时间点 time2 = Time.new # 获取时间差 time = time2 - time1 # 赋值一个给全局变量,之后时间统计要用到 $cloneTime = time # 赋值一个给全局变量,之后时间统计要用到 $cloneAllTime = $cloneAllTime + time # 获取git clone下载的文件路径 source = target_path.to_s # 计算git clone下载的文件大小,单位为M dirSum = Dir.size(source)/1000.0/1000.0 # 赋值给一个全局变量,之后输出会用到 $gitAllSize = $gitAllSize + dirSum # 如果是--verbose,则输出详细信息,生成csv if $pluginIsVerbose == true verboseClone(force_head, shallow_clone, time, dirSum) end rescue => exception # 标红输出git clone hook异常 puts "\e[31mCocoapodsTSPodfileTimeWatch clone error(已捕获): #{exception}\e[0m" end end |
#origin_clone ⇒ Object
使用方法别名hook clone方法
103 |
# File 'lib/cocoapods_plugin.rb', line 103 alias :origin_clone :clone |
#verboseClone(force_head, shallow_clone, time, dirSum) ⇒ Object
–verbose输出每个库的下载耗时
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/cocoapods_plugin.rb', line 139 def verboseClone(force_head, shallow_clone, time, dirSum) # 这里只能根据url获取到pod名称的开始index start = url.rindex("/") + 1 # 获取pod名称 podName = url[start, url.length] # 标红输出git clone耗时 puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone time: #{time}\e[0m" # 赋值给一个全局变量,之后输出会用到 $gitSize = dirSum # 标红输出git clone下载文件大小 puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone allsize: "+"#{dirSum}"+"M\e[0m" end |