class CocoapodsTSPodfileTimeWatch::CocoapodsTSPodfileTimeWatch::Pod::Downloader::Http

Public Instance Methods

download_file(_full_filename) click to toggle source
# File lib/cocoapods_plugin.rb, line 215
def download_file(_full_filename)
  # 捕获一下异常,不会因为plugin的原因导致pod失败
  begin
    if _full_filename.to_s.include?($pluginCurrentTarget)
      # 说明是之前被赋值的开始下载了

      # 获取CDN下载执行前时间点
      time1 = Time.new
      # 执行原来的CDN下载方法
      origin_download_file(_full_filename)
      # 获取CDN下载执行后时间点
      time2 = Time.new
      # 赋值CDN下载耗时给全局变量,用于之后输出以及写在csv中
      $cdnDownloadTime = time2 - time1
    else
      # 说明不是之前被赋值的开始下载了,输出一下,然后清空
      puts "\e[31mCocoapodsTSPodfileTimeWatch unzip warning: #{$pluginCurrentTarget} target error\e[0m"
      puts "\e[31mCocoapodsTSPodfileTimeWatch unzip warning: #{$pluginCurrentPodName} name error\e[0m"
      $pluginCurrentTarget = ""
      $pluginCurrentPodName = ""
    end
  rescue => exception
    # 输出CDM下载方法异常
    puts "\e[31mCocoapodsTSPodfileTimeWatch download_file error(已捕获): #{exception}\e[0m"
  end
  
end
Also aliased as: origin_download_file
extract_with_type(full_filename, type = :zip) click to toggle source
# File lib/cocoapods_plugin.rb, line 243
def extract_with_type(full_filename, type = :zip)
  # 捕获一下异常,不会因为plugin的原因导致pod失败
  begin
    if full_filename.to_s.include?($pluginCurrentTarget)
      # 说明是之前被赋值的下载完成了,开始进行解压了

      # 计算拷贝到的目录下所有文件总大小,单位为M
      dirSum = File.size(full_filename.to_s)/1000.0/1000.0
      # 赋值给当前正在解压的zip大小,之后输出到csv要用
      $pluginCurrentZipSize = dirSum
    else
      # 说明不是之前被赋值的下载完成了,输出一下,然后清空
      puts "\e[31mCocoapodsTSPodfileTimeWatch unzip warning: #{$pluginCurrentTarget} target error\e[0m"
      puts "\e[31mCocoapodsTSPodfileTimeWatch unzip warning: #{$pluginCurrentPodName} name error\e[0m"
      $pluginCurrentTarget = ""
      $pluginCurrentPodName = ""
    end
  rescue => exception
    # 输出CDN解压方法异常
    puts "\e[31mCocoapodsTSPodfileTimeWatch extract_with_type error(已捕获): #{exception}\e[0m"
  end
  # 获取CDN解压前时间点
  time1 = Time.new
  # 执行之前的解压方法
  origin_extract_with_type(full_filename, type)
  # 获取CDN解压后时间点
  time2 = Time.new
  # 赋值CDN解压耗时给全局变量,用于之后输出以及写在csv中
  $cdnUnZipTime = time2 - time1
end
Also aliased as: origin_extract_with_type
origin_download_file(_full_filename)

使用方法别名hook解压方法,获取解压之前的文件大小

Alias for: download_file
origin_extract_with_type(full_filename, type = :zip)
Alias for: extract_with_type