cocoapods-dependency 0.1.0

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: 3137ba3775705b9ef046dbe2660825ba27b8b194
4
+ data.tar.gz: 1c09338b49757a6f47de41042504f8229e844dec
5
+ SHA512:
6
+ metadata.gz: 66ce4904c06df521456c93553a41f6bf21523ba10765b1dca13037104c907701f7105257066d1eb2a40ee00408707841a7e9be3af26ca02c8db936eb55290be5
7
+ data.tar.gz: c5531128b6d8c1e256d12c3d290487f6e9ecb6b823c2cc74dd7c6c50d05fc99dffe95f49a1f488b8979d3729f9fb9c22a4d7ff835f48099d599e42e98fba0fad
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .DS_Store
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Metrics/MethodLength:
2
+ Max: 20
3
+
4
+ Style/TrailingCommaInHashLiteral:
5
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,4 @@
1
+ SimpleCov.start do
2
+ track_files 'lib/**/*.rb'
3
+ add_filter '/spec/'
4
+ end
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ os: osx
4
+ rvm:
5
+ - 2.4.1
6
+ before_install:
7
+ - gem install bundler -v 1.16.1
8
+ - bundle
9
+ - bundle exec pod repo update
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in cocoapods-dependency.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-dependency (0.1.0)
5
+ cocoapods (~> 1.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ CFPropertyList (3.0.0)
11
+ activesupport (4.2.10)
12
+ i18n (~> 0.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ atomos (0.1.3)
17
+ claide (1.0.2)
18
+ cocoapods (1.5.3)
19
+ activesupport (>= 4.0.2, < 5)
20
+ claide (>= 1.0.2, < 2.0)
21
+ cocoapods-core (= 1.5.3)
22
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
23
+ cocoapods-downloader (>= 1.2.0, < 2.0)
24
+ cocoapods-plugins (>= 1.0.0, < 2.0)
25
+ cocoapods-search (>= 1.0.0, < 2.0)
26
+ cocoapods-stats (>= 1.0.0, < 2.0)
27
+ cocoapods-trunk (>= 1.3.0, < 2.0)
28
+ cocoapods-try (>= 1.1.0, < 2.0)
29
+ colored2 (~> 3.1)
30
+ escape (~> 0.0.4)
31
+ fourflusher (~> 2.0.1)
32
+ gh_inspector (~> 1.0)
33
+ molinillo (~> 0.6.5)
34
+ nap (~> 1.0)
35
+ ruby-macho (~> 1.1)
36
+ xcodeproj (>= 1.5.7, < 2.0)
37
+ cocoapods-core (1.5.3)
38
+ activesupport (>= 4.0.2, < 6)
39
+ fuzzy_match (~> 2.0.4)
40
+ nap (~> 1.0)
41
+ cocoapods-deintegrate (1.0.2)
42
+ cocoapods-downloader (1.2.1)
43
+ cocoapods-plugins (1.0.0)
44
+ nap
45
+ cocoapods-search (1.0.0)
46
+ cocoapods-stats (1.0.0)
47
+ cocoapods-trunk (1.3.1)
48
+ nap (>= 0.8, < 2.0)
49
+ netrc (~> 0.11)
50
+ cocoapods-try (1.1.0)
51
+ colored2 (3.1.2)
52
+ concurrent-ruby (1.0.5)
53
+ coveralls (0.8.22)
54
+ json (>= 1.8, < 3)
55
+ simplecov (~> 0.16.1)
56
+ term-ansicolor (~> 1.3)
57
+ thor (~> 0.19.4)
58
+ tins (~> 1.6)
59
+ diff-lcs (1.3)
60
+ docile (1.3.1)
61
+ escape (0.0.4)
62
+ fourflusher (2.0.1)
63
+ fuzzy_match (2.0.4)
64
+ gh_inspector (1.1.3)
65
+ i18n (0.9.5)
66
+ concurrent-ruby (~> 1.0)
67
+ json (2.1.0)
68
+ minitest (5.11.3)
69
+ molinillo (0.6.6)
70
+ nanaimo (0.2.6)
71
+ nap (1.1.0)
72
+ netrc (0.11.0)
73
+ rake (10.5.0)
74
+ rspec (3.7.0)
75
+ rspec-core (~> 3.7.0)
76
+ rspec-expectations (~> 3.7.0)
77
+ rspec-mocks (~> 3.7.0)
78
+ rspec-core (3.7.1)
79
+ rspec-support (~> 3.7.0)
80
+ rspec-expectations (3.7.0)
81
+ diff-lcs (>= 1.2.0, < 2.0)
82
+ rspec-support (~> 3.7.0)
83
+ rspec-mocks (3.7.0)
84
+ diff-lcs (>= 1.2.0, < 2.0)
85
+ rspec-support (~> 3.7.0)
86
+ rspec-support (3.7.1)
87
+ ruby-macho (1.2.0)
88
+ simplecov (0.16.1)
89
+ docile (~> 1.1)
90
+ json (>= 1.8, < 3)
91
+ simplecov-html (~> 0.10.0)
92
+ simplecov-html (0.10.2)
93
+ term-ansicolor (1.6.0)
94
+ tins (~> 1.0)
95
+ thor (0.19.4)
96
+ thread_safe (0.3.6)
97
+ tins (1.16.3)
98
+ tzinfo (1.2.5)
99
+ thread_safe (~> 0.1)
100
+ xcodeproj (1.6.0)
101
+ CFPropertyList (>= 2.3.3, < 4.0)
102
+ atomos (~> 0.1.3)
103
+ claide (>= 1.0.2, < 2.0)
104
+ colored2 (~> 3.1)
105
+ nanaimo (~> 0.2.6)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ bundler (~> 1.16)
112
+ cocoapods-dependency!
113
+ coveralls (~> 0)
114
+ rake (~> 10.0)
115
+ rspec (~> 3.0)
116
+
117
+ BUNDLED WITH
118
+ 1.16.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Cocoapods Dependency
2
+
3
+ [![Build Status](https://travis-ci.org/X140Yu/cocoapods-dependency.svg?branch=master)](https://travis-ci.org/X140Yu/cocoapods-dependency)
4
+ [![Coverage Status](https://coveralls.io/repos/github/X140Yu/cocoapods-dependency/badge.svg?branch=master)](https://coveralls.io/github/X140Yu/cocoapods-dependency?branch=master)
5
+
6
+
7
+ A ruby gem which analyzes the dependencies of any cocoapods projects. Subspecs are properly handled.
8
+
9
+ ## [中文说明](https://zhaoxinyu.me/2018-08-20-analyze-pods-dependecy/)
10
+
11
+ ## Installation & Usage
12
+
13
+ Clone this repo,
14
+
15
+ And then execute:
16
+
17
+ $ cd cocoapods-dependency
18
+ $ bundle
19
+ $ bin/analyze /path/to/podfile_dir
20
+
21
+ Note: the argument has to be a absolute path to the podfile directory.
22
+
23
+ You will get a result like this,
24
+
25
+ ```ruby
26
+ {
27
+ 'Texture' => ['PINCache', 'PINOperation', 'PINRemoteImage'],
28
+ 'PINCache' => ['PINOperation'],
29
+ 'PINRemoteImage' => ['PINCache', 'PINOperation'],
30
+ 'PINOperation' => [],
31
+ }
32
+ ```
33
+
34
+ ## Why this gem?
35
+
36
+ Suppose you have a project with a simple dependency,
37
+
38
+ ```ruby podfile
39
+ target 'Test' do
40
+ pod 'Texture', '2.7'
41
+ end
42
+ ```
43
+
44
+ It seems like this project has just a single dependency, but behind this pod, it may depend on several other pods and these other pods may also depend on some other pods as well 🤦🏻‍♂️, it's hard to determine what the exactly dependency situation of the project with just a glance of the podfile. So I wrote this it to do this thing.
45
+
46
+ - ✅ It can print all the dependencies
47
+ - ✅ Each dependecy's dependencies can also be printed
48
+ - ✅ Subspecs are properly handled, `pod 'Texture', '2.7'` and `pod 'Texture', '2.7', subspecs: %w[PINRemoteImage IGListKit Yoga]` will lead to different results
49
+
50
+ ## TODO
51
+
52
+ - [ ] Pretty printed result
53
+ - [ ] Lift it to a cocoapods-plugin
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/analyze ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/cocoapods/analyze'
4
+ require 'pp'
5
+
6
+ path = ARGV.shift
7
+ raise 'Please pass the path of the podfile directory as the argument' unless path
8
+
9
+ pp Cocoapods::DependencyAnalyzer.analyze(path)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cocoapods/dependency"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'cocoapods-dependency/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'cocoapods-dependency'
7
+ spec.version = CocoapodsDependency::VERSION
8
+ spec.authors = ['Xinyu Zhao']
9
+ spec.email = ['zhaoxinyu1994@gmail.com']
10
+
11
+ spec.summary = 'Analyzes the dependencies of any cocoapods projects.'
12
+ spec.description = 'Analyzes the dependencies of any cocoapods projects. Subspecs are properly handled.'
13
+ spec.homepage = 'https://zhaoxinyu.me'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'coveralls', '~> 0'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+
28
+ spec.add_dependency 'cocoapods', '~> 1.5'
29
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-dependency/version'
@@ -0,0 +1,99 @@
1
+ require 'cocoapods'
2
+ require 'pathname'
3
+
4
+ module CocoapodsDependency
5
+ #
6
+ # Analyze the project using cocoapods
7
+ #
8
+ class Analyzer
9
+ def self.analyze(podfile_dir_path)
10
+ path = Pathname.new(podfile_dir_path)
11
+ raise 'absolute path is needed' unless path.absolute?
12
+
13
+ Dir.chdir(podfile_dir_path) do
14
+ analyze_with_podfile(
15
+ path,
16
+ Pod::Podfile.from_file(path + 'Podfile'),
17
+ Pod::Lockfile.from_file(path + 'Podfile.lock')
18
+ )
19
+ end
20
+ end
21
+
22
+ def self.podfile_dependencies(podfile)
23
+ res = []
24
+ podfile.root_target_definitions.each do |td|
25
+ children_definitions = td.recursive_children
26
+ children_definitions.each do |cd|
27
+ dependencies_hash_array = cd.send(:get_hash_value, 'dependencies')
28
+ next if dependencies_hash_array.count.zero?
29
+
30
+ dependencies_hash_array.each do |item|
31
+ next if item.class.name != 'Hash'
32
+
33
+ item.each do |name, _|
34
+ res.push name
35
+ end
36
+ end
37
+ end
38
+ end
39
+ res
40
+ end
41
+
42
+ def self.analyze_with_podfile(_podfile_dir_path, podfile, lockfile = nil)
43
+ analyzer = Pod::Installer::Analyzer.new(
44
+ Pod::Sandbox.new(Dir.mktmpdir),
45
+ podfile,
46
+ lockfile
47
+ )
48
+
49
+ specifications = analyzer.analyze.specifications.map(&:root).uniq
50
+
51
+ podfile_dependencies = podfile_dependencies(podfile)
52
+
53
+ map = {}
54
+ specifications.each do |s|
55
+ map[s.name] = if s.default_subspecs.count > 0
56
+ subspecs_with_name(s, s.default_subspecs) + s.dependencies
57
+ else
58
+ s.subspecs + s.dependencies
59
+ end
60
+ subspecs_in_podfile = podfile_dependencies.select { |pd| pd.split('/')[0] == s.name }
61
+ sp = subspecs_in_podfile.map { |sip| s.subspecs.find { |ss| ss.name == sip } }.compact
62
+ map[s.name] = sp if sp.count != 0
63
+ s.subspecs.each do |ss|
64
+ map[ss.name] = ss.dependencies
65
+ end
66
+ end
67
+
68
+ # for performance
69
+ dependencies_map = {}
70
+ specifications.each do |s|
71
+ dependencies_map[s.name] = s
72
+ end
73
+
74
+ new_map = {}
75
+ specifications.each do |s|
76
+ new_map[s.name] = find_dependencies(s.name, map, [], dependencies_map, s.name).uniq.sort
77
+ end
78
+
79
+ new_map
80
+ end
81
+
82
+ def self.find_dependencies(name, map, res, dependencies_map, root_name)
83
+ return unless map[name]
84
+
85
+ map[name].each do |k|
86
+ find_dependencies(k.name, map, res, dependencies_map, root_name)
87
+ dependency = dependencies_map[k.name.split('/')[0]]
88
+ res.push dependency.name if dependency && dependency.name != root_name
89
+ end
90
+ res
91
+ end
92
+
93
+ def self.subspecs_with_name(spec, subspecs_short_names)
94
+ subspecs_short_names.map do |name|
95
+ spec.subspecs.find { |ss| ss.name.include? name }
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-dependency/command/dependency'
@@ -0,0 +1,30 @@
1
+ require 'cocoapods-dependency/analyze'
2
+ require 'pp'
3
+ module Pod
4
+ class Command
5
+
6
+ class Dependency < Command
7
+ self.summary = 'Analyzes the dependencies of any cocoapods projects.'
8
+
9
+ self.description = <<-DESC
10
+ Analyzes the dependencies of any cocoapods projects. Subspecs are properly handled.
11
+ DESC
12
+
13
+ # self.arguments = 'NAME'
14
+
15
+ def initialize(argv)
16
+ @name = argv.shift_argument
17
+ super
18
+ end
19
+
20
+ def validate!
21
+ super
22
+ verify_podfile_exists!
23
+ end
24
+
25
+ def run
26
+ pp CocoapodsDependency::Analyzer.analyze_with_podfile(nil, config.podfile)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ # :nocov:
2
+ module CocoapodsDependency
3
+ VERSION = "0.1.0"
4
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-dependency/command'
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-dependency
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Xinyu Zhao
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-09-14 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
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
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: cocoapods
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.5'
83
+ description: Analyzes the dependencies of any cocoapods projects. Subspecs are properly
84
+ handled.
85
+ email:
86
+ - zhaoxinyu1994@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".rubocop.yml"
94
+ - ".simplecov"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/analyze
102
+ - bin/console
103
+ - bin/setup
104
+ - cocoapods-dependency.gemspec
105
+ - lib/cocoapods-dependency.rb
106
+ - lib/cocoapods-dependency/analyze.rb
107
+ - lib/cocoapods-dependency/command.rb
108
+ - lib/cocoapods-dependency/command/dependency.rb
109
+ - lib/cocoapods-dependency/version.rb
110
+ - lib/cocoapods_plugin.rb
111
+ homepage: https://zhaoxinyu.me
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.6.14
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Analyzes the dependencies of any cocoapods projects.
135
+ test_files: []