cocoapods-dependencies-graph 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
+ SHA1:
3
+ metadata.gz: a8cb1123a0894147b6ef8376a2e904538ba91d3b
4
+ data.tar.gz: 9ff250af8bb6fb9808a4be6c359a5906a0a45365
5
+ SHA512:
6
+ metadata.gz: 8e4ecf99d4fcb9781802a563761fb4d20642049780bbb9272ba15c38479f0ad5c718bc7da112f383a5badc3df0dd7b78e7290e3a4a4ca99ad4127ffe5bc59a7e
7
+ data.tar.gz: a4b54c8027e53c4f267dbc4228ebde13e24ab876b4022afd1e42648e51b4683f64fe321c17679ced94c44b17269ba3ef24e5b43a5bf093512086c0f06722e4fb
data/.fury ADDED
@@ -0,0 +1 @@
1
+ application_name: cocoapods-dependencies
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'cocoapods', '~> 1.0'
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-dependencies-graph (0.0.1)
5
+ ruby-graphviz (~> 1.2)
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.2)
17
+ claide (1.0.2)
18
+ cocoapods (1.5.2)
19
+ activesupport (>= 4.0.2, < 5)
20
+ claide (>= 1.0.2, < 2.0)
21
+ cocoapods-core (= 1.5.2)
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.2)
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.0)
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.0)
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
+ escape (0.0.4)
54
+ fourflusher (2.0.1)
55
+ fuzzy_match (2.0.4)
56
+ gh_inspector (1.1.3)
57
+ i18n (0.9.5)
58
+ concurrent-ruby (~> 1.0)
59
+ minitest (5.11.3)
60
+ molinillo (0.6.5)
61
+ nanaimo (0.2.5)
62
+ nap (1.1.0)
63
+ netrc (0.11.0)
64
+ rake (12.3.1)
65
+ ruby-graphviz (1.2.3)
66
+ ruby-macho (1.1.0)
67
+ thread_safe (0.3.6)
68
+ tzinfo (1.2.5)
69
+ thread_safe (~> 0.1)
70
+ xcodeproj (1.5.8)
71
+ CFPropertyList (>= 2.3.3, < 4.0)
72
+ atomos (~> 0.1.2)
73
+ claide (>= 1.0.2, < 2.0)
74
+ colored2 (~> 3.1)
75
+ nanaimo (~> 0.2.5)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ bundler (~> 1.3)
82
+ cocoapods (~> 1.0)
83
+ cocoapods-dependencies-graph!
84
+ rake
85
+
86
+ BUNDLED WITH
87
+ 1.16.1
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Samuel E. Giddins <segiddins@segiddins.me>
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,23 @@
1
+ # cocoapods-dependencies
2
+
3
+ Shows a project's CocoaPod dependency graph.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ $ [sudo] gem install cocoapods-dependencies
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ $ pod dependencies [PODSPEC] [--graphviz] [--image]
15
+ ```
16
+
17
+ Use the `--graphviz` option to generate `<podspec name>.gv` or `Podfile.gv` containing the dependency graph in graphviz format.
18
+
19
+ Use the `--image` option to generate `<podspec name>.png` or `Podfile.png` containing a rendering of the dependency graph.
20
+
21
+ Use the `--occurrences-of` option to find all occurences of the pod name in the dependency graph.
22
+
23
+ [!] Note that for either graphviz or image output, GraphViz must be installed and `dot` must be accessible via `$PATH`.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods_dependencies.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-dependencies-graph"
8
+ spec.version = Pod::Dependencies::VERSION
9
+ spec.author = "MP Mobile Core"
10
+ spec.email = "mpmobile_core@mercadolibre.com"
11
+ spec.description = %q{Shows a project's CocoaPods dependency graph.}
12
+ spec.summary = %q{Shows a project's CocoaPods dependency graph.}
13
+ spec.homepage = "https://github.com/mercadolibre/fury_cocoapods-dependencies"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+
23
+ spec.add_dependency "ruby-graphviz", "~> 1.2"
24
+ end
@@ -0,0 +1,5 @@
1
+ module Pod
2
+ module Dependencies
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'pod/command/dependencies'
@@ -0,0 +1,206 @@
1
+ module Pod
2
+ class Command
3
+ class Dependencies < Command
4
+ include Command::ProjectDirectory
5
+
6
+ self.summary = "Show project's dependency graph."
7
+
8
+ self.description = <<-DESC
9
+ Shows the project's dependency graph.
10
+ DESC
11
+
12
+ def self.options
13
+ [
14
+ ['--ignore-lockfile', 'Whether the lockfile should be ignored when calculating the dependency graph'],
15
+ ['--repo-update', 'Fetch external podspecs and run `pod repo update` before calculating the dependency graph'],
16
+ ['--graphviz', 'Outputs the dependency graph in Graphviz format to <podspec name>.gv or Podfile.gv'],
17
+ ['--image', 'Outputs the dependency graph as an image to <podspec name>.png or Podfile.png'],
18
+ ['--occurrences-of', 'Prints out pod name ocurrences']
19
+ ].concat(super)
20
+ end
21
+
22
+ def self.arguments
23
+ [
24
+ CLAide::Argument.new('PODSPEC', false)
25
+ ].concat(super)
26
+ end
27
+
28
+ def initialize(argv)
29
+ @podspec_name = argv.shift_argument
30
+ @ignore_lockfile = argv.flag?('ignore-lockfile', false)
31
+ @repo_update = argv.flag?('repo-update', false)
32
+ @produce_graphviz_output = argv.flag?('graphviz', false)
33
+ @produce_image_output = argv.flag?('image', false)
34
+ @lib_to_find = argv.option('occurrences-of')
35
+ super
36
+ end
37
+
38
+ def validate!
39
+ super
40
+ if @podspec_name
41
+ require 'pathname'
42
+ path = Pathname.new(@podspec_name)
43
+ if path.file?
44
+ @podspec = Specification.from_file(path)
45
+ else
46
+ sets = Config.
47
+ instance.
48
+ sources_manager.
49
+ search(Dependency.new(@podspec_name))
50
+ spec = sets && sets.specification
51
+ @podspec = spec && spec.subspec_by_name(@podspec_name)
52
+ raise Informative, "Cannot find `#{@podspec_name}`." unless @podspec
53
+ end
54
+ end
55
+ if (@produce_image_output || @produce_graphviz_output) && Executable.which('dot').nil?
56
+ raise Informative, 'GraphViz must be installed and `dot` must be in ' \
57
+ '$PATH to produce image or graphviz output.'
58
+ end
59
+ end
60
+
61
+ def run
62
+ require 'yaml'
63
+ UI.title "Calculating dependencies" do
64
+ dependencies
65
+ end
66
+ graphviz_image_output if @produce_image_output
67
+ graphviz_dot_output if @produce_graphviz_output
68
+ yaml_output
69
+ UI.puts "#{@lib_to_find} occurrences: #{find_occurrences}" if @lib_to_find
70
+ end
71
+
72
+ def dependencies
73
+ @dependencies ||= begin
74
+ analyzer = Installer::Analyzer.new(
75
+ sandbox,
76
+ podfile,
77
+ @ignore_lockfile || @podspec ? nil : config.lockfile
78
+ )
79
+
80
+ specs = config.with_changes(skip_repo_update: !@repo_update) do
81
+ analyzer.analyze(@repo_update || @podspec).specs_by_target.values.flatten(1)
82
+ end
83
+
84
+ lockfile = Lockfile.generate(podfile, specs, {})
85
+ lockfile.to_hash['PODS']
86
+ end
87
+ end
88
+
89
+ def podfile
90
+ @podfile ||= begin
91
+ if podspec = @podspec
92
+ platform = podspec.available_platforms.first
93
+ platform_name = platform.name
94
+ platform_version = platform.deployment_target.to_s
95
+ source_urls = Config.instance.sources_manager.all.map(&:url).compact
96
+ Podfile.new do
97
+ install! 'cocoapods', integrate_targets: false, warn_for_multiple_pod_sources: false
98
+ source_urls.each { |u| source(u) }
99
+ platform platform_name, platform_version
100
+ pod podspec.name, podspec: podspec.defined_in_file
101
+ target 'Dependencies'
102
+ end
103
+ else
104
+ verify_podfile_exists!
105
+ config.podfile
106
+ end
107
+ end
108
+ end
109
+
110
+ def sandbox
111
+ if @podspec
112
+ require 'tmpdir'
113
+ Sandbox.new(Dir.mktmpdir)
114
+ else
115
+ config.sandbox
116
+ end
117
+ end
118
+
119
+ def graphviz_data
120
+ @graphviz ||= begin
121
+ require 'graphviz'
122
+ graph = GraphViz::new(output_file_basename, :type => :digraph)
123
+ root = graph.add_node(output_file_basename)
124
+
125
+ unless @podspec
126
+ podfile_dependencies.each do |pod|
127
+ pod_node = graph.add_node(pod)
128
+ graph.add_edge(root, pod_node)
129
+ end
130
+ end
131
+
132
+ pod_to_dependencies.each do |pod, dependencies|
133
+ pod_node = graph.add_node(sanitized_pod_name(pod))
134
+ dependencies.each do |dependency|
135
+ dep_node = graph.add_node(sanitized_pod_name(dependency))
136
+ graph.add_edge(pod_node, dep_node)
137
+ end
138
+ end
139
+ graph
140
+ end
141
+ end
142
+
143
+ # Truncates the input string after a pod's name removing version requirements, etc.
144
+ def sanitized_pod_name(name)
145
+ Pod::Dependency.from_string(name).name
146
+ end
147
+
148
+ # Returns a Set of Strings of the names of dependencies specified in the Podfile.
149
+ def podfile_dependencies
150
+ Set.new(podfile.target_definitions.values.map { |t| t.dependencies.map { |d| d.name } }.flatten)
151
+ end
152
+
153
+ # Returns a [String: [String]] containing resolved mappings from the name of a pod to an array of the names of its dependencies.
154
+ def pod_to_dependencies
155
+ dependencies.map { |d| d.is_a?(Hash) ? d : { d => [] } }.reduce({}) { |combined, individual| combined.merge!(individual) }
156
+ end
157
+
158
+ # Basename to use for output files.
159
+ def output_file_basename
160
+ return 'Podfile' unless @podspec_name
161
+ File.basename(@podspec_name, File.extname(@podspec_name))
162
+ end
163
+
164
+ def yaml_output
165
+ UI.title 'Dependencies' do
166
+ UI.puts YAML.dump(dependencies)
167
+ end
168
+ end
169
+
170
+ def graphviz_image_output
171
+ graphviz_data.output( :png => "#{output_file_basename}.png")
172
+ end
173
+
174
+ def graphviz_dot_output
175
+ graphviz_data.output( :dot => "#{output_file_basename}.gv")
176
+ end
177
+
178
+ def find_occurrences
179
+ pod_occurrences_in_podfile + pod_occurrences_in_podfile_dependencies
180
+ end
181
+
182
+ def pod_occurrences_in_podfile
183
+ counter = 0
184
+ podfile_dependencies.each do |pod|
185
+ if sanitized_pod_name(pod) == @lib_to_find
186
+ counter = counter + 1
187
+ end
188
+ end
189
+ counter
190
+ end
191
+
192
+ def pod_occurrences_in_podfile_dependencies
193
+ counter = 0
194
+ pod_to_dependencies.each do |pod, dependencies|
195
+ dependencies.each do |dependency|
196
+ if sanitized_pod_name(dependency) == @lib_to_find
197
+ counter = counter + 1
198
+ end
199
+ end
200
+ end
201
+ counter
202
+ end
203
+
204
+ end
205
+ end
206
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-dependencies-graph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - MP Mobile Core
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-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.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
+ - !ruby/object:Gem::Dependency
42
+ name: ruby-graphviz
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ description: Shows a project's CocoaPods dependency graph.
56
+ email: mpmobile_core@mercadolibre.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".fury"
62
+ - Gemfile
63
+ - Gemfile.lock
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - cocoapods_dependencies.gemspec
68
+ - lib/cocoapods_dependencies.rb
69
+ - lib/cocoapods_plugin.rb
70
+ - lib/pod/command/dependencies.rb
71
+ homepage: https://github.com/mercadolibre/fury_cocoapods-dependencies
72
+ licenses: []
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.6.14
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Shows a project's CocoaPods dependency graph.
94
+ test_files: []