pod-target 0.1.4 → 0.2.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 +4 -4
- data/.idea/inspectionProfiles/Project_Default.xml +5 -0
- data/.idea/pod-target.iml +6 -4
- data/.idea/vcs.xml +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/README.md +12 -1
- data/lib/pod/target/cli.rb +14 -8
- data/lib/pod/target/commands/{resolve/dependency.rb → dependency.rb} +5 -6
- data/lib/pod/target/commands/resolve/graph.rb +14 -2
- data/lib/pod/target/commands/target.rb +84 -0
- data/lib/pod/target/templates/target/.gitkeep +1 -0
- data/lib/pod/target/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c295b45538525799e71dfab6879e9919289ffcd5dc92a36004ea9d0f1e809c7
|
4
|
+
data.tar.gz: d470fd27f32dce46cf517de02bca2c2b1d9a4f4bf9c7eb823352dddf22051641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7db41989940fc351f282ab6d154e0dbfac5cb914715fdb29f03cedb0841f46f0ba24b74fbebc5a27c1860294345758df87d69d0480b786a3317a2a659a160e15
|
7
|
+
data.tar.gz: a8a6be9427993f40fd5c5548c08e554ad9b958a3fd5f5a9619b569d8cb4e61f27a052530d56516947769a4ee9fc276e718862418e35cc331d157bd3d74afb291
|
@@ -1,6 +1,11 @@
|
|
1
1
|
<component name="InspectionProjectProfileManager">
|
2
2
|
<profile version="1.0">
|
3
3
|
<option name="myName" value="Project Default" />
|
4
|
+
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
5
|
+
<Languages>
|
6
|
+
<language minSize="69" name="Ruby" />
|
7
|
+
</Languages>
|
8
|
+
</inspection_tool>
|
4
9
|
<inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
|
5
10
|
</profile>
|
6
11
|
</component>
|
data/.idea/pod-target.iml
CHANGED
@@ -22,11 +22,13 @@
|
|
22
22
|
<orderEntry type="library" scope="PROVIDED" name="necromancer (v0.3.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
23
23
|
<orderEntry type="library" scope="PROVIDED" name="pastel (v0.6.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
24
24
|
<orderEntry type="library" scope="PROVIDED" name="rake (v12.3.3, RVM: ruby-2.7.0) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.3, RVM: ruby-2.7.0) [gem]" level="application" />
|
25
26
|
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
26
27
|
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
27
28
|
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
28
29
|
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
29
30
|
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-graphviz (v1.2.5, RVM: ruby-2.7.0) [gem]" level="application" />
|
30
32
|
<orderEntry type="library" scope="PROVIDED" name="thor (v1.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
31
33
|
<orderEntry type="library" scope="PROVIDED" name="tty (v0.5.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
32
34
|
<orderEntry type="library" scope="PROVIDED" name="tty-color (v0.3.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
@@ -49,16 +51,16 @@
|
|
49
51
|
<option name="myRootTask">
|
50
52
|
<RakeTaskImpl id="rake">
|
51
53
|
<subtasks>
|
52
|
-
<RakeTaskImpl description="Build pod-target-0.1.
|
54
|
+
<RakeTaskImpl description="Build pod-target-0.1.4.gem into the pkg directory" fullCommand="build" id="build" />
|
53
55
|
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
54
56
|
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
55
|
-
<RakeTaskImpl description="Build and install pod-target-0.1.
|
57
|
+
<RakeTaskImpl description="Build and install pod-target-0.1.4.gem into system gems" fullCommand="install" id="install" />
|
56
58
|
<RakeTaskImpl id="install">
|
57
59
|
<subtasks>
|
58
|
-
<RakeTaskImpl description="Build and install pod-target-0.1.
|
60
|
+
<RakeTaskImpl description="Build and install pod-target-0.1.4.gem into system gems without network access" fullCommand="install:local" id="local" />
|
59
61
|
</subtasks>
|
60
62
|
</RakeTaskImpl>
|
61
|
-
<RakeTaskImpl description="Create tag v0.1.
|
63
|
+
<RakeTaskImpl description="Create tag v0.1.4 and build and push pod-target-0.1.4.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
62
64
|
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
63
65
|
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
64
66
|
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
data/.idea/vcs.xml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pod-target (0.
|
4
|
+
pod-target (0.2.0)
|
5
5
|
thor
|
6
6
|
xcodeproj (~> 1.7)
|
7
7
|
|
@@ -20,6 +20,7 @@ GEM
|
|
20
20
|
equatable (~> 0.5.0)
|
21
21
|
tty-color (~> 0.3.0)
|
22
22
|
rake (12.3.3)
|
23
|
+
rexml (3.2.3)
|
23
24
|
rspec (3.10.0)
|
24
25
|
rspec-core (~> 3.10.0)
|
25
26
|
rspec-expectations (~> 3.10.0)
|
@@ -33,6 +34,8 @@ GEM
|
|
33
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
35
|
rspec-support (~> 3.10.0)
|
35
36
|
rspec-support (3.10.2)
|
37
|
+
ruby-graphviz (1.2.5)
|
38
|
+
rexml
|
36
39
|
thor (1.1.0)
|
37
40
|
tty (0.5.0)
|
38
41
|
equatable (~> 0.5.0)
|
@@ -93,6 +96,7 @@ DEPENDENCIES
|
|
93
96
|
pod-target!
|
94
97
|
rake (~> 12.0)
|
95
98
|
rspec (~> 3.0)
|
99
|
+
ruby-graphviz
|
96
100
|
tty
|
97
101
|
|
98
102
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ X->Y means X depends on Y
|
|
6
6
|

|
7
7
|
Like the image above, we have: A->B->C and A->C. We will output the file csv named "remove_dependency.csv" to show the targets that can be removed from A. For this example, it will be like this:
|
8
8
|
A,C. The first column is the target, and the following targets are targets can be removed.
|
9
|
+
|
10
|
+
Moreover, we also draw dependency graph for specific target based on this idea. We remove all dependencies lika A->C, so we can see dependencie between targets clearer.
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this line to your application's Gemfile:
|
@@ -23,7 +25,7 @@ Or install it yourself as:
|
|
23
25
|
$ gem install pod-target
|
24
26
|
|
25
27
|
## Usage
|
26
|
-
pod-target resolve-dependency
|
28
|
+
pod-target resolve-dependency\
|
27
29
|
|
28
30
|
Options:\
|
29
31
|
[--workspace=WORKSPACE] # Set workspace path, if not set will use current directory\
|
@@ -33,6 +35,15 @@ Options:\
|
|
33
35
|
[--filter=expression] # If set, filter targets which name matches the regular expression\
|
34
36
|
|
35
37
|
Workspace path and output path can be absolute path or relative path
|
38
|
+
|
39
|
+
pod-target target\
|
40
|
+
|
41
|
+
Options:\
|
42
|
+
[--root=ROOT] # Set name of the root target, must be set
|
43
|
+
\
|
44
|
+
[--workspace=WORKSPACE] # Set workspace path, if not set will use current directory
|
45
|
+
\
|
46
|
+
[--output=OUTPUT] # Set output path of csv file, if not set will use current directory
|
36
47
|
## Development
|
37
48
|
|
38
49
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/pod/target/cli.rb
CHANGED
@@ -19,9 +19,19 @@ module Pod
|
|
19
19
|
end
|
20
20
|
map %w(--version -v) => :version
|
21
21
|
|
22
|
+
desc 'target', 'Find dependencies of the target'
|
23
|
+
method_option :root, type: :string,
|
24
|
+
desc: 'Set name of the root target, must be set'
|
25
|
+
method_option :workspace, type: :string,
|
26
|
+
desc: "Set workspace path, if not set will use current directory"
|
27
|
+
method_option :output, type: :string,
|
28
|
+
desc: "Set output path of csv file, if not set will use current directory"
|
29
|
+
def target(*)
|
30
|
+
require_relative 'commands/target'
|
31
|
+
Pod::Target::Commands::Target.new(options).execute
|
32
|
+
end
|
33
|
+
|
22
34
|
desc 'resolve-dependency', "Resolve dependencies of pod's targets"
|
23
|
-
method_option :help, aliases: '-h', type: :boolean,
|
24
|
-
desc: 'Display usage information'
|
25
35
|
method_option :workspace, type: :string,
|
26
36
|
desc: "Set workspace path, if not set will use current directory"
|
27
37
|
method_option :output, type: :string,
|
@@ -29,12 +39,8 @@ module Pod
|
|
29
39
|
method_option :filter, type: :string, banner: "expression",
|
30
40
|
desc: "If set, filter targets which name matches the regular expression"
|
31
41
|
def resolve_dependency(*)
|
32
|
-
|
33
|
-
|
34
|
-
else
|
35
|
-
require_relative 'commands/resolve/dependency'
|
36
|
-
Pod::Target::Commands::Dependency.new(options).execute
|
37
|
-
end
|
42
|
+
require_relative 'commands/dependency'
|
43
|
+
Pod::Target::Commands::Dependency.new(options).execute
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative '../command'
|
4
4
|
require 'tty-prompt'
|
5
5
|
|
6
6
|
module Pod
|
7
7
|
module Target
|
8
8
|
module Commands
|
9
9
|
class Dependency < Pod::Target::Command
|
10
|
-
require_relative './xcworkspace'
|
11
|
-
require_relative './parser'
|
12
|
-
require_relative './graph'
|
10
|
+
require_relative './resolve/xcworkspace'
|
11
|
+
require_relative './resolve/parser'
|
12
|
+
require_relative './resolve/graph'
|
13
13
|
def initialize(options)
|
14
14
|
@options = options
|
15
15
|
end
|
@@ -36,12 +36,11 @@ module Pod
|
|
36
36
|
nodes = graph.nodes
|
37
37
|
nodes.each do |_, value|
|
38
38
|
level_map = {}
|
39
|
-
graph.
|
39
|
+
graph.dfs(value, level_map, 0)
|
40
40
|
removes = []
|
41
41
|
value.neighbors.each do |neighbor|
|
42
42
|
if level_map[neighbor.name] > 1
|
43
43
|
removes << neighbor.name
|
44
|
-
|
45
44
|
end
|
46
45
|
end
|
47
46
|
if removes.size > 0
|
@@ -52,7 +52,7 @@ module Pod
|
|
52
52
|
source.add_neighbor(destination)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def dfs(node, level_map, depth)
|
56
56
|
return if depth == 3
|
57
57
|
name = node.name
|
58
58
|
if level_map.key?(name)
|
@@ -61,7 +61,19 @@ module Pod
|
|
61
61
|
level_map[name] = depth
|
62
62
|
end
|
63
63
|
node.neighbors.each do |neighbor|
|
64
|
-
|
64
|
+
dfs(neighbor, level_map, depth+1)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def dfs2(node, level_map, depth)
|
69
|
+
name = node.name
|
70
|
+
if level_map.key?(name)
|
71
|
+
level_map[name] = [level_map[name], depth].max
|
72
|
+
else
|
73
|
+
level_map[name] = depth
|
74
|
+
end
|
75
|
+
node.neighbors.each do |neighbor|
|
76
|
+
dfs2(neighbor, level_map, depth+1)
|
65
77
|
end
|
66
78
|
end
|
67
79
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../command'
|
4
|
+
require 'tty-prompt'
|
5
|
+
require 'graphviz'
|
6
|
+
|
7
|
+
module Pod
|
8
|
+
module Target
|
9
|
+
module Commands
|
10
|
+
class Target < Pod::Target::Command
|
11
|
+
require_relative './resolve/xcworkspace'
|
12
|
+
require_relative './resolve/parser'
|
13
|
+
require_relative './resolve/graph'
|
14
|
+
def initialize(options)
|
15
|
+
@options = options
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute(input: $stdin, output: $stdout)
|
19
|
+
@xcworkspace = @options[:workspace]
|
20
|
+
@xcworkspace ||= XCWorkspace.find_workspace
|
21
|
+
@output = @options[:output]
|
22
|
+
@output ||= '.'
|
23
|
+
@root = @options[:root]
|
24
|
+
if @root.nil?
|
25
|
+
prompt = TTY::Prompt.new
|
26
|
+
prompt.error("Root target is not set")
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
parse
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse
|
33
|
+
prompt = TTY::Prompt.new
|
34
|
+
prompt.ok("Finding targets' dependencies and build graph...")
|
35
|
+
parser = Parser.new(@xcworkspace, nil)
|
36
|
+
targets = parser.all_targets
|
37
|
+
graph = Graph.new
|
38
|
+
graph.add_target_info(targets)
|
39
|
+
dir = File.dirname(@output + "/dependencies.gv")
|
40
|
+
tmp_file = File.join(dir, '/dependencies.gv')
|
41
|
+
save_gv(graphviz_data(graph), tmp_file)
|
42
|
+
graphviz_graph = GraphViz.parse(tmp_file)
|
43
|
+
save_png(graphviz_graph, 'dependencies.png')
|
44
|
+
FileUtils.remove_file(tmp_file)
|
45
|
+
prompt.ok("File is write at: " + dir + "/dependencies.png")
|
46
|
+
end
|
47
|
+
|
48
|
+
def save_gv(graphviz_data, filename)
|
49
|
+
graphviz_data.output(dot: filename)
|
50
|
+
end
|
51
|
+
|
52
|
+
def save_png(graphviz_data, filename)
|
53
|
+
graphviz_data.output(png: filename)
|
54
|
+
end
|
55
|
+
|
56
|
+
def graphviz_data(graph)
|
57
|
+
node = graph.nodes.values.find { |node| node.name =~ /#{@root}/ }
|
58
|
+
unless node.nil?
|
59
|
+
graphviz = GraphViz.new(type: :digraph)
|
60
|
+
level_map = {}
|
61
|
+
graph.dfs2(node, level_map, 0)
|
62
|
+
visited = Set.new([])
|
63
|
+
dfs(graphviz, node, visited, level_map)
|
64
|
+
graphviz
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def dfs(graphviz, node, visited, level_map)
|
69
|
+
return if visited.include?(node.name)
|
70
|
+
visited.add(node.name)
|
71
|
+
depth = level_map[node.name]
|
72
|
+
target_node = graphviz.add_node(node.name)
|
73
|
+
node.neighbors.each do |dependency|
|
74
|
+
if level_map[dependency.name] == depth+1
|
75
|
+
dep_node = graphviz.add_node(dependency.name)
|
76
|
+
graphviz.add_edge(target_node, dep_node)
|
77
|
+
dfs(graphviz, dependency, visited, level_map)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
data/lib/pod/target/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pod-target
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bao Do
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -70,12 +70,14 @@ files:
|
|
70
70
|
- lib/pod/target/cli.rb
|
71
71
|
- lib/pod/target/command.rb
|
72
72
|
- lib/pod/target/commands/.gitkeep
|
73
|
-
- lib/pod/target/commands/
|
73
|
+
- lib/pod/target/commands/dependency.rb
|
74
74
|
- lib/pod/target/commands/resolve/graph.rb
|
75
75
|
- lib/pod/target/commands/resolve/parser.rb
|
76
76
|
- lib/pod/target/commands/resolve/xcworkspace.rb
|
77
|
+
- lib/pod/target/commands/target.rb
|
77
78
|
- lib/pod/target/templates/.gitkeep
|
78
79
|
- lib/pod/target/templates/resolve/dependency/.gitkeep
|
80
|
+
- lib/pod/target/templates/target/.gitkeep
|
79
81
|
- lib/pod/target/version.rb
|
80
82
|
- pod-target.gemspec
|
81
83
|
homepage: https://github.com/bendoppler/podspec-dependency-resolve.git
|