cocoapods-time-analyze 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 90448f904d5dc96cee02eb05cf9b7c1edb0eac67
4
+ data.tar.gz: 87420f3dcebff8c293eaa0b7c81ddecf2c8d27be
5
+ SHA512:
6
+ metadata.gz: c4ebb8f479d2f71b6bb394d73c538c5c70b52bf8045f21c8efe760832094c0e116bc3ce5e85634b3aa1d1b84c119b9bee9ffa79c1606a071985e43cbba902dc1
7
+ data.tar.gz: 6c1b95350ffac524371afce41a0006c55b65799c27c47a790c539efb6f6eb7a0c9294d854a6a1986036b337ba717930f3c43a4912722bff712de3c166b937af0
data/.gem_release.yml ADDED
@@ -0,0 +1,3 @@
1
+ host: https://rubygems.org/
2
+ tag: true
3
+ push: true
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://gems.ruby-china.com/'
2
+
3
+ # Specify your gem's dependencies in cocoapods-time-analyze.gemspec
4
+ gemspec
5
+
6
+ gem 'debase'
data/Gemfile.lock ADDED
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-time-analyze (0.0.1)
5
+
6
+ GEM
7
+ remote: https://gems.ruby-china.com/
8
+ specs:
9
+ CFPropertyList (3.0.0)
10
+ activesupport (4.2.10)
11
+ i18n (~> 0.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ ast (2.4.0)
16
+ atomos (0.1.3)
17
+ byebug (10.0.2)
18
+ claide (1.0.2)
19
+ cocoapods (1.5.3)
20
+ activesupport (>= 4.0.2, < 5)
21
+ claide (>= 1.0.2, < 2.0)
22
+ cocoapods-core (= 1.5.3)
23
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
24
+ cocoapods-downloader (>= 1.2.0, < 2.0)
25
+ cocoapods-plugins (>= 1.0.0, < 2.0)
26
+ cocoapods-search (>= 1.0.0, < 2.0)
27
+ cocoapods-stats (>= 1.0.0, < 2.0)
28
+ cocoapods-trunk (>= 1.3.0, < 2.0)
29
+ cocoapods-try (>= 1.1.0, < 2.0)
30
+ colored2 (~> 3.1)
31
+ escape (~> 0.0.4)
32
+ fourflusher (~> 2.0.1)
33
+ gh_inspector (~> 1.0)
34
+ molinillo (~> 0.6.5)
35
+ nap (~> 1.0)
36
+ ruby-macho (~> 1.1)
37
+ xcodeproj (>= 1.5.7, < 2.0)
38
+ cocoapods-core (1.5.3)
39
+ activesupport (>= 4.0.2, < 6)
40
+ fuzzy_match (~> 2.0.4)
41
+ nap (~> 1.0)
42
+ cocoapods-deintegrate (1.0.2)
43
+ cocoapods-downloader (1.2.1)
44
+ cocoapods-plugins (1.0.0)
45
+ nap
46
+ cocoapods-search (1.0.0)
47
+ cocoapods-stats (1.0.0)
48
+ cocoapods-trunk (1.3.1)
49
+ nap (>= 0.8, < 2.0)
50
+ netrc (~> 0.11)
51
+ cocoapods-try (1.1.0)
52
+ coderay (1.1.2)
53
+ colored2 (3.1.2)
54
+ concurrent-ruby (1.0.5)
55
+ debase (0.2.2)
56
+ debase-ruby_core_source (>= 0.10.2)
57
+ debase-ruby_core_source (0.10.3)
58
+ diff-lcs (1.3)
59
+ escape (0.0.4)
60
+ fakefs (0.13.3)
61
+ fourflusher (2.0.1)
62
+ fuzzy_match (2.0.4)
63
+ gem-release (2.0.1)
64
+ gh_inspector (1.1.3)
65
+ i18n (0.9.5)
66
+ concurrent-ruby (~> 1.0)
67
+ jaro_winkler (1.5.1)
68
+ method_source (0.9.0)
69
+ minitest (5.11.3)
70
+ molinillo (0.6.6)
71
+ nanaimo (0.2.6)
72
+ nap (1.1.0)
73
+ netrc (0.11.0)
74
+ parallel (1.12.1)
75
+ parser (2.5.1.0)
76
+ ast (~> 2.4.0)
77
+ powerpack (0.1.2)
78
+ pry (0.11.3)
79
+ coderay (~> 1.1.0)
80
+ method_source (~> 0.9.0)
81
+ pry-byebug (3.6.0)
82
+ byebug (~> 10.0)
83
+ pry (~> 0.10)
84
+ rainbow (3.0.0)
85
+ rake (12.3.1)
86
+ rspec (3.7.0)
87
+ rspec-core (~> 3.7.0)
88
+ rspec-expectations (~> 3.7.0)
89
+ rspec-mocks (~> 3.7.0)
90
+ rspec-core (3.7.1)
91
+ rspec-support (~> 3.7.0)
92
+ rspec-expectations (3.7.0)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.7.0)
95
+ rspec-mocks (3.7.0)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.7.0)
98
+ rspec-support (3.7.1)
99
+ rubocop (0.58.2)
100
+ jaro_winkler (~> 1.5.1)
101
+ parallel (~> 1.10)
102
+ parser (>= 2.5, != 2.5.1.1)
103
+ powerpack (~> 0.1)
104
+ rainbow (>= 2.2.2, < 4.0)
105
+ ruby-progressbar (~> 1.7)
106
+ unicode-display_width (~> 1.0, >= 1.0.1)
107
+ ruby-debug-ide (0.6.1)
108
+ rake (>= 0.8.1)
109
+ ruby-macho (1.2.0)
110
+ ruby-progressbar (1.9.0)
111
+ thread_safe (0.3.6)
112
+ tzinfo (1.2.5)
113
+ thread_safe (~> 0.1)
114
+ unicode-display_width (1.4.0)
115
+ xcodeproj (1.6.0)
116
+ CFPropertyList (>= 2.3.3, < 4.0)
117
+ atomos (~> 0.1.3)
118
+ claide (>= 1.0.2, < 2.0)
119
+ colored2 (~> 3.1)
120
+ nanaimo (~> 0.2.6)
121
+
122
+ PLATFORMS
123
+ ruby
124
+
125
+ DEPENDENCIES
126
+ bundler (~> 1.3)
127
+ cocoapods (~> 1.5)
128
+ cocoapods-time-analyze!
129
+ debase
130
+ fakefs (~> 0.13)
131
+ gem-release (~> 2.0)
132
+ pry-byebug (~> 3.6)
133
+ rake (~> 12.3)
134
+ rspec (~> 3.7)
135
+ rubocop (~> 0.58)
136
+ ruby-debug-ide (~> 0.6)
137
+
138
+ BUNDLED WITH
139
+ 1.16.3
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Forelax <helloworldmkv@163.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.
data/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # cocoapods-time-analyze
2
+
3
+ cocoapods-time-analyze is used to display the time spent by every step of `pod install` and total time of xcode build.
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ $ gem install cocoapods-time-analyze
9
+ # if you use bundle
10
+ $ bundle add cocoapods-time-analyze
11
+ ```
12
+
13
+ Then add this to your podfile:
14
+
15
+ ```ruby
16
+ plugin 'cocoapods-time-analyze'
17
+ ```
18
+
19
+ Then run `pod install`.
20
+
21
+ ## Usage
22
+
23
+ ### Pod install time analyze
24
+
25
+ Create the `.cocoapods_time_analyze_config.rb` file under the Podfile directory.
26
+
27
+ Use this file to config the behaviour.
28
+
29
+ ```ruby
30
+ module TimeAnalyzeConfig
31
+ class PodInstall
32
+ # by default the plugin will generate a summary yaml file named pod-install-summary.yml under directory, you can
33
+ # use this method to override this behaviour
34
+ def self.enable_local_summary
35
+ true
36
+ end
37
+ # add the step you want to analyze to this method
38
+ def self.target_steps
39
+ %w[prepare resolve_dependencies generate_pods_project]
40
+ end
41
+ # do anything you want to do after pod install, for example, you can send the result to a server
42
+ # @param total_time [Float] pod install totoal time, in second
43
+ # @param detail [Hash] analyze result in hash format, the key is the step name, value is the duration in second.
44
+ def self.after_all(total_time, detail)
45
+ # something awesome
46
+ end
47
+ end
48
+ end
49
+ ```
50
+ ### Build time analyze
51
+
52
+ Open Xcode, add this script to the post build action of scheme you want to analyze:
53
+
54
+ ```shell
55
+ # script in xcode scheme post build action does not display
56
+ # in the xcode console, so we need to save it to a log file.
57
+ exec > $PODS_ROOT/cocoapods-time-analyze-post-build.log 2>&1
58
+ ruby $PODS_ROOT/analyze_build.rb
59
+ ```
60
+
61
+ If you want to config the behaviour, you can also open the `.cocoapods_time_analyze_config.rb` file to config it.
62
+
63
+ ```ruby
64
+ module TimeAnalyzeConfig
65
+ class Build
66
+ # by default the plugin will generate a summary yaml file named build-summary.yml under directory, you can
67
+ # use this method to override this behaviour
68
+ def self.enable_local_summary
69
+ true
70
+ end
71
+ # do anything you want to do after build, for example, you can send the result to a server
72
+ # @param total_time [Float] build totoal time, in second
73
+ # @param detail [Hash] analyze result in hash format
74
+ # @option opts [Integer] :binary_size The size of the binary in final .app product
75
+ # @option opts [Integer] :other_size The size of things except binary size in final .app product
76
+ def self.after_all(total_time, detail)
77
+ # something awesome
78
+ end
79
+ end
80
+ end
81
+ ```
82
+
data/Rakefile ADDED
@@ -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
+
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'cocoapods-time-analyze/gem_version.rb'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'cocoapods-time-analyze'
7
+ spec.version = CocoapodsTimeAnalyze::VERSION
8
+ spec.authors = ['Forelax']
9
+ spec.email = ['helloworldmkv@163.com']
10
+ spec.description = 'A cocoapods plugin to analyze time of cocoapods pod install and xcodebuild.'
11
+ spec.summary = 'A cocoapods plugin to analyze time of cocoapods pod install and xcodebuild.'
12
+ spec.homepage = 'https://github.com/Forelax/cocoapods-time-analyze'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'cocoapods', '~> 1.5'
21
+ spec.add_development_dependency 'fakefs', '~> 0.13'
22
+ spec.add_development_dependency 'pry-byebug', '~> 3.6'
23
+ spec.add_development_dependency 'rake', '~> 12.3'
24
+ spec.add_development_dependency 'rspec', '~> 3.7'
25
+ spec.add_development_dependency 'rubocop', '~> 0.58'
26
+ spec.add_development_dependency 'ruby-debug-ide', '~> 0.6'
27
+ spec.add_development_dependency 'gem-release', '~> 2.0'
28
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-time-analyze/gem_version'
@@ -0,0 +1,5 @@
1
+ if File.exist?('./.cocoapods_time_analyze_config.rb')
2
+ load File.expand_path('./.cocoapods_time_analyze_config.rb')
3
+ else
4
+ require 'cocoapods-time-analyze/template/cocoapods_time_analyze_config'
5
+ end
@@ -0,0 +1,3 @@
1
+ module PodTimeAnalyze
2
+ POD_INSTALL_SUMMARY_FILE_NAME = 'pod-install-summary.yml'.freeze
3
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsTimeAnalyze
2
+ VERSION = '0.0.2'.freeze
3
+ end
@@ -0,0 +1,58 @@
1
+ require 'cocoapods-time-analyze/config-loader/config_loader'
2
+ require 'cocoapods-time-analyze/const'
3
+ require 'yaml'
4
+
5
+ module Pod
6
+ class Installer
7
+ alias origin_install! install!
8
+
9
+ def install!
10
+ @time_log = {}
11
+
12
+ TimeAnalyzeConfig::PodInstall.target_steps.each { |step| redefine_step_method(step.to_sym) }
13
+ install_start_time = Time.now
14
+ origin_install!
15
+ total_time = Time.now - install_start_time
16
+
17
+ TimeAnalyzeConfig::PodInstall.after_all(total_time, @time_log)
18
+ write_summary_file(total_time) if TimeAnalyzeConfig::PodInstall.enable_local_summary
19
+ end
20
+
21
+ def self.alias_step_method(method_sym)
22
+ if method_defined?(method_sym) || private_method_defined?(method_sym)
23
+ alias_method "origin_#{method_sym}".to_sym, method_sym
24
+ else
25
+ raise "Pod::Installer does not have method named #{method_sym}, please check your .cocoapods_time_analyze_config.rb config file"
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def redefine_step_method(method_sym)
32
+ @time_log ||= {}
33
+
34
+ block = proc do |*arguments|
35
+ start_time = Time.now
36
+ send("origin_#{method_sym}".to_sym, *arguments)
37
+ total_time = Time.now - start_time
38
+ @time_log[method_sym] = total_time
39
+ end
40
+
41
+ self.class.alias_step_method(method_sym)
42
+ self.class.send(:define_method, method_sym, &block)
43
+ end
44
+
45
+ def write_summary_file(total_time)
46
+ file_name = PodTimeAnalyze::POD_INSTALL_SUMMARY_FILE_NAME
47
+ today = Date.today.to_s
48
+ summary_total_time = total_time.to_i
49
+ summary = File.exist?(file_name) ? YAML.safe_load(File.read(file_name)) : {}
50
+ summary['total_time'] = summary['total_time'] ? summary['total_time'] + summary_total_time : summary_total_time
51
+ summary['detail'] ||= {}
52
+ summary['detail'][today] = summary['detail'][today] ? summary['detail'][today] + summary_total_time : summary_total_time
53
+ File.open file_name, 'w+' do |file|
54
+ file.write(YAML.dump(summary))
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ Pod::HooksManager.register('cocoapods-time-analyze', :post_install) do |installer|
2
+ analyze_template_file_path = File.expand_path '../template/analyze_build.rb', __dir__
3
+ FileUtils.copy analyze_template_file_path, installer.sandbox.root.to_s
4
+ end
@@ -0,0 +1,49 @@
1
+ require 'json'
2
+ require 'yaml'
3
+ require 'pp'
4
+
5
+ workspace_dir = ENV['BUILD_DIR'].gsub('Build/Products', '')
6
+ build_log_path = File.join(workspace_dir, 'Logs/Build/LogStoreManifest.plist')
7
+ app_path = ENV['CODESIGNING_FOLDER_PATH']
8
+ executable_path = File.join(app_path, File.basename(app_path, '.app'))
9
+ pods_root = ENV['PODS_ROOT']
10
+ config_dir = File.dirname(pods_root)
11
+ config_file_path = File.join(config_dir, '.cocoapods_time_analyze_config.rb')
12
+
13
+ load config_file_path
14
+
15
+ # call Dir.mktmpdir in scheme post action script may throw can not find method exception
16
+ json_log_file = `mktemp`.strip
17
+
18
+ `plutil -convert json -o #{json_log_file} #{build_log_path}`
19
+ log_content = JSON.parse(File.read(json_log_file))
20
+ `rm -rf #{json_log_file}`
21
+
22
+ end_time_with_duration = log_content['logs'].each_with_object({}) do |log_content, hash|
23
+ start_timestamp = log_content.last['timeStartedRecording'].to_i
24
+ end_timestamp = log_content.last['timeStoppedRecording'].to_i
25
+ duration = end_timestamp - start_timestamp
26
+ hash[end_timestamp] = duration
27
+ end
28
+
29
+ last_build_duration = end_time_with_duration[end_time_with_duration.keys.sort.last]
30
+ executable_size = File.size(executable_path)
31
+ app_size = `du -sk #{app_path}`.split(' ').first.strip.to_i * 1024
32
+
33
+ otherthing_size = app_size - executable_size
34
+
35
+ TimeAnalyzeConfig::Build.after_all(last_build_duration, { binary_size: executable_size, other_size: otherthing_size })
36
+
37
+ if TimeAnalyzeConfig::Build.enable_local_summary
38
+ file_name = 'build-summary.yml'
39
+ file_path = File.join(config_dir, file_name)
40
+ today = Date.today.to_s
41
+ summary_total_time = last_build_duration.to_i
42
+ summary = File.exist?(file_path) ? YAML.safe_load(File.read(file_path)) : {}
43
+ summary['total_time'] = summary['total_time'] ? summary['total_time'] + summary_total_time : summary_total_time
44
+ summary['detail'] ||= {}
45
+ summary['detail'][today] = (summary['detail'][today] ? summary['detail'][today] + summary_total_time : summary_total_time)
46
+ File.open file_path, 'w+' do |file|
47
+ file.write(YAML.dump(summary))
48
+ end
49
+ end
@@ -0,0 +1,38 @@
1
+ module TimeAnalyzeConfig
2
+ class PodInstall
3
+ # by default the plugin will generate a summary yaml file named pod-install-summary.yml under directory, you can
4
+ # use this method to override this behaviour
5
+ def self.enable_local_summary
6
+ true
7
+ end
8
+
9
+ # add the step you want to analyze to this method
10
+ def self.target_steps
11
+ %w[]
12
+ end
13
+
14
+ # do anything you want to do after pod install, for example, you can send the result to a server
15
+ # @param total_time [Float] pod install totoal time, in second
16
+ # @param detail [Hash] analyze result in hash format, the key is the step name, value is the duration in second.
17
+ def self.after_all(total_time, detail)
18
+ # something awesome
19
+ end
20
+ end
21
+
22
+ class Build
23
+ # by default the plugin will generate a summary yaml file named build-summary.yml under directory, you can
24
+ # use this method to override this behaviour
25
+ def self.enable_local_summary
26
+ true
27
+ end
28
+
29
+ # do anything you want to do after build, for example, you can send the result to a server
30
+ # @param total_time [Float] build totoal time, in second
31
+ # @param detail [Hash] analyze result in hash format
32
+ # @option opts [Integer] :binary_size The size of the binary in final .app product
33
+ # @option opts [Integer] :other_size The size of things except binary size in final .app product
34
+ def self.after_all(total_time, detail)
35
+ # something awesome
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ require 'cocoapods-time-analyze/post-install/post_install'
2
+ require 'cocoapods-time-analyze/install-hook/install_hook'
3
+ require 'cocoapods-time-analyze/config-loader/config_loader'
@@ -0,0 +1,4 @@
1
+ ---
2
+ total_time: 0
3
+ detail:
4
+ '2018-09-18': 0
@@ -0,0 +1,55 @@
1
+ require 'fakefs/safe'
2
+
3
+ RSpec::Matchers.define :a_approximate_hash_of do |x|
4
+ match do |actual|
5
+ actual.all? { |k, v| (x[k] - v).abs < 0.05 }
6
+ end
7
+ end
8
+
9
+ describe 'InstallHook' do
10
+ let(:target_steps) { %w[prepare resolve_dependencies download_dependencies validate_targets generate_pods_project integrate_user_project perform_post_install_actions] }
11
+ let(:installer) { Pod::Installer.new(nil, nil) }
12
+ let(:installation_options) { double('installation_options') }
13
+ let(:expected_detail) { target_steps.each_with_object({}) { |step, hash| hash[step.to_sym] = 0.1 } }
14
+ let(:expected_total_time) { target_steps.count * 0.1 }
15
+ let!(:summary_file_content) { File.read(File.expand_path('fixtures/pod-install-summary.yml', __dir__)) }
16
+
17
+ before do
18
+ allow(TimeAnalyzeConfig::PodInstall).to receive(:target_steps).and_return(target_steps)
19
+ allow(TimeAnalyzeConfig::PodInstall).to receive(:after_all)
20
+ allow(installer).to receive(:installation_options).and_return(installation_options)
21
+ allow(installation_options).to receive(:integrate_targets?).and_return(true)
22
+ allow_any_instance_of(Date).to receive(:to_s).and_return('2018-09-18')
23
+
24
+ target_steps.each do |step|
25
+ allow(installer).to receive("origin_#{step}") { sleep(0.1) }
26
+ end
27
+
28
+ FakeFS.activate!
29
+
30
+ installer.install!
31
+ end
32
+
33
+ it 'call the origin step method' do
34
+ target_steps.each do |step|
35
+ expect(installer).to have_received("origin_#{step}".to_sym)
36
+ end
37
+ end
38
+
39
+ it 'call the after_all hook in config file' do
40
+ expect(TimeAnalyzeConfig::PodInstall).to have_received(:after_all).with(
41
+ be_within(0.05).of(expected_total_time),
42
+ a_approximate_hash_of(expected_detail)
43
+ )
44
+ end
45
+
46
+ context 'when enable_local_summary is true' do
47
+ it 'save summary file to root dir' do
48
+ expect(File.read(File.join('/', PodTimeAnalyze::POD_INSTALL_SUMMARY_FILE_NAME))).to eql(summary_file_content)
49
+ end
50
+ end
51
+
52
+ after do
53
+ FakeFS.deactivate!
54
+ end
55
+ end
@@ -0,0 +1,46 @@
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 'pathname'
8
+ require 'cocoapods'
9
+ require 'cocoapods_plugin'
10
+ require 'byebug'
11
+ require 'pp'
12
+
13
+ #-----------------------------------------------------------------------------#
14
+
15
+ module Pod
16
+
17
+ # Disable the wrapping so the output is deterministic in the tests.
18
+ #
19
+ UI.disable_wrap = true
20
+
21
+ # Redirects the messages to an internal store.
22
+ #
23
+ module UI
24
+ @output = ''
25
+ @warnings = ''
26
+
27
+ class << self
28
+ attr_accessor :output
29
+ attr_accessor :warnings
30
+
31
+ def puts(message = '')
32
+ @output << "#{message}\n"
33
+ end
34
+
35
+ def warn(message = '', actions = [])
36
+ @warnings << "#{message}\n"
37
+ end
38
+
39
+ def print(message)
40
+ @output << message
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-time-analyze
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Forelax
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-20 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: cocoapods
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fakefs
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '12.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '12.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.58'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.58'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ruby-debug-ide
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.6'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.6'
125
+ - !ruby/object:Gem::Dependency
126
+ name: gem-release
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.0'
139
+ description: A cocoapods plugin to analyze time of cocoapods pod install and xcodebuild.
140
+ email:
141
+ - helloworldmkv@163.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gem_release.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".ruby-version"
150
+ - Gemfile
151
+ - Gemfile.lock
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - bin/rspec
156
+ - cocoapods-time-analyze.gemspec
157
+ - lib/cocoapods-time-analyze.rb
158
+ - lib/cocoapods-time-analyze/config-loader/config_loader.rb
159
+ - lib/cocoapods-time-analyze/const.rb
160
+ - lib/cocoapods-time-analyze/gem_version.rb
161
+ - lib/cocoapods-time-analyze/install-hook/install_hook.rb
162
+ - lib/cocoapods-time-analyze/post-install/post_install.rb
163
+ - lib/cocoapods-time-analyze/template/analyze_build.rb
164
+ - lib/cocoapods-time-analyze/template/cocoapods_time_analyze_config.rb
165
+ - lib/cocoapods_plugin.rb
166
+ - spec/fixtures/pod-install-summary.yml
167
+ - spec/install_hook_spec.rb
168
+ - spec/spec_helper.rb
169
+ homepage: https://github.com/Forelax/cocoapods-time-analyze
170
+ licenses:
171
+ - MIT
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 2.4.8
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: A cocoapods plugin to analyze time of cocoapods pod install and xcodebuild.
193
+ test_files:
194
+ - spec/fixtures/pod-install-summary.yml
195
+ - spec/install_hook_spec.rb
196
+ - spec/spec_helper.rb