hierarchy-tree 0.3.2 → 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: 3d4301de42dc78d8664798e551f846073a2bd7a79a2f5d5245d5c9e9339145c4
4
- data.tar.gz: 73f7863eb9059605923a62c27dcc4baa3193509d5c0240f178e33f185e10df2a
3
+ metadata.gz: 9c49580e82d4958c3aac779b9d6bc474db3f458312a56ae56f9340e5dd775544
4
+ data.tar.gz: 706e5c3ffa57ae961aa0c571a2c0db16688baba490a3408f7a65023a9f84e101
5
5
  SHA512:
6
- metadata.gz: 1567fd7d03e5e87ba9b8efe378a9ec15361352e9631229fa75b547905c762999d7315f4749841594aa2e1bd306a81f133d742f581fb76aa7dbe8523cf23754da
7
- data.tar.gz: e371543dcc4e11f0946595218da4beaf1bb792b596988d16b417c5441d00f5d4e0492f2f740acaae869e83bd336c8a27de57161c86e7e448a56c28461b3f6070
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-X.Y.Z.gem
6
+ # rm hierarchy-tree-0.3.2.gem
7
7
  # gem build hierarchy_tree
8
- # gem install hierarchy-tree-X.Y.Z.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 relation.class_name != from.name and 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.2
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