rubytree 0.9.5pre6 → 0.9.5pre7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/API-CHANGES.rdoc +11 -11
- data/Gemfile.lock +36 -24
- data/History.rdoc +46 -28
- data/LICENSE.md +1 -1
- data/README.md +31 -21
- data/Rakefile +11 -11
- data/TODO.org +2 -0
- data/gem_graph.png +0 -0
- data/lib/rubytree.rb +13 -13
- data/lib/tree.rb +127 -75
- data/lib/tree/binarytree.rb +48 -31
- data/lib/tree/tree_deps.rb +15 -14
- data/lib/tree/utils/camel_case_method_handler.rb +16 -15
- data/lib/tree/utils/hash_converter.rb +35 -21
- data/lib/tree/utils/json_converter.rb +18 -16
- data/lib/tree/utils/metrics_methods.rb +33 -24
- data/lib/tree/utils/path_methods.rb +92 -0
- data/lib/tree/utils/tree_merge_handler.rb +34 -23
- data/lib/tree/utils/utils.rb +14 -14
- data/lib/tree/version.rb +13 -13
- data/rubytree.gemspec +88 -0
- data/setup.rb +1585 -0
- data/test/test_subclassed_node.rb +5 -0
- data/test/test_tree.rb +73 -0
- metadata +8 -4
data/test/test_tree.rb
CHANGED
@@ -1018,6 +1018,9 @@ module TestTree
|
|
1018
1018
|
end
|
1019
1019
|
|
1020
1020
|
assert_equal(2, @child4.node_depth, "Child 4 should have depth 2")
|
1021
|
+
|
1022
|
+
@root << @child5 << @child3
|
1023
|
+
assert_equal(3, @child4.node_depth, "Child 4 should have depth 3 after Child 5 inserted above")
|
1021
1024
|
end
|
1022
1025
|
|
1023
1026
|
# Test the level method. Since this is an alias of node_depth, we just test for equivalence
|
@@ -1657,6 +1660,76 @@ module TestTree
|
|
1657
1660
|
assert_nil(root1["2"]["4"]) # This is on the old tree
|
1658
1661
|
|
1659
1662
|
end
|
1663
|
+
|
1664
|
+
# Test the path_as_string method.
|
1665
|
+
def test_path_as_string
|
1666
|
+
j = Tree::TreeNode.new("j")
|
1667
|
+
f = Tree::TreeNode.new("f")
|
1668
|
+
k = Tree::TreeNode.new("k")
|
1669
|
+
a = Tree::TreeNode.new("a")
|
1670
|
+
d = Tree::TreeNode.new("d")
|
1671
|
+
h = Tree::TreeNode.new("h")
|
1672
|
+
z = Tree::TreeNode.new("z")
|
1673
|
+
p = Tree::TreeNode.new("p")
|
1674
|
+
t = Tree::TreeNode.new("t")
|
1675
|
+
e = Tree::TreeNode.new("e")
|
1676
|
+
|
1677
|
+
# Create the following Tree
|
1678
|
+
# j <-- level 0 (Root)
|
1679
|
+
# / \
|
1680
|
+
# f k <-- level 1
|
1681
|
+
# / \ \
|
1682
|
+
# a h z <-- level 2
|
1683
|
+
# \ / \
|
1684
|
+
# d p t <-- level 3
|
1685
|
+
# /
|
1686
|
+
# e <-- level 4
|
1687
|
+
j << f << a << d << e
|
1688
|
+
f << h
|
1689
|
+
h << p
|
1690
|
+
h << t
|
1691
|
+
j << k << z
|
1692
|
+
|
1693
|
+
assert_equal(t.path_as_string(), 'j=>f=>h=>t') # Check the default sep.
|
1694
|
+
|
1695
|
+
assert_equal(t.path_as_string(' => '), 'j => f => h => t')
|
1696
|
+
assert_equal(z.path_as_string(' => '), 'j => k => z')
|
1697
|
+
assert_equal(a.path_as_string(' => '), 'j => f => a')
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
# Test the path_as_array method.
|
1701
|
+
def test_path_as_array
|
1702
|
+
j = Tree::TreeNode.new("j")
|
1703
|
+
f = Tree::TreeNode.new("f")
|
1704
|
+
k = Tree::TreeNode.new("k")
|
1705
|
+
a = Tree::TreeNode.new("a")
|
1706
|
+
d = Tree::TreeNode.new("d")
|
1707
|
+
h = Tree::TreeNode.new("h")
|
1708
|
+
z = Tree::TreeNode.new("z")
|
1709
|
+
p = Tree::TreeNode.new("p")
|
1710
|
+
t = Tree::TreeNode.new("t")
|
1711
|
+
e = Tree::TreeNode.new("e")
|
1712
|
+
|
1713
|
+
# Create the following Tree
|
1714
|
+
# j <-- level 0 (Root)
|
1715
|
+
# / \
|
1716
|
+
# f k <-- level 1
|
1717
|
+
# / \ \
|
1718
|
+
# a h z <-- level 2
|
1719
|
+
# \ / \
|
1720
|
+
# d p t <-- level 3
|
1721
|
+
# /
|
1722
|
+
# e <-- level 4
|
1723
|
+
j << f << a << d << e
|
1724
|
+
f << h
|
1725
|
+
h << p
|
1726
|
+
h << t
|
1727
|
+
j << k << z
|
1728
|
+
|
1729
|
+
assert_equal(e.path_as_array, ['j', 'f', 'a', 'd', 'e'])
|
1730
|
+
assert_equal(p.path_as_array, ['j', 'f' , 'h', 'p'])
|
1731
|
+
assert_equal(k.path_as_array, ['j', 'k'])
|
1732
|
+
end
|
1660
1733
|
end
|
1661
1734
|
end
|
1662
1735
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubytree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5pre7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anupam Sengupta
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- TAGS
|
140
140
|
- TODO.org
|
141
141
|
- examples/example_basic.rb
|
142
|
+
- gem_graph.png
|
142
143
|
- lib/rubytree.rb
|
143
144
|
- lib/tree.rb
|
144
145
|
- lib/tree/binarytree.rb
|
@@ -147,9 +148,12 @@ files:
|
|
147
148
|
- lib/tree/utils/hash_converter.rb
|
148
149
|
- lib/tree/utils/json_converter.rb
|
149
150
|
- lib/tree/utils/metrics_methods.rb
|
151
|
+
- lib/tree/utils/path_methods.rb
|
150
152
|
- lib/tree/utils/tree_merge_handler.rb
|
151
153
|
- lib/tree/utils/utils.rb
|
152
154
|
- lib/tree/version.rb
|
155
|
+
- rubytree.gemspec
|
156
|
+
- setup.rb
|
153
157
|
- test/run_test.rb
|
154
158
|
- test/test_binarytree.rb
|
155
159
|
- test/test_rubytree_require.rb
|
@@ -186,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
190
|
version: 1.3.1
|
187
191
|
requirements: []
|
188
192
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.4.
|
193
|
+
rubygems_version: 2.4.6
|
190
194
|
signing_key:
|
191
195
|
specification_version: 4
|
192
196
|
summary: A generic tree data structure.
|