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
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/cocoapods_plugin.rb', line 80 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方法
79 |
# File 'lib/cocoapods_plugin.rb', line 79 alias :origin_clone :clone |
#verboseClone(force_head, shallow_clone, time, dirSum) ⇒ Object
–verbose输出每个库的下载耗时
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cocoapods_plugin.rb', line 115 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 |