hierarchy-tree 0.3.2 → 0.3.3
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/lib/hierarchy_tree.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c49580e82d4958c3aac779b9d6bc474db3f458312a56ae56f9340e5dd775544
|
4
|
+
data.tar.gz: 706e5c3ffa57ae961aa0c571a2c0db16688baba490a3408f7a65023a9f84e101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0916dff1eeca02e53a6be930ca62f55e52d4d717a057a9bd892a9297134354a86e2b2b1c9a8b5a2c5daf8d7e990bd17586dc0a7170d82c98a9e4bcfdf21a84bb'
|
7
|
+
data.tar.gz: fe0c0bb82cf73cb06873290335b1d25c463d0fddafe4a6737e474941d87745accf3d8b568b35dbac9a97cef4bd1f3bfa4727ac2ba5b7a3e917450c79fb07df64
|
data/lib/hierarchy_tree.rb
CHANGED
@@ -3,9 +3,9 @@ require 'active_support/core_ext/object/inclusion.rb'
|
|
3
3
|
|
4
4
|
################ Debug ################
|
5
5
|
# gem cleanup hierarchy-tree
|
6
|
-
# rm hierarchy-tree-
|
6
|
+
# rm hierarchy-tree-0.3.2.gem
|
7
7
|
# gem build hierarchy_tree
|
8
|
-
# gem install hierarchy-tree-
|
8
|
+
# gem install hierarchy-tree-0.3.3.gem
|
9
9
|
# ruby -Itest test/test_hierarchy_tree.rb
|
10
10
|
|
11
11
|
class Hierarchy
|
@@ -46,7 +46,7 @@ class Hierarchy
|
|
46
46
|
|
47
47
|
paths << hashify(next_path) if next_class == to.to_s
|
48
48
|
|
49
|
-
if
|
49
|
+
if non_looped_path?(from, to, relation, next_path)
|
50
50
|
visited[next_class] = next_path
|
51
51
|
queue.push({ class: next_class, path: next_path })
|
52
52
|
end
|
@@ -189,6 +189,12 @@ class Hierarchy
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
def self.non_looped_path?(from, to, relation, next_path)
|
193
|
+
relation.class_name != from.name and
|
194
|
+
relation.class_name != to.name and
|
195
|
+
next_path == next_path.uniq
|
196
|
+
end
|
197
|
+
|
192
198
|
def self.valid_path?(path, target)
|
193
199
|
return true if path == target
|
194
200
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hierarchy-tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Cordeiro Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|