cocoapods-dependencies 0.4.1 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92aa58560ae3465b1cb34a916e9ab23277c7f92f
4
- data.tar.gz: 958347a537c155896ebce64330ef4d3e4a4586c5
3
+ metadata.gz: 6df1521f948464f5de577e826da141c40a7dbc5e
4
+ data.tar.gz: 65a4380ebca179b108a9793cc8c877aafacf3478
5
5
  SHA512:
6
- metadata.gz: 5b3f82769405c6c7e9a497d2d8ad0aa294675cce32a5c214f7e7ce6b4ce4fff30e7ba4992ecb615a588367dfb61996d160814e82172cf8c457ea222f3d0169a1
7
- data.tar.gz: f8e98e2f4f2ebeb2928b0b8b44a30e9785eda908d4f98da111e632ef91e489a1c513a3d88c594e7c856c3eaba204c1b0ac51c32dd0d0110ca3c0ef2dadb42f21
6
+ metadata.gz: c01ff988b603af73bc674446b24767529f6e88a681895e6d7a97f6fc8b8bcdeddfa13e12431b8a5bd46a4abc57bd6c3a093f3ebc4f6ec6b170ea8b22ce4f6f3c
7
+ data.tar.gz: 0d729655c79bb6b07c6bfc28b90edce9d94952a6a78ec48275ff67122022bd71b8e6859887710bbef82256b447a8e597f21f8acc65d402c57f65ecb6abf6a55d
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-dependencies (0.4.1)
4
+ cocoapods-dependencies (0.5.0)
5
+ ruby-graphviz (~> 1.2)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  rake (10.2.2)
11
+ ruby-graphviz (1.2.2)
10
12
 
11
13
  PLATFORMS
12
14
  ruby
@@ -15,3 +17,6 @@ DEPENDENCIES
15
17
  bundler (~> 1.3)
16
18
  cocoapods-dependencies!
17
19
  rake
20
+
21
+ BUNDLED WITH
22
+ 1.10.5
data/README.md CHANGED
@@ -14,5 +14,9 @@ $ [sudo] gem install cocoapods-dependencies
14
14
  ## Usage
15
15
 
16
16
  ```bash
17
- $ pod dependencies [PODSPEC]
17
+ $ pod dependencies [PODSPEC] [--graphviz] [--image]
18
18
  ```
19
+
20
+ Use the `--graphviz` option to generate `<podspec name>.gv` or `Podfile.gv` containing the dependency graph in graphviz format.
21
+
22
+ Use the `--image` option to generate `<podsepc name>.png` or `Podfile.png` containing a rendering of the dependency graph.
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency "ruby-graphviz", "~> 1.2"
23
25
  end
@@ -1,5 +1,5 @@
1
1
  module Pod
2
2
  module Dependencies
3
- VERSION = '0.4.1'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
@@ -11,6 +11,8 @@ module Pod
11
11
  [
12
12
  ['--ignore-lockfile', 'Whether the lockfile should be ignored when calculating the dependency graph'],
13
13
  ['--repo-update', 'Fetch external podspecs and run `pod repo update` before calculating the dependency graph'],
14
+ ['--graphviz', 'Outputs the dependency graph in Graphviz format to <podspec name>.gv or Podfile.gv'],
15
+ ['--image', 'Outputs the dependency graph as an image to <podsepc name>.png or Podfile.png'],
14
16
  ].concat(super)
15
17
  end
16
18
 
@@ -24,6 +26,8 @@ module Pod
24
26
  @podspec_name = argv.shift_argument
25
27
  @ignore_lockfile = argv.flag?('ignore-lockfile', false)
26
28
  @repo_update = argv.flag?('repo-update', false)
29
+ @produce_graphviz_output = argv.flag?('graphviz', false)
30
+ @produce_image_output = argv.flag?('image', false)
27
31
  super
28
32
  end
29
33
 
@@ -44,10 +48,11 @@ module Pod
44
48
  end
45
49
 
46
50
  def run
47
- UI.title 'Dependencies' do
48
- require 'yaml'
49
- UI.puts dependencies.to_yaml
50
- end
51
+ require 'graphviz'
52
+ require 'yaml'
53
+ graphviz_image_output if @produce_image_output
54
+ graphviz_dot_output if @produce_graphviz_output
55
+ yaml_output
51
56
  end
52
57
 
53
58
  def dependencies
@@ -97,6 +102,71 @@ module Pod
97
102
  config.sandbox
98
103
  end
99
104
  end
105
+
106
+ def graphviz_data
107
+ @graphviz ||= begin
108
+ graph = GraphViz::new(output_file_basename, :type => :digraph)
109
+ root = graph.add_node(output_file_basename)
110
+
111
+ unless @podspec
112
+ podfile_dependencies.each do |pod|
113
+ pod_node = graph.add_node(pod)
114
+ graph.add_edge(root, pod_node)
115
+ end
116
+ end
117
+
118
+ pod_to_dependencies.each do |pod, dependencies|
119
+ pod_node = graph.add_node(sanitized_pod_name(pod))
120
+ dependencies.each do |dependency|
121
+ dep_node = graph.add_node(sanitized_pod_name(dependency))
122
+ graph.add_edge(pod_node, dep_node)
123
+ end
124
+ end
125
+
126
+ graph
127
+ end
128
+ end
129
+
130
+ # Truncates the input string after a pod's name removing version requirements, etc.
131
+ def sanitized_pod_name(name)
132
+ match = /([\w_\/]+)( \(.*\))?/.match(name)
133
+ match ? match[1] : name
134
+ end
135
+
136
+ # Returns a Set of Strings of the names of dependencies specified in the Podfile.
137
+ def podfile_dependencies
138
+ Set.new(podfile.target_definitions.values.map { |t| t.dependencies.map { |d| d.name } }.flatten)
139
+ end
140
+
141
+ # Returns a [String] of the names of dependencies specified in the podspec.
142
+ def podspec_dependencies
143
+ @podspec.all_dependencies.map { |d| d.name }
144
+ end
145
+
146
+ # Returns a [String: [String]] containing resolved mappings from the name of a pod to an array of the names of its dependencies.
147
+ def pod_to_dependencies
148
+ dependencies.map { |d| d.is_a?(Hash) ? d : { d => [] } }.reduce({}) { |combined, individual| combined.merge!(individual) }
149
+ end
150
+
151
+ # Basename to use for output files.
152
+ def output_file_basename
153
+ return 'Podfile' unless @podspec_name
154
+ File.basename(@podspec_name, File.extname(@podspec_name))
155
+ end
156
+
157
+ def yaml_output
158
+ UI.title 'Dependencies' do
159
+ UI.puts dependencies.to_yaml
160
+ end
161
+ end
162
+
163
+ def graphviz_image_output
164
+ graphviz_data.output( :png => "#{output_file_basename}.png")
165
+ end
166
+
167
+ def graphviz_dot_output
168
+ graphviz_data.output( :dot => "#{output_file_basename}.gv")
169
+ end
100
170
 
101
171
  end
102
172
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel E. Giddins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
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'
41
55
  description: Shows a project's CocoaPods dependency graph.
42
56
  email:
43
57
  - segiddins@segiddins.me
@@ -75,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
89
  version: '0'
76
90
  requirements: []
77
91
  rubyforge_project:
78
- rubygems_version: 2.4.6
92
+ rubygems_version: 2.4.8
79
93
  signing_key:
80
94
  specification_version: 4
81
95
  summary: Shows a project's CocoaPods dependency graph.