tree_graph 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/README.md +2 -0
- data/lib/tree_graph/version.rb +1 -1
- data/lib/tree_graph.rb +13 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b955eb6cbbadd1046da5a1b57d0e309e1409a7383a0f1eb139a4d9a8796c2a1c
|
4
|
+
data.tar.gz: e597fd6a7e69411b2da4a59314fca704f3c19ecffe35b58c51b4c73c1db19a9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea5e1e665570c6cb644024ea8b763733c601d844c3afc42ce514ff464cf4222716cfb2e7b065b241885e0b308dfedcb1a29e447be5b057a151dbe18c6e5e2ba5
|
7
|
+
data.tar.gz: 3ce2e2b287dc19265f2fcc14358fc0dd5925864a6f0141148a471a435e2641457c39fc4457b8dbc56b9055e11454fa4346b2fdb86495db98a119a0674866a627
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
In Node class, `include TreeGraph`, then implement two methods, `label_for_tree_graph` and `children_for_tree_graph`(which return thing responds to `each`). Then you can call `tree_graph`, `tree_graph_bottom_up` and `tree_graph_bottom_up_in_same_order` on that Node object.
|
24
24
|
|
25
|
+
By default, `::Object#label_for_tree_graph` call `to_s`, and `::Object#children_for_tree_graph` return empty array.
|
26
|
+
|
25
27
|
Or checkout [test/tree_graph_test.rb](https://github.com/turnon/tree_graph/blob/master/test/tree_graph_test.rb) to see how to use.
|
26
28
|
|
27
29
|
Gems depending on tree_graph: [constree](https://github.com/turnon/constree), [trace_tree](https://github.com/turnon/trace_tree).
|
data/lib/tree_graph/version.rb
CHANGED
data/lib/tree_graph.rb
CHANGED
@@ -14,6 +14,18 @@ module TreeGraph
|
|
14
14
|
BottomUpInSameOrder.new(self).tree_graph
|
15
15
|
end
|
16
16
|
|
17
|
+
EMPTY_ARRAY = []
|
18
|
+
|
19
|
+
class ::Object
|
20
|
+
def label_for_tree_graph
|
21
|
+
to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def children_for_tree_graph
|
25
|
+
EMPTY_ARRAY
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
17
29
|
module Node
|
18
30
|
|
19
31
|
attr_accessor :is_last
|
@@ -44,7 +56,7 @@ module TreeGraph
|
|
44
56
|
end
|
45
57
|
|
46
58
|
def ancestors
|
47
|
-
return
|
59
|
+
return EMPTY_ARRAY unless parent
|
48
60
|
parent.ancestors + [parent]
|
49
61
|
end
|
50
62
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tree_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
|
93
|
-
rubygems_version: 2.6.8
|
92
|
+
rubygems_version: 3.1.6
|
94
93
|
signing_key:
|
95
94
|
specification_version: 4
|
96
95
|
summary: A mixin to help you generate tree graph
|