Class: Stool::Command::Util::LibsCheck
- Inherits:
-
Stool::Command::Util
- Object
- CLAide::Command
- Stool::Command
- Stool::Command::Util
- Stool::Command::Util::LibsCheck
- Defined in:
- lib/stool/Command/Util/LibsCheck.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ LibsCheck
constructor
self.arguments = [ CLAide::Argument.new(‘close’, false), ].
- #run ⇒ Object
-
#summary_repo(repo) ⇒ Object
统计某一个pod库.
- #v_to_i(x) ⇒ Object
Methods inherited from Stool::Command
#checkConfigFile, options, #pp
Constructor Details
#initialize(argv) ⇒ LibsCheck
self.arguments = [
CLAide::Argument.new('close', false),
]
16 17 18 19 20 21 22 23 |
# File 'lib/stool/Command/Util/LibsCheck.rb', line 16 def initialize(argv) if @@config.checkRepos.count > 0 Spreadsheet.client_encoding="utf-8" #创建表格对象 @book = Spreadsheet::Workbook.new end super end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/stool/Command/Util/LibsCheck.rb', line 25 def run @@config.checkRepos.map { |e| summary_repo e } #在指定路径下面创建test1.xls表格,并写book对象 path = File.join(Config.logsDirPath,'pod_summary.xls') Dir.chdir(Config.logsDirPath) @book.write path puts "已经生成Excel文件<#{path}>" `open #{path}` end |
#summary_repo(repo) ⇒ Object
统计某一个pod库
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/stool/Command/Util/LibsCheck.rb', line 40 def summary_repo(repo) repoPath = File.join(Dir.home,'.cocoapods/repos',repo) unless Dir.exist?(repoPath) puts "#{repoPath} does not exist!!".red puts "Now,we have found some repos,which did you mean: ".red puts `pod repo`.white raise end puts "更新当前repo - #{repo}".white puts `pod repo update #{repo}` puts "生成表格中...".white #创建工作表 sheet1 = @book.create_worksheet :name => "pod_summary_" + repo #在表格第一行设置分类 sheet1.row(0)[0]="名字" sheet1.row(0)[1]="简介" sheet1.row(0)[2]="所属业务模块" sheet1.row(0)[3]="主页" sheet1.row(0)[4]="统计时版本" Dir.chdir(repoPath) libs = [] Dir.entries(repoPath).sort.uniq.each do |dir| unless dir['.'] #取出最大版本 arr = Dir.entries(File.join(repoPath,dir)).sort_by do |x| v_to_i x end if arr.last fname = Dir.entries(File.join(repoPath,dir,arr.last)).last libinfo = LibInfo.loadFromPath(File.join(repoPath,dir,arr.last)) if libinfo libs.push(libinfo) end end end end puts Dir.entries(repoPath).count mod = '' libs.each_with_index {|lib,idx| mod = '其他工具' @@config.checkReposSheets.each do|dic| dic.values[0].each do |pod| if lib.name.downcase.eql?(pod.downcase) mod = dic.keys[0] break end end end sheet1.row(idx+1)[0]= lib.name sheet1.row(idx+1)[1]= lib.summary sheet1.row(idx+1)[2]= mod sheet1.row(idx+1)[3]= lib.homepage sheet1.row(idx+1)[4]= lib.version } end |
#v_to_i(x) ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/stool/Command/Util/LibsCheck.rb', line 104 def v_to_i (x) maxX = 10 a = 0 arr = x.split('.').reverse arr.map.with_index {|x, idx| a = a + x.to_i * 10**(idx * maxX) } a end |