cocoapods-why 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: cf607f5706da9f9cffa9cdac50e702f3c9e2fbf305f2674121102dfda5b80a01
4
- data.tar.gz: 07625dc6f38f2728f818bc4890d4809d19d51e9899ca9065d320c7ae0d461407
3
+ metadata.gz: 6c3cff85c9714857f4d2291c3abb3478cabc3564c31398ec078a8a681b3b2786
4
+ data.tar.gz: 1a87098be80cc339392007248aecd0f8b2dd92259e2e978217ab512c6157275e
5
5
  SHA512:
6
- metadata.gz: 43a3893be1ee319fdced20be09c9ad7e751e5c0b4d2d76ce0704878c69fcb0b9be34956ac3326611ff156cf5dc9bfb36af2edfc405ab22af274b8e7e7befc7fe
7
- data.tar.gz: 5ba60b6bc840b2c23edea06b345cab24d8c03bd9db0dc11e1344da578cedd361deb311e7b84fbb74bc782cefca4bc465739f7e50c89c482db8282ed659225145
6
+ metadata.gz: ee8d9a9bb28c0e180a124d22ae99cdc37c25983c284ae003bb4e57834306999f05c172c145852283361a9fdf3f746dc3a54c52f07cc6bb2d5da6d52b02e3533c
7
+ data.tar.gz: c173fc047350aa91f209eb90b3a239ac81ee9950af471a4054f910d1b570edfc20fd2193f5b78e0870b20aee11017d96be0ea7f4525a6a5110cfafdbc5326149
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CocoaPodsWhy
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -80,8 +80,9 @@ module Pod
80
80
  # @return [Hash<String,Array<String>>] a mapping of pod names to their direct dependencies
81
81
  def all_dependencies(targets)
82
82
  targets.to_h do |target|
83
- target_dependencies = target[:dependencies].delete_if { |dep| dep.include? '/' } # Remove subspecs
84
- [target[:name], target_dependencies]
83
+ deps = target[:dependencies] || []
84
+ deps = deps.delete_if { |dep| dep.include? '/' } # Remove subspecs
85
+ [target[:name], deps]
85
86
  end
86
87
  end
87
88
 
@@ -101,10 +102,16 @@ module Pod
101
102
  end
102
103
 
103
104
  # Computes and returns all possible paths between a source vertex and a target vertex in a directed graph.
104
- # It does this by performing a DFS and, whenever the target is discovered (or re-discovered), the current
105
- # DFS stack is captured as one of the possible paths.
106
105
  #
107
- # @note Back edges are ignored because the input graph is assumed to be acyclic.
106
+ # It does this by performing a recursive walk through the graph (like DFS). After returning from a recursive
107
+ # descent through all of a vertex's edges, the vertex is prepended to each returned path and in this way the
108
+ # list of all paths is built up. The recursion stops when the target vertex is discovered.
109
+ #
110
+ # The algorithm described above is exponential in running time, so memoization is used to speed it up.
111
+ # After all paths from a vertex are discovered, the results are stored in a hash. Before processing a vertex,
112
+ # this hash is queried for a previously stored result, which if found is returned instead of recomputed.
113
+ #
114
+ # @note The input graph is assumed to be acyclic.
108
115
  #
109
116
  # @param [String] source
110
117
  # The vertex at which to begin the search.
@@ -115,20 +122,16 @@ module Pod
115
122
  #
116
123
  # @return [Array<Array<String>>] a list of all paths from source to target
117
124
  def all_paths(source, target, graph)
118
- dfs_stack = [source] # RGL uses recursion for DFS and does not expose a stack, so we build one as we go.
119
- all_paths = []
120
- visitor = RGL::DFSVisitor.new(graph)
121
- visitor.set_tree_edge_event_handler do |_, v|
122
- dfs_stack << v
123
- all_paths << dfs_stack.dup if v == target
124
- end
125
- visitor.set_forward_edge_event_handler do |_, v|
126
- dfs_stack << v
127
- all_paths << dfs_stack.dup if v == target
128
- dfs_stack.pop
125
+
126
+ def search(source, target, graph, all_paths)
127
+ return all_paths[source] if all_paths.key?(source)
128
+ return [[target]] if source == target
129
+ source_paths = []
130
+ graph.each_adjacent(source) { |v| source_paths += search(v, target, graph, all_paths) }
131
+ all_paths[source] = source_paths.map { |path| [source] + path }
129
132
  end
130
- graph.depth_first_visit(source, visitor) { dfs_stack.pop }
131
- all_paths
133
+
134
+ search(source, target, graph, {})
132
135
  end
133
136
 
134
137
  # Converts a list of dependency paths into a graph. The vertices in the paths are
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-why
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Harmon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler