tree_graph 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab015d3d94eff12b6296b6e1525c1834aaa93993
4
- data.tar.gz: 2aef11ef5ecc266b6f222b1ac2174d1cf109e1b1
3
+ metadata.gz: e8ea278383e74d9eee8b9ba0af8fd71c6285195e
4
+ data.tar.gz: 2438160903879f555690e1b014ed90ed1973eb1e
5
5
  SHA512:
6
- metadata.gz: 7aa9c7f03dc01db31e7bf558183b3127e222367cee62cadd47107ba43deb6285d9e398f61905c34792a331a3e10c5b97c8ac739530b19b9b5e36911be6344628
7
- data.tar.gz: 94fa4cdc237b6a8ef0f765e158d09c1784c643506f9abb07c4fd2ad7de63da96fdb28e31b957d3e1a47124f46f485e66f65b148cc197c325b594419bf3f230f0
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 `tree_graph_bottom_up` on that Node object.
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
 
@@ -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
- raw_node.children_for_tree_graph.each do |c|
25
- children << self.class.new(c, self)
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
- return children if children.empty?
28
- children.last.is_last = true
29
- children
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
@@ -1,3 +1,3 @@
1
1
  module TreeGraph
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-28 00:00:00.000000000 Z
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler