Class: Pod::Downloader::Cache
- Inherits:
-
Object
- Object
- Pod::Downloader::Cache
- Defined in:
- lib/cocoapods_plugin.rb
Instance Method Summary collapse
- #copy_and_clean(source, destination, spec) ⇒ Object
-
#origin_copy_and_clean ⇒ Object
使用方法别名hook copy_and_clean方法.
-
#verboseCopy_and_clean(source, destination, spec) ⇒ Object
–verbose输出详细信息,生成在home路径下.AllPodsTimeAndSize.csv的隐藏文件.
Instance Method Details
#copy_and_clean(source, destination, spec) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/cocoapods_plugin.rb', line 67 def copy_and_clean(source, destination, spec) # 执行之前的拷贝到cache并且清除git clone临时目录的方法 origin_copy_and_clean(source, destination, spec) # 如果是--verbose,则输出详细信息,生成csv if $pluginIsVerbose == true verboseCopy_and_clean(source, destination, spec) end end |
#origin_copy_and_clean ⇒ Object
使用方法别名hook copy_and_clean方法
66 |
# File 'lib/cocoapods_plugin.rb', line 66 alias :origin_copy_and_clean :copy_and_clean |
#verboseCopy_and_clean(source, destination, spec) ⇒ Object
–verbose输出详细信息,生成在home路径下.AllPodsTimeAndSize.csv的隐藏文件
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cocoapods_plugin.rb', line 77 def verboseCopy_and_clean(source, destination, spec) begin # 计算拷贝到的目录下所有文件总大小,单位为M dirSum = Dir.size(destination.to_s)/1000.0/1000.0 # 标红输出cache文件大小,单位为M puts "\e[31mCocoapodsTSPodfileTimeWatch cachesize #{spec.name}: "+"#{dirSum}"+"M\e[0m" # 计算git clone大小和cache文件大小的差值,如果差值过大,则有优化空间 diffSize = $gitSize - dirSum # 标红输出差值 puts "\e[31mCocoapodsTSPodfileTimeWatch diffSize = #{diffSize}\e[0m" # 统计到csv中 CSV.open("#{Dir.home}/.AllPodsTimeAndSize.csv", "a+") do |csv| csv << [spec.name, $cloneTime, $gitSize, dirSum, diffSize] end # 换行 puts rescue => exception # 输出拷贝清除方法异常 puts "\e[31mCocoapodsTSPodfileTimeWatch verboseCopy_and_clean error(已捕获): #{exception}\e[0m" end $gitSize = 0 end |