rubytree 0.9.5pre4 → 0.9.5pre5
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 +8 -0
- data/Gemfile.lock +2 -2
- data/History.rdoc +7 -0
- data/TODO.org +3 -0
- data/lib/tree.rb +9 -1
- data/lib/tree/version.rb +2 -2
- data/test/test_tree.rb +28 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850e06171da2b8d2ce18e1c2a753940720fa995f
|
4
|
+
data.tar.gz: d135be3794997cded9a37f969270e007878371b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4a868546b8c5e32d216ac7ea5614bff5edd440ce6ef9927b210962f1aa5690afe8b36e797d0a077db4a955b6e42485b0dd3a8da45e52fbbbba9fc1bb4e7c271
|
7
|
+
data.tar.gz: d4f1e908972b00e23a7d93722e7cd32c7b40750bbfc8604cd527764dc8fb84d0e7cff42aa29e25041ca49b39cc738a4fdfcb907f487d79a575efd4415e8cf9a7
|
data/API-CHANGES.rdoc
CHANGED
@@ -9,6 +9,14 @@ Note: API level changes are expected to reduce dramatically after the 1.x
|
|
9
9
|
release. In most cases, an alternative will be provided to ensure relatively
|
10
10
|
smooth transition to the new APIs.
|
11
11
|
|
12
|
+
== Release 0.9.5 Changes
|
13
|
+
|
14
|
+
- The {Tree::TreeNode#add} method now provides 'move' semantics, if a child
|
15
|
+
which is on an existing tree is added to another tree, or location on the same
|
16
|
+
tree. In this situation, the child node is removed from its old position, and
|
17
|
+
added to the new parent node. After the add operation is complete, the child
|
18
|
+
no longer exists on the old tree/location.
|
19
|
+
|
12
20
|
== Release 0.9.3 Changes
|
13
21
|
|
14
22
|
- The validation for unique node names has changed in the {Tree::TreeNode#add}
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubytree (0.9.
|
4
|
+
rubytree (0.9.5pre5)
|
5
5
|
json (~> 1.8)
|
6
6
|
structured_warnings (~> 0.1)
|
7
7
|
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
json (~> 1.4)
|
24
24
|
rest-client (1.6.7)
|
25
25
|
mime-types (>= 1.16)
|
26
|
-
rtags (0.
|
26
|
+
rtags (0.97)
|
27
27
|
rtagstask (0.0.4)
|
28
28
|
rtags (> 0.0.0)
|
29
29
|
simplecov (0.9.1)
|
data/History.rdoc
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
= History of Changes
|
4
4
|
|
5
|
+
=== 0.9.5pre5 / 2015-01-01
|
6
|
+
|
7
|
+
* Fixed {issue 32}{https://github.com/evolve75/RubyTree/issues/32} and enabled
|
8
|
+
'move' semantics on the {Tree::TreeNode#add} method, so that a child being
|
9
|
+
added, that has an existing parent, will be removed from its old parent, prior
|
10
|
+
to being added to the new location.
|
11
|
+
|
5
12
|
=== 0.9.5pre4 / 2014-12-17
|
6
13
|
|
7
14
|
* Added performance improvements to {Tree::TreeNode#is_root?} and
|
data/TODO.org
CHANGED
@@ -187,6 +187,8 @@
|
|
187
187
|
|
188
188
|
|
189
189
|
* R0.9.5
|
190
|
+
** DONE Fix [[Issue:32][Issue #32]] and enable move semantics on the TreeNode#add method. :ARCHIVE:
|
191
|
+
CLOSED: [2015-01-01 Thu 16:05]
|
190
192
|
** DONE Check the lazy initialization of =@node_depth= and changes in parent nodes :ARCHIVE:
|
191
193
|
CLOSED: [2014-12-18 Thu 11:05]
|
192
194
|
** DONE Pull the performance improvements from Aidan [[Pull:37][#37]] :ARCHIVE:
|
@@ -235,6 +237,7 @@
|
|
235
237
|
restructure the internals to make better use of memory.
|
236
238
|
** STARTED Convert all documentation to markdown mode.
|
237
239
|
** TODO Expand the examples section, and add supporting documentation
|
240
|
+
|
238
241
|
* Unplanned / Not assigned to any release
|
239
242
|
*** DONE [#A] Migrate the website and references from http://rubyforge.org/ :ARCHIVE:
|
240
243
|
CLOSED: [2014-07-04 Fri 22:18]
|
data/lib/tree.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
# Author:: Anupam Sengupta (anupamsg@gmail.com)
|
10
10
|
#
|
11
11
|
|
12
|
-
# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Anupam Sengupta
|
12
|
+
# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Anupam Sengupta
|
13
13
|
#
|
14
14
|
# All rights reserved.
|
15
15
|
#
|
@@ -347,6 +347,12 @@ module Tree
|
|
347
347
|
#
|
348
348
|
# This is to prevent +nil+ nodes being created as children if a non-existant position is used.
|
349
349
|
#
|
350
|
+
# If the new node being added has an existing parent node, then it will be
|
351
|
+
# removed from this pre-existing parent prior to being added as a child to
|
352
|
+
# this node. I.e., the child node will effectively be moved from its old
|
353
|
+
# parent to this node. In this situation, after the operation is complete,
|
354
|
+
# the node will no longer exist as a child for its old parent.
|
355
|
+
#
|
350
356
|
# @param [Tree::TreeNode] child The child node to add.
|
351
357
|
# @param [optional, Number] at_index The optional position where the node is to be inserted.
|
352
358
|
#
|
@@ -365,6 +371,8 @@ module Tree
|
|
365
371
|
# Lazy mans unique test, won't test if children of child are unique in this tree too.
|
366
372
|
raise "Child #{child.name} already added!" if @children_hash.include?(child.name)
|
367
373
|
|
374
|
+
child.parent.remove! child if child.parent # Detach from the old parent
|
375
|
+
|
368
376
|
if insertion_range.include?(at_index)
|
369
377
|
@children.insert(at_index, child)
|
370
378
|
else
|
data/lib/tree/version.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Author:: Anupam Sengupta (anupamsg@gmail.com)
|
6
6
|
#
|
7
|
-
# Copyright (c) 2012, 2013, 2014 Anupam Sengupta
|
7
|
+
# Copyright (c) 2012, 2013, 2014, 2015 Anupam Sengupta
|
8
8
|
#
|
9
9
|
# All rights reserved.
|
10
10
|
#
|
@@ -37,5 +37,5 @@
|
|
37
37
|
#
|
38
38
|
module Tree
|
39
39
|
# Rubytree Package Version
|
40
|
-
VERSION = '0.9.
|
40
|
+
VERSION = '0.9.5pre5'
|
41
41
|
end
|
data/test/test_tree.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# test_tree.rb - This file is part of the RubyTree package.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Anupam Sengupta
|
5
|
+
# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Anupam Sengupta
|
6
6
|
#
|
7
7
|
# All rights reserved.
|
8
8
|
#
|
@@ -512,6 +512,7 @@ module TestTree
|
|
512
512
|
|
513
513
|
# Test the addition of a nil node.
|
514
514
|
assert_raise(ArgumentError) { @root.add(nil) }
|
515
|
+
|
515
516
|
end
|
516
517
|
|
517
518
|
# Test the addition of a duplicate node (duplicate being defined as a node with the same name).
|
@@ -1615,28 +1616,45 @@ module TestTree
|
|
1615
1616
|
root_node = Tree::TreeNode.new("OLDROOT")
|
1616
1617
|
|
1617
1618
|
child_node = Tree::TreeNode.new("CHILD")
|
1618
|
-
assert_equal(child_node.node_depth
|
1619
|
+
assert_equal(0, child_node.node_depth)
|
1619
1620
|
|
1620
1621
|
root_node << child_node
|
1621
1622
|
assert_equal(root_node["CHILD"].name, "CHILD")
|
1622
|
-
assert_equal(root_node.node_depth
|
1623
|
-
assert_equal(child_node.node_depth
|
1623
|
+
assert_equal(0, root_node.node_depth)
|
1624
|
+
assert_equal(1, child_node.node_depth)
|
1624
1625
|
|
1625
1626
|
grandchild_node = Tree::TreeNode.new("GRANDCHILD")
|
1626
1627
|
child_node << grandchild_node
|
1627
1628
|
assert_equal(root_node["CHILD"]["GRANDCHILD"].name, "GRANDCHILD")
|
1628
|
-
assert_equal(root_node.node_depth
|
1629
|
-
assert_equal(child_node.node_depth
|
1630
|
-
assert_equal(grandchild_node.node_depth
|
1629
|
+
assert_equal(0, root_node.node_depth)
|
1630
|
+
assert_equal(1, child_node.node_depth)
|
1631
|
+
assert_equal(2, grandchild_node.node_depth)
|
1631
1632
|
|
1632
1633
|
root2_node = Tree::TreeNode.new("NEWROOT")
|
1633
|
-
assert_equal(root2_node.node_depth
|
1634
|
+
assert_equal(0, root2_node.node_depth)
|
1634
1635
|
|
1635
1636
|
# Move the grand child to a new root.
|
1636
1637
|
root2_node << grandchild_node
|
1637
1638
|
assert_equal(root2_node["GRANDCHILD"].name, "GRANDCHILD")
|
1638
|
-
assert_equal(grandchild_node.parent
|
1639
|
-
assert_equal(grandchild_node.node_depth
|
1639
|
+
assert_equal(root2_node, grandchild_node.parent)
|
1640
|
+
assert_equal(1, grandchild_node.node_depth)
|
1641
|
+
|
1642
|
+
# Test the move semantics for addition of an existing child node
|
1643
|
+
root1 = Tree::TreeNode.new("1")
|
1644
|
+
root1 << Tree::TreeNode.new("2") << Tree::TreeNode.new("4")
|
1645
|
+
root1 << Tree::TreeNode.new("3") << Tree::TreeNode.new("5")
|
1646
|
+
root1["3"] << Tree::TreeNode.new("6")
|
1647
|
+
assert_equal(root1["3"]["6"].name, "6")
|
1648
|
+
|
1649
|
+
# Create a new tree
|
1650
|
+
root2 = root1.dup
|
1651
|
+
assert_equal(root1, root2)
|
1652
|
+
assert_not_same(root1, root2)
|
1653
|
+
|
1654
|
+
# Now 'move' the "4" node to the new tree. This should have 'dup' semantics.
|
1655
|
+
root2["3"] << root1["2"]["4"]
|
1656
|
+
assert_equal("3", root2["3"]["4"].parent.name) # This is on the new tree
|
1657
|
+
assert_nil(root1["2"]["4"]) # This is on the old tree
|
1640
1658
|
|
1641
1659
|
end
|
1642
1660
|
end
|