cocoapods-flash 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 43cb853df2bf214cba4b3a5dbcc8f709721647e496ec5c1b3a060a11378a0783
4
+ data.tar.gz: 83cf0b11de317bcf2e2bd81c7efbd6709b1fce6067b84373b833a13fa802d3b7
5
+ SHA512:
6
+ metadata.gz: bd97ca264bcc98ce2adb7c8cdb36680748f4d8ce37c729ea085ff69b2228f344879f90e16d2542cfefd28aff5e8e9c54f82a692b419b61f63de942a608681379
7
+ data.tar.gz: 5ae3bdd641abd1daa70033c880caa095942dfd6ad822d466979b0864376e1b792a429dd431d891c570171f3416cd0ef54bcf5046048bcffef144b2d7415a6c18
@@ -0,0 +1,21 @@
1
+ module Pod
2
+ module Flash
3
+ class Config
4
+ attr_accessor :dsl_config
5
+
6
+ def initialize
7
+ @dsl_config = {}
8
+ end
9
+
10
+ def self.instance
11
+ @instance ||= Config.new
12
+ end
13
+ end
14
+ end
15
+
16
+ class Podfile
17
+ def config_cocoapods_flash(options)
18
+ Flash::Config.instance.dsl_config = options
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,57 @@
1
+ require "fileutils"
2
+ require "json"
3
+
4
+ module Pod
5
+ module Flash
6
+ class InstrumentationResult
7
+ ATTRS = {
8
+ :summary => {},
9
+ :breakdown => [],
10
+ :source_installers => {},
11
+ }.freeze
12
+
13
+ attr_accessor(*ATTRS.keys)
14
+
15
+ def initialize
16
+ ATTRS.each { |k, v| send("#{k}=", v) }
17
+ end
18
+
19
+ def self.instance
20
+ @instance ||= InstrumentationResult.new
21
+ end
22
+
23
+ def total
24
+ @summary["total"]
25
+ end
26
+
27
+ def path
28
+ @path ||= begin
29
+ dir = ".stats/cocoapods_flash"
30
+ FileUtils.mkdir_p(dir)
31
+ Pathname("#{dir}/instrumentation.json")
32
+ end
33
+ end
34
+
35
+ def save!
36
+ data = ATTRS.to_h { |k| [k, send(k)] }
37
+ File.write(path, JSON.pretty_generate(data))
38
+ end
39
+
40
+ def print_overview
41
+ breakdown_desc = breakdown.map { |h| "• #{h[:step]}: #{h[:duration].ceil.to_s.cyan} s" }.join("\n")
42
+ msg = <<~HEREDOC
43
+
44
+ ------------------------ [cocoapods-flash] -------------------------
45
+ Total time: #{total.ceil.to_s.cyan} s
46
+
47
+ Breakdown
48
+ #{breakdown_desc}
49
+
50
+ Check out the details at #{path.realpath}
51
+ --------------------------------------------------------------------
52
+ HEREDOC
53
+ Pod::UI.puts(msg)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,9 @@
1
+ module Pod
2
+ module Flash
3
+ module Logger
4
+ def self.log(msg)
5
+ Pod::UI.puts "[cocoapods-flash] #{msg}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module Pod
2
+ module Flash
3
+ module PatchingMixin
4
+ def patch_method(method_name, &block)
5
+ raw_method_name = "flash_#{method_name}"
6
+ alias_method raw_method_name, method_name
7
+ define_method(method_name, &block)
8
+ private raw_method_name
9
+ end
10
+
11
+ def self.included(base)
12
+ base.extend(self)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "log"
2
+ require_relative "instrumentation_result"
3
+
4
+ module Pod
5
+ module Flash
6
+ class Stopwatch
7
+ def self.measure(name, options = {})
8
+ tick = Time.new
9
+ yield if block_given?
10
+ tock = Time.new
11
+ duration = tock - tick
12
+ if options.fetch(:track, true)
13
+ InstrumentationResult.instance.breakdown << { :step => name, :duration => duration }
14
+ end
15
+ duration
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ require_relative "log"
2
+ require_relative "patch"
3
+ require_relative "stopwatch"
4
+
5
+ module Pod
6
+ module Flash
7
+ module TimingMixin
8
+ include Flash::PatchingMixin
9
+
10
+ def timing(name, options = {})
11
+ patch_method(name) do
12
+ duration = Flash::Stopwatch.measure("#{self.class}.#{name}", options) do
13
+ method("flash_#{name}").call
14
+ end
15
+ yield self, duration if block_given?
16
+ end
17
+ end
18
+
19
+ def self.included(base)
20
+ base.extend(self)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1 @@
1
+ require "cocoapods-flash/patch"
@@ -0,0 +1,3 @@
1
+ require "cocoapods-flash/core/log"
2
+ require "cocoapods-flash/core/timing"
3
+ require "cocoapods-flash/core/instrumentation_result"
@@ -0,0 +1,17 @@
1
+ require_relative "base"
2
+
3
+ module Pod
4
+ class Installer
5
+ include Flash::TimingMixin
6
+
7
+ timing(:install!) do |_, duration|
8
+ Flash::InstrumentationResult.instance.summary["total"] = duration
9
+ Flash::InstrumentationResult.instance.save!
10
+ Flash::InstrumentationResult.instance.print_overview
11
+ end
12
+ timing(:prepare)
13
+ timing(:resolve_dependencies)
14
+ timing(:download_dependencies)
15
+ timing(:integrate)
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "base"
2
+
3
+ module Pod
4
+ class Installer
5
+ class PodSourceInstaller
6
+ include Flash::TimingMixin
7
+
8
+ timing(:install!, track: false) do |installer, duration|
9
+ Flash::InstrumentationResult.instance.source_installers[installer.name] = duration
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ require "cocoapods-flash/patch/installer"
2
+ require "cocoapods-flash/patch/source_installer"
@@ -0,0 +1 @@
1
+ require "cocoapods-flash/gem_version"
@@ -0,0 +1,5 @@
1
+ require "cocoapods-flash/main"
2
+
3
+ Pod::HooksManager.register("cocoapods-flash", :post_install) do |context|
4
+ # Code goes here
5
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-flash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thuyen Trinh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.23.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.23.0
27
+ description: A CocoaPods plugin that helps pod installation run faster
28
+ email:
29
+ - trinhngocthuyen@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/cocoapods-flash.rb
35
+ - lib/cocoapods-flash/core/config.rb
36
+ - lib/cocoapods-flash/core/instrumentation_result.rb
37
+ - lib/cocoapods-flash/core/log.rb
38
+ - lib/cocoapods-flash/core/patch.rb
39
+ - lib/cocoapods-flash/core/stopwatch.rb
40
+ - lib/cocoapods-flash/core/timing.rb
41
+ - lib/cocoapods-flash/main.rb
42
+ - lib/cocoapods-flash/patch.rb
43
+ - lib/cocoapods-flash/patch/base.rb
44
+ - lib/cocoapods-flash/patch/installer.rb
45
+ - lib/cocoapods-flash/patch/source_installer.rb
46
+ - lib/cocoapods_plugin.rb
47
+ homepage: https://github.com/trinhngocthuyen/cocoapods-flash
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.2.3
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: A CocoaPods plugin that helps pod installation run faster
70
+ test_files: []