tree_graph 0.2.1 → 0.2.2
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/README.md +1 -1
- data/lib/tree_graph.rb +18 -6
- data/lib/tree_graph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8ea278383e74d9eee8b9ba0af8fd71c6285195e
|
4
|
+
data.tar.gz: 2438160903879f555690e1b014ed90ed1973eb1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6878272b7f685894423acaa61669f19764b2d19ea839a285862c469ff96a7cfa81182736efe51103268c853440cdae4172f7b7d61d86219baaa02512086c7244
|
7
|
+
data.tar.gz: c5dd31ce5378959315c04ae121a04b95e6b92bb7cb3b6f0bd3ebbbe7334bf779b6c43162a34589fd379ffae7eb26a9b0bdb8ceef2e137572fc61de36c4d7fd6e
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
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` and `
|
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
25
|
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
26
|
|
data/lib/tree_graph.rb
CHANGED
@@ -10,6 +10,10 @@ module TreeGraph
|
|
10
10
|
BottomUp.new(self).tree_graph
|
11
11
|
end
|
12
12
|
|
13
|
+
def tree_graph_bottom_up_in_same_order
|
14
|
+
BottomUpInSameOrder.new(self).tree_graph
|
15
|
+
end
|
16
|
+
|
13
17
|
module Node
|
14
18
|
|
15
19
|
attr_accessor :is_last
|
@@ -20,13 +24,15 @@ module TreeGraph
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def children_nodes
|
23
|
-
children
|
24
|
-
|
25
|
-
|
27
|
+
children.map do |c|
|
28
|
+
self.class.new(c, self)
|
29
|
+
end.tap do |nodes|
|
30
|
+
nodes.last.is_last = true unless nodes.empty?
|
26
31
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
def children
|
35
|
+
raw_node.children_for_tree_graph
|
30
36
|
end
|
31
37
|
|
32
38
|
def level
|
@@ -79,4 +85,10 @@ module TreeGraph
|
|
79
85
|
is_last ? '┌─' : '├─'
|
80
86
|
end
|
81
87
|
end
|
88
|
+
|
89
|
+
class BottomUpInSameOrder < BottomUp
|
90
|
+
def children
|
91
|
+
super.reverse
|
92
|
+
end
|
93
|
+
end
|
82
94
|
end
|
data/lib/tree_graph/version.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|