cocoapods-TSPodfileTimeWatch 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 406c2ee036c2e6c3afc25293302c75e0a9ecf85c591bab3b08dc2b7df35341b0
4
+ data.tar.gz: 258c31372b7173030a8c5a8e66f6212626b98d11a6c17d46c0a70a8e61bc35a9
5
+ SHA512:
6
+ metadata.gz: 8f349ed92837cc7cc71041f5227528a7524ed6d2e382668073ea9b6c83bd7ad922ab854791837ea3e55cfa558caf0872e6f1d5b9ed7e97f9299c718efb7f218f
7
+ data.tar.gz: 27a1f704f86bd855d89626af952f4724cd552321e2f0cad7516477dd12c5c91d5704be5fbbf818a9b065808820ab1d2f6900aa929dfc2283dfd18f69edc2045d
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-TSPodfileTimeWatch.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020 xueruicao <xueruicao@tencent.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # cocoapods-TSPodfileTimeWatch
2
+
3
+ A description of cocoapods-TSPodfileTimeWatch.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-TSPodfileTimeWatch
8
+
9
+ ## Usage
10
+
11
+ $ pod spec TSPodfileTimeWatch POD_NAME
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-TSPodfileTimeWatch/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-TSPodfileTimeWatch'
8
+ spec.version = CocoapodsTspodfiletimewatch::VERSION
9
+ spec.authors = ['keai']
10
+ spec.email = ['604922471@qq.com']
11
+ spec.description = %q{cocoapods-TSPodfileTimeWatch}
12
+ spec.summary = <<-DESC
13
+ cocoapods-TSPodfileTimeWatch
14
+ DESC
15
+ spec.homepage = 'https://github.com/cxr0715/cocoapods-TSPodfileTimeWatch'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-TSPodfileTimeWatch/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-TSPodfileTimeWatch/command/TSPodfileTimeWatch'
@@ -0,0 +1,44 @@
1
+ module Pod
2
+ class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
19
+ #
20
+ class Tspodfiletimewatch < Command
21
+ self.summary = 'Short description of cocoapods-TSPodfileTimeWatch.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-TSPodfileTimeWatch.
25
+ DESC
26
+
27
+ self.arguments = 'NAME'
28
+
29
+ def initialize(argv)
30
+ @name = argv.shift_argument
31
+ super
32
+ end
33
+
34
+ def validate!
35
+ super
36
+ help! 'A Pod name is required.' unless @name
37
+ end
38
+
39
+ def run
40
+ UI.puts "Add your implementation for the cocoapods-TSPodfileTimeWatch plugin in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsTspodfiletimewatch
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,104 @@
1
+ require 'cocoapods-TSPodfileTimeWatch/command'
2
+ require 'csv'
3
+ class Dir
4
+ def self.size(dir)
5
+ sum = 0
6
+ Dir.foreach(dir) do |entry|
7
+ begin
8
+ next if entry =~ /^\./ && entry != '.git'
9
+ next if entry == "lfs" # 不统计在lfs文件夹下的资源,git clone下载的是lfs内的资源,之后copy到真正目录下,导致大小统计了两次,所以这里不统计lfs目录下的资源
10
+ path = File.join(dir, entry)
11
+ FileTest.directory?(path) ? sum += Dir.size(path) : sum += File.size(path)
12
+ rescue => exception
13
+ puts "\e[31mCocoapodsTSPodfileTimeWatch Dir.size error: #{exception}\e[0m"
14
+ next
15
+ retry
16
+ end
17
+ end
18
+ sum
19
+ end
20
+ end
21
+ $currentPodName = ""
22
+ $gitSize = 0
23
+ $cloneTime = 0
24
+ module CocoapodsTSPodfileTimeWatch
25
+ class Pod::Downloader::Cache
26
+ # 使用方法别名hook copy_and_clean方法
27
+ alias :origin_copy_and_clean :copy_and_clean
28
+ def copy_and_clean(source, destination, spec)
29
+ # 执行之前的拷贝到cache并且清除git clone临时目录的方法
30
+ origin_copy_and_clean(source, destination, spec)
31
+ # 如果拷贝清除方法的pod名称与之前git clone记录下来的名称相同,则执行统计
32
+ if $currentPodName.include? spec.name
33
+ begin
34
+ # 计算拷贝到的目录下所有文件总大小,单位为M
35
+ dirSum = Dir.size(destination.to_s)/1000.0/1000.0
36
+ # 标红输出cache文件大小,单位为M
37
+ puts "\e[31mCocoapodsTSPodfileTimeWatch cachesize #{spec.name}: "+"#{dirSum}"+"M\e[0m"
38
+ # 计算git clone大小和cache文件大小的差值,如果差值过大,则有优化空间
39
+ diffSize = $gitSize - dirSum
40
+ # 标红输出差值
41
+ puts "\e[31mCocoapodsTSPodfileTimeWatch diffSize = #{diffSize}\e[0m"
42
+ # 统计到csv中
43
+ CSV.open("/Users/caoxuerui/Desktop/AllPodsTimeAndSize2020_10_22.csv", "ab") do |csv|
44
+ csv << [spec.name, $cloneTime, $gitSize, dirSum, diffSize]
45
+ end
46
+ # 换行
47
+ puts
48
+ rescue => exception
49
+ # 输出拷贝清除方法异常
50
+ puts "\e[31mCocoapodsTSPodfileTimeWatch copy_and_clean error: #{exception}\e[0m"
51
+ end
52
+ end
53
+ $currentPodName = ""
54
+ $gitSize = 0
55
+ end
56
+ end
57
+
58
+ class Pod::Downloader::Git
59
+ # 使用方法别名hook clone方法
60
+ alias :origin_clone :clone
61
+ def clone(force_head = false, shallow_clone = true)
62
+ # 获取clone执行前时间点
63
+ time1 = Time.new
64
+
65
+ # 执行之前的clone方法
66
+ origin_clone(force_head, shallow_clone)
67
+
68
+ # 捕获一下异常,不会因为plugin的原因导致pod失败
69
+ begin
70
+ # 获取clone执行后时间点
71
+ time2 = Time.now
72
+
73
+ # 获取时间差
74
+ time = time2 - time1
75
+
76
+ # 赋值一个给全局变量,之后时间统计要用到
77
+ $cloneTime = time
78
+
79
+ # 这里只能根据url获取到pod名称的开始index
80
+ start = url.rindex("/") + 1
81
+ # 获取pod名称
82
+ podName = url[start, url.length]
83
+ # 赋值给一个全局变量,之后输出会用到
84
+ $currentPodName = podName
85
+ # 标红输出git clone耗时
86
+ puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone time: #{time}\e[0m"
87
+
88
+ # 获取git clone下载的文件路径
89
+ source = target_path.to_s
90
+ # 计算git clone下载的文件大小,单位为M
91
+ dirSum = Dir.size(source)/1000.0/1000.0
92
+ # 赋值给一个全局变量,之后输出会用到
93
+ $gitSize = dirSum
94
+
95
+ # 标红输出git clone下载文件大小
96
+ puts "\e[31mCocoapodsTSPodfileTimeWatch #{podName} clone allsize: "+"#{dirSum}"+"M\e[0m"
97
+ rescue => exception
98
+ # 标红输出git clone hook异常
99
+ puts "\e[31mCocoapodsTSPodfileTimeWatch clone error: #{exception}\e[0m"
100
+ end
101
+
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Tspodfiletimewatch do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ TSPodfileTimeWatch }).should.be.instance_of Command::Tspodfiletimewatch
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-TSPodfileTimeWatch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - keai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: cocoapods-TSPodfileTimeWatch
42
+ email:
43
+ - 604922471@qq.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - cocoapods-TSPodfileTimeWatch.gemspec
54
+ - lib/cocoapods-TSPodfileTimeWatch.rb
55
+ - lib/cocoapods-TSPodfileTimeWatch/command.rb
56
+ - lib/cocoapods-TSPodfileTimeWatch/command/TSPodfileTimeWatch.rb
57
+ - lib/cocoapods-TSPodfileTimeWatch/gem_version.rb
58
+ - lib/cocoapods_plugin.rb
59
+ - spec/command/TSPodfileTimeWatch_spec.rb
60
+ - spec/spec_helper.rb
61
+ homepage: https://github.com/cxr0715/cocoapods-TSPodfileTimeWatch
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: cocoapods-TSPodfileTimeWatch
84
+ test_files:
85
+ - spec/command/TSPodfileTimeWatch_spec.rb
86
+ - spec/spec_helper.rb