class CocoapodsTSPodfileTimeWatch::CocoapodsTSPodfileTimeWatch::Pod::Downloader::Cache
Public Instance Methods
download(request, target)
click to toggle source
# File lib/cocoapods_plugin.rb, line 130 def download(request, target) # 获取downloader下载的文件路径 source = target.to_s # 赋值当前正在下载的文件路径给全局变量,为了解压zip的时候做判断 $pluginCurrentTarget = source # 赋值当前正在下载的pod名称给全局变量,为了解压zip的时候做输出 $pluginCurrentPodName = request.name.to_s # 获取clone执行前时间点 time1 = Time.new # 执行之前的download_source方法,接收该方法的返回值 result, podspecs = origin_download(request, target) # 如果不是--verbose,只输出总耗时,总下载大小 # 捕获一下异常,不会因为plugin的原因导致pod失败 begin # 获取clone执行后时间点 time2 = Time.new # 获取时间差 time = time2 - time1 if request.params["git".to_sym] # 说明是git方式 # 赋值一个给全局变量,之后时间统计要用到 $cloneTime = time # 赋值一个给全局变量,之后时间统计要用到 $cloneAllTime = $cloneAllTime + time # 计算downloader下载的文件大小,单位为M dirSum = Dir.size(source)/1000.0/1000.0 # 赋值给一个全局变量,之后输出会用到 $gitAllSize = $gitAllSize + dirSum else # 说明是CDN方式 # 赋值一个给全局变量,之后时间统计要用到 $downloadTime = time # 赋值一个给全局变量,之后时间统计要用到 $downloadAllTime = $downloadAllTime + time # 赋值给一个全局变量,之后输出会用到 $cdnDownloadAllTime = $cdnDownloadAllTime + $cdnDownloadTime # 赋值给一个全局变量,之后输出会用到 $cdnUnZipAllTime = $cdnUnZipAllTime + $cdnUnZipTime # 赋值给一个全局变量,之后输出会用到 $pluginCurrentZipAllSize = $pluginCurrentZipAllSize + $pluginCurrentZipSize end # 如果是--verbose,则输出详细信息,生成csv if $pluginIsVerbose == true verboseDownload(request, time, dirSum) end # 返回值 [result, podspecs] rescue => exception # 标红输出git clone hook异常 puts "\e[31mCocoapodsTSPodfileTimeWatch download error(已捕获): #{exception}\e[0m" end end
Also aliased as: origin_download
verboseDownload(request, time, dirSum)
click to toggle source
# File lib/cocoapods_plugin.rb, line 185 def verboseDownload(request, time, dirSum) if request.params["git".to_sym] # 说明是git方式 # 标红输出git clone耗时 puts "\e[31mCocoapodsTSPodfileTimeWatch #{request.name.to_s} clone time: #{time}"+" S\e[0m" # 赋值给一个全局变量,之后输出会用到 $gitSize = dirSum # 标红输出git clone下载文件大小 puts "\e[31mCocoapodsTSPodfileTimeWatch #{request.name.to_s} clone allsize: "+"#{dirSum}"+" M\e[0m" else # 说明是CDN方式 # 标红输出CDN 下载耗时 puts "\e[31mCocoapodsTSPodfileTimeWatch #{request.name.to_s} CDN download time: #{$cdnDownloadTime}"+" S\e[0m" # 标红输出CDN 解压耗时 puts "\e[31mCocoapodsTSPodfileTimeWatch #{request.name.to_s} CDN unzip time: #{$cdnUnZipTime}"+" S\e[0m" # 标红输出CDN 总耗时 puts "\e[31mCocoapodsTSPodfileTimeWatch #{request.name.to_s} CDN All time: #{$downloadTime}"+" S\e[0m" # 标红输出CDN clone下载文件大小 puts "\e[31mCocoapodsTSPodfileTimeWatch #{request.name.to_s} CDN zipSize: "+"#{$pluginCurrentZipSize}"+" M\e[0m" end end