dependency-trees 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependency-trees.gemspec +1 -1
- data/lib/dependency_tree.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9473e445def6dc4b9761b4bd489e5cb5f88eb09479a3d2a7d4a8f8aee17adb
|
4
|
+
data.tar.gz: e791b23401582dfc3e055df4bb80788f13d0f993df0fe4b4598b188b15b35802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f9e22ab9c93adbc25b0f3a6cacc980bd6d48c7e27b4f0832d80c9a1c01b438d27ac25b446cd8343c4631544e331b8fb7315cbf94fa8522e1fcd07a5216e703
|
7
|
+
data.tar.gz: 2beac964d33a438684f0f594a5199969f20f617d27e39193c185d42d0b8105c879635bfa28f59443396f3b7217329fb12f591af7b76bd9c2d204e048b11c929c
|
data/dependency-trees.gemspec
CHANGED
data/lib/dependency_tree.rb
CHANGED
@@ -34,8 +34,8 @@ module DependencyTree
|
|
34
34
|
next unless array.class == Array
|
35
35
|
|
36
36
|
new_array = array.map do |subtree|
|
37
|
-
next subtree.
|
38
|
-
next subtree if subtree.class != Tree || subtree.size >
|
37
|
+
next subtree.root_referenced_earlier_summary if subtree[:referenced_earlier]
|
38
|
+
next subtree if subtree.class != Tree || subtree.size > 3
|
39
39
|
|
40
40
|
subtree.root_summary
|
41
41
|
end
|
@@ -65,8 +65,8 @@ module DependencyTree
|
|
65
65
|
"#{self[:class]}, id #{self[:id]}, #{self[:status]}"
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
69
|
-
root_summary + ",
|
68
|
+
def root_referenced_earlier_summary
|
69
|
+
root_summary + ", referenced_earlier"
|
70
70
|
end
|
71
71
|
|
72
72
|
def deep_tree_clone
|
@@ -113,14 +113,14 @@ module DependencyTree
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def dependency_tree(depth = Float::INFINITY, hash_for_duplication_check = IdHash.new)
|
116
|
-
|
116
|
+
is_referenced_earlier = hash_for_duplication_check[self.class]&.include?(id)
|
117
117
|
hash_for_duplication_check.add(self.class, id)
|
118
|
-
shoud_go_deeper = depth > 0 && !
|
118
|
+
shoud_go_deeper = depth > 0 && !is_referenced_earlier
|
119
119
|
result = shoud_go_deeper ? get_associations_for_tree(depth, hash_for_duplication_check) : Tree.new
|
120
120
|
result[:id] = id
|
121
121
|
result[:instance] = self
|
122
122
|
result[:class] = self.class.to_s.underscore
|
123
|
-
result[:
|
123
|
+
result[:referenced_earlier] = true if is_referenced_earlier
|
124
124
|
result
|
125
125
|
end
|
126
126
|
|