hierarchy-tree 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hierarchy_tree.rb +9 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6644c370fbd994c645135ec56cd7aa19c6586cf7da38136e929b1bac2edd0ddf
4
- data.tar.gz: 938f28a4313baa9ba0dabfdbfed06dd32022fbf79177b2bbdf537233593d15ee
3
+ metadata.gz: 9c49580e82d4958c3aac779b9d6bc474db3f458312a56ae56f9340e5dd775544
4
+ data.tar.gz: 706e5c3ffa57ae961aa0c571a2c0db16688baba490a3408f7a65023a9f84e101
5
5
  SHA512:
6
- metadata.gz: 4e3f81dad78bfb864c73153cdebfb2ad3978f1caa70ad2996c2125ce7d88fd2ecf4a362e6c2920877f7e23cfe129f51055f0f945e647392c8f66d69ac3b5c67e
7
- data.tar.gz: 790d3534a9798da8fea30a5d44252e57f6d5f00f3fbdac7700502a3c2860a2427e9b97594a926c32cab800eaa3b2d86df8107ab5d675fcb48bd3274ed330bf4c
6
+ metadata.gz: '0916dff1eeca02e53a6be930ca62f55e52d4d717a057a9bd892a9297134354a86e2b2b1c9a8b5a2c5daf8d7e990bd17586dc0a7170d82c98a9e4bcfdf21a84bb'
7
+ data.tar.gz: fe0c0bb82cf73cb06873290335b1d25c463d0fddafe4a6737e474941d87745accf3d8b568b35dbac9a97cef4bd1f3bfa4727ac2ba5b7a3e917450c79fb07df64
@@ -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-0.3.1.gem
6
+ # rm hierarchy-tree-0.3.2.gem
7
7
  # gem build hierarchy_tree
8
- # gem install hierarchy-tree-0.3.1.gem
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 next_path == next_path.uniq # Non-looped path
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.1
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-25 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest