cocoapods-dependency 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06e9d2cc3603dedcc65d3a511dde130db41c6052
4
- data.tar.gz: ea3881bbb48de4e9bed95d7f08ceda78a3c7b72d
3
+ metadata.gz: bbceca13412e0e3a77941bcc66a5c1b0cce58422
4
+ data.tar.gz: c302b713bab4af69e22c604b2ef09c0ef36c4b47
5
5
  SHA512:
6
- metadata.gz: aac99fbc541750009f178773f236d952af61adb75436fc9417e839c6860a63456269d2f7b2d1aee2c5684720beda04a7bf787917621aab71d26649fcab6f158a
7
- data.tar.gz: 9bba5cc80b8f117a84f3af79e46a05a562d8b3cd569f49acc7140290ecf3386e9b76c1cc4313263eee1ef4f9dccf7f39ecdeba80698cfc03345fd95cb09a471b
6
+ metadata.gz: 63a9ff5a2d500cfb89fcb8ae17db5bde719c0e668f643af2adb6045c7f9028b2cffce602be60f9d9a37cded311e9d0fe4765cfd779c4e91803b9e6e6b8b0f9ff
7
+ data.tar.gz: 90b91726a892313e4196b38d8b1288a7197ddf1a8bd50e08ac16cd4a7743611599ece274d777fcd02cddb833afb724c75b10240375d2034f7929a4208b0ba345
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-dependency (0.1.1)
4
+ cocoapods-dependency (0.2.0)
5
5
  cocoapods (~> 1.5)
6
6
 
7
7
  GEM
@@ -15,10 +15,10 @@ GEM
15
15
  tzinfo (~> 1.1)
16
16
  atomos (0.1.3)
17
17
  claide (1.0.2)
18
- cocoapods (1.5.3)
18
+ cocoapods (1.5.0)
19
19
  activesupport (>= 4.0.2, < 5)
20
20
  claide (>= 1.0.2, < 2.0)
21
- cocoapods-core (= 1.5.3)
21
+ cocoapods-core (= 1.5.0)
22
22
  cocoapods-deintegrate (>= 1.0.2, < 2.0)
23
23
  cocoapods-downloader (>= 1.2.0, < 2.0)
24
24
  cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -34,7 +34,7 @@ GEM
34
34
  nap (~> 1.0)
35
35
  ruby-macho (~> 1.1)
36
36
  xcodeproj (>= 1.5.7, < 2.0)
37
- cocoapods-core (1.5.3)
37
+ cocoapods-core (1.5.0)
38
38
  activesupport (>= 4.0.2, < 6)
39
39
  fuzzy_match (~> 2.0.4)
40
40
  nap (~> 1.0)
@@ -71,19 +71,19 @@ GEM
71
71
  nap (1.1.0)
72
72
  netrc (0.11.0)
73
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)
74
+ rspec (3.8.0)
75
+ rspec-core (~> 3.8.0)
76
+ rspec-expectations (~> 3.8.0)
77
+ rspec-mocks (~> 3.8.0)
78
+ rspec-core (3.8.0)
79
+ rspec-support (~> 3.8.0)
80
+ rspec-expectations (3.8.2)
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.7.0)
83
- rspec-mocks (3.7.0)
82
+ rspec-support (~> 3.8.0)
83
+ rspec-mocks (3.8.0)
84
84
  diff-lcs (>= 1.2.0, < 2.0)
85
- rspec-support (~> 3.7.0)
86
- rspec-support (3.7.1)
85
+ rspec-support (~> 3.8.0)
86
+ rspec-support (3.8.0)
87
87
  ruby-macho (1.3.1)
88
88
  simplecov (0.16.1)
89
89
  docile (~> 1.1)
@@ -94,7 +94,7 @@ GEM
94
94
  tins (~> 1.0)
95
95
  thor (0.19.4)
96
96
  thread_safe (0.3.6)
97
- tins (1.16.3)
97
+ tins (1.17.0)
98
98
  tzinfo (1.2.5)
99
99
  thread_safe (~> 0.1)
100
100
  xcodeproj (1.7.0)
@@ -115,4 +115,4 @@ DEPENDENCIES
115
115
  rspec (~> 3.0)
116
116
 
117
117
  BUNDLED WITH
