tree_graph 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e8ea278383e74d9eee8b9ba0af8fd71c6285195e
4
- data.tar.gz: 2438160903879f555690e1b014ed90ed1973eb1e
2
+ SHA256:
3
+ metadata.gz: b955eb6cbbadd1046da5a1b57d0e309e1409a7383a0f1eb139a4d9a8796c2a1c
4
+ data.tar.gz: e597fd6a7e69411b2da4a59314fca704f3c19ecffe35b58c51b4c73c1db19a9e
5
5
  SHA512:
6
- metadata.gz: 6878272b7f685894423acaa61669f19764b2d19ea839a285862c469ff96a7cfa81182736efe51103268c853440cdae4172f7b7d61d86219baaa02512086c7244
7
- data.tar.gz: c5dd31ce5378959315c04ae121a04b95e6b92bb7cb3b6f0bd3ebbbe7334bf779b6c43162a34589fd379ffae7eb26a9b0bdb8ceef2e137572fc61de36c4d7fd6e
6
+ metadata.gz: ea5e1e665570c6cb644024ea8b763733c601d844c3afc42ce514ff464cf4222716cfb2e7b065b241885e0b308dfedcb1a29e447be5b057a151dbe18c6e5e2ba5
7
+ data.tar.gz: 3ce2e2b287dc19265f2fcc14358fc0dd5925864a6f0141148a471a435e2641457c39fc4457b8dbc56b9055e11454fa4346b2fdb86495db98a119a0674866a627
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  *.swp
11
11
  *.gem
12
+ .tool-versions
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).
@@ -1,3 +1,3 @@
1
1
  module TreeGraph
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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 [] unless parent
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.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: 2017-04-29 00:00:00.000000000 Z
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
- rubyforge_project:
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