118
- 1.16.4
118
+ 1.17.0
data/README.md CHANGED
@@ -14,20 +14,15 @@ A CocoaPods plugin which analyzes the dependencies of any cocoapods projects. Su
14
14
  $ gem install cocoapods-dependency
15
15
 
16
16
  ## Usage
17
-
18
- $ pod dependency
19
17
 
20
18
  The command should be executed in directory that contains podfile.
21
19
 
22
- You will get a result like this,
20
+ ```shell
21
+ # put the analyze result to console
22
+ $ pod dependency
23
23
 
24
- ```ruby
25
- {
26
- 'Texture' => ['PINCache', 'PINOperation', 'PINRemoteImage'],
27
- 'PINCache' => ['PINOperation'],
28
- 'PINRemoteImage' => ['PINCache', 'PINOperation'],
29
- 'PINOperation' => [],
30
- }
24
+ # write te analyze result to a readable HTML
25
+ $ pod dependency --visual
31
26
  ```
32
27
 
33
28
  ## Why this gem?
@@ -49,7 +44,7 @@ It seems like this project has just a single dependency, but behind this pod, it
49
44
  ## TODO
50
45
 
51
46
  - [X] Lift it to a cocoapods-plugin
52
- - [ ] Pretty printed result
47
+ - [X] Pretty printed result
53
48
 
54
49
  ## License
55
50
 
@@ -1,5 +1,8 @@
1
1
  require 'cocoapods-dependency/analyze'
2
2
  require 'pp'
3
+ require 'cocoapods-dependency/visual_out'
4
+ require 'tmpdir'
5
+
3
6
  module Pod
4
7
  class Command
5
8
 
@@ -10,20 +13,36 @@ module Pod
10
13
  Analyzes the dependencies of any cocoapods projects. Subspecs are properly handled.
11
14
  DESC
12
15
 
13
- # self.arguments = 'NAME'
14
-
15
16
  def initialize(argv)
16
- @name = argv.shift_argument
17
+ @using_visual_output = argv.flag?('visual', false)
17
18
  super
18
19
  end
19
20
 
21
+ def self.options
22
+ [
23
+ ['--visual', 'Output the result using html'],
24
+ ].concat(super)
25
+ end
26
+
20
27
  def validate!
21
28
  super
22
29
  verify_podfile_exists!
23
30
  end
24
31
 
25
32
  def run
26
- pp CocoapodsDependency::Analyzer.analyze_with_podfile(nil, config.podfile)
33
+ analyze_result = CocoapodsDependency::Analyzer.analyze_with_podfile(nil, config.podfile)
34
+ if @using_visual_output
35
+ helper = CocoapodsDependency::VisualOutHelper.new(analyze_result)
36
+ final_path = Dir.tmpdir
37
+ helper.write_json_to_file("#{final_path}/index.json")
38
+ html_path = File.expand_path("../resources/index.html", __dir__)
39
+ system "cp #{html_path} #{final_path}"
40
+ final_html_path = "#{final_path}/index.html"
41
+ puts "[CocoapodsDependency] ✅ html file generated at path #{final_html_path}"
42
+ system "open #{final_html_path}"
43
+ else
44
+ pp result
45
+ end
27
46
  end
28
47
  end
29
48
  end
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>Dependency Checker for CocoaPods Projects</title>
7
+ <style type="text/css">
8
+ #nav a {
9
+ display: block;
10
+ }
11
+
12
+ html,
13
+ body {
14
+ height: 100%;
15
+ }
16
+
17
+ #nav {
18
+ padding: 10px 30px;
19
+ float: left;
20
+ width: 30%;
21
+ height: 100%;
22
+ overflow: scroll;
23
+ }
24
+
25
+ #content {
26
+ padding: 10px 30px;
27
+ float: left;
28
+ width: 60%;
29
+ height: 100%;
30
+ overflow: scroll;
31
+ }
32
+ </style>
33
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
34
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
35
+
36
+ <body onload="pageDidLoad()">
37
+ <script>
38
+
39
+ function loadJSON(fileName, callback) {
40
+ var xobj = new XMLHttpRequest();
41
+ xobj.overrideMimeType("application/json");
42
+ xobj.open('GET', fileName, true);
43
+ xobj.onreadystatechange = function () {
44
+ if (xobj.readyState == 4 && xobj.status == "200") {
45
+ callback(xobj.responseText);
46
+ }
47
+ };
48
+ xobj.send(null);
49
+ }
50
+
51
+ function pageDidLoad() {
52
+ loadJSON('index.json', response => {
53
+ var actual_JSON = JSON.parse(response);
54
+
55
+ let podNames = actual_JSON.links.map(s => s.source);
56
+
57
+ renderNavs(podNames)
58
+ renderPods(actual_JSON.links)
59
+ });
60
+ }
61
+
62
+ function renderNavs(podNames) {
63
+ let fLeft = document.getElementById('nav')
64
+ podNames.forEach(e => {
65
+ let nav = document.createElement('a')
66
+ nav.href = '#' + e
67
+ nav.innerText = e
68
+ fLeft.appendChild(nav)
69
+ })
70
+ }
71
+
72
+ function renderPods(pods) {
73
+ let d = document.getElementById('pods')
74
+ pods.forEach(element => {
75
+ let div = document.createElement('div')
76
+ let header = document.createElement('h3')
77
+ header.innerHTML = element.source
78
+ header.id = element.source
79
+
80
+ div.appendChild(header)
81
+
82
+ let ul = document.createElement('ul')
83
+ let dependencies = element.dependencies.sort()
84
+ dependencies.forEach(dependency => {
85
+ let li = document.createElement('li')
86
+ let a = document.createElement('a')
87
+ a.innerHTML = dependency
88
+ a.href = '#' + dependency
89
+ ul.appendChild(li)
90
+ li.appendChild(a)
91
+ })
92
+
93
+ div.appendChild(ul)
94
+ d.appendChild(div)
95
+ })
96
+ }
97
+
98
+ </script>
99
+ </head>
100
+
101
+ <body>
102
+ <div id="nav">
103
+
104
+ </div>
105
+ <div id="content">
106
+ <div id="pods"></div>
107
+ </div>
108
+ </body>
109
+
110
+ </html>
@@ -1,4 +1,4 @@
1
1
  # :nocov:
2
2
  module CocoapodsDependency
3
- VERSION = '0.1.1'
3
+ VERSION = '0.2.0'
4
4
  end
@@ -0,0 +1,50 @@
1
+ require 'json'
2
+ require 'yaml'
3
+ require 'cocoapods'
4
+ module CocoapodsDependency
5
+ class VisualOutHelper
6
+ def initialize(dependency_map)
7
+ @dependency_map = dependency_map
8
+ end
9
+
10
+ def to_d3js_json
11
+ json = {}
12
+ links = []
13
+ @dependency_map.each do |node, v|
14
+ v.each do |dependency|
15
+ links.push(
16
+ {
17
+ 'source': node,
18
+ 'dest': dependency,
19
+ }
20
+ )
21
+ end
22
+ end
23
+
24
+ json['links'] = links
25
+
26
+ JSON.pretty_generate(json)
27
+ end
28
+
29
+ def write_json_to_file(path)
30
+ links = []
31
+ json = {}
32
+ @dependency_map.each do |node, v|
33
+ links.push(
34
+ {
35
+ 'source': node,
36
+ 'dependencies': v,
37
+ }
38
+ )
39
+ end
40
+ json['links'] = links
41
+ json_result = JSON.pretty_generate(json)
42
+ File.write(path, json_result)
43
+ end
44
+
45
+ def write_d3js_to_file(path)
46
+ json = 'var dependencies = ' + to_d3js_json
47
+ File.write(path, json)
48
+ end
49
+ end
50
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dependency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xinyu Zhao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-25 00:00:00.000000000 Z
11
+ date: 2018-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,7 +106,9 @@ files:
106
106
  - lib/cocoapods-dependency/analyze.rb
107
107
  - lib/cocoapods-dependency/command.rb
108
108
  - lib/cocoapods-dependency/command/dependency.rb
109
+ - lib/cocoapods-dependency/resources/index.html
109
110
  - lib/cocoapods-dependency/version.rb
111
+ - lib/cocoapods-dependency/visual_out.rb
110
112
  - lib/cocoapods_plugin.rb
111
113
  homepage: https://github.com/X140Yu/cocoapods-dependency
112
114
  licenses: