rubytree 0.6.0 → 0.6.1
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.
- data/COPYING +2 -2
- data/ChangeLog +17 -1
- data/History.txt +8 -1
- data/README +10 -8
- data/Rakefile +1 -2
- data/lib/tree.rb +11 -5
- data/test/test_tree.rb +22 -14
- metadata +4 -14
data/COPYING
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= RubyTree
|
2
2
|
|
3
3
|
http://rubytree.rubyforge.org
|
4
4
|
|
@@ -26,4 +26,4 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSE
|
|
26
26
|
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
27
27
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
28
|
|
29
|
-
$Id: COPYING
|
29
|
+
$Id: COPYING 163 2010-01-03 19:38:25Z anupamsg $
|
data/ChangeLog
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
2010-01-05 Anupam Sengupta <anupamsg@gmail.com>
|
2
|
+
|
3
|
+
* README: Updated the requirements section.
|
4
|
+
|
5
|
+
* Rakefile: Removed the hard run-time dependency on
|
6
|
+
'structured_warnings' gem. The library will still be used if
|
7
|
+
available on the user's system.
|
8
|
+
|
9
|
+
* test/test_tree.rb: Changed the tests to sync with the
|
10
|
+
soft-dependency on 'structured_warnings'.
|
11
|
+
|
12
|
+
* lib/tree.rb (Tree::TreeNode#depth): Removed the hard
|
13
|
+
dependency on 'structured_warnings' RubyGem. Changed to a soft
|
14
|
+
dependency that degrades well to a standard warning mechanism if
|
15
|
+
the Gem is not available.
|
16
|
+
|
1
17
|
2010-01-03 Anupam Sengupta <anupamsg@gmail.com>
|
2
18
|
|
3
19
|
* lib/tree.rb (Tree::TreeNode#nodeDepth): Added the nodeDepth and
|
@@ -191,4 +207,4 @@
|
|
191
207
|
|
192
208
|
* Changelog: Added the Changelog file.
|
193
209
|
|
194
|
-
$Id: ChangeLog
|
210
|
+
$Id: ChangeLog 164 2010-01-04 19:27:12Z anupamsg $
|
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 0.6.1 / 2010-01-04
|
2
|
+
|
3
|
+
* Changed the hard-dependency on the 'structured_warnings' RubyGem to a soft-dependency - which lets Rubytree still
|
4
|
+
work if this RubyGem is not available. The rationale for this is that we should not require the user to install a
|
5
|
+
separate library just for one single edge-case function (in this case, to indicate a deprecated method). However, if
|
6
|
+
the library _is_ available on the user's system, then it will get used.
|
7
|
+
|
1
8
|
=== 0.6.0 / 2010-01-03
|
2
9
|
|
3
10
|
* Fixed the bug#22535[http://rubyforge.org/tracker/index.php?func=detail&aid=22535&group_id=1215&atid=4793] where the
|
@@ -33,4 +40,4 @@
|
|
33
40
|
|
34
41
|
* Minor code refactoring. Changes in the Rakefile.
|
35
42
|
|
36
|
-
$Id: History.txt
|
43
|
+
$Id: History.txt 164 2010-01-04 19:27:12Z anupamsg $
|
data/README
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
== DESCRIPTION:
|
13
13
|
|
14
|
-
|
14
|
+
RubyTree is a Ruby implementation of the generic Tree data structure. It provides a generic tree data-structure with
|
15
15
|
ability to store keyed node-elements in the tree. This implementation is node-centric, where the individual nodes on
|
16
16
|
the tree are the primary objects and form the leafs of the structure. The implementation mixes in the Enumerable
|
17
17
|
module.
|
@@ -58,15 +58,17 @@ As an example, the following code-snippet implements this tree structure:
|
|
58
58
|
|
59
59
|
* Ruby 1.8+ (http://www.ruby-lang.org)
|
60
60
|
* Hoe (http://seattlerb.rubyforge.org/hoe/Hoe.html) Rubygem
|
61
|
-
|
61
|
+
|
62
|
+
* Optional but recommended:
|
63
|
+
* structured_warnings (http://github.com/schmidt/structured_warnings) Rubygem
|
62
64
|
|
63
65
|
== INSTALL:
|
64
66
|
|
65
|
-
|
67
|
+
RubyTree is an open source project and is hosted at:
|
66
68
|
|
67
69
|
http://rubytree.rubyforge.org
|
68
70
|
|
69
|
-
|
71
|
+
RubyTree can be downloaded as a Rubygem or as a tar/zip file from:
|
70
72
|
|
71
73
|
http://rubyforge.org/frs/?group_id=1215&release_id=8817
|
72
74
|
|
@@ -78,7 +80,7 @@ The file-name is one of:
|
|
78
80
|
|
79
81
|
Download the appropriate file-type for your system.
|
80
82
|
|
81
|
-
It is recommended to install
|
83
|
+
It is recommended to install RubyTree as a Ruby Gem, as this is an easy way to keep the version updated, and keep
|
82
84
|
multiple versions of the library available on your system.
|
83
85
|
|
84
86
|
=== Installing the Gem
|
@@ -87,7 +89,7 @@ To Install the Gem, from a Terminal/CLI command prompt, issue the command:
|
|
87
89
|
|
88
90
|
$ gem install rubytree
|
89
91
|
|
90
|
-
This should install the gem file for
|
92
|
+
This should install the gem file for RubyTree. Note that you may need to be a super-user (root) to successfully install
|
91
93
|
the gem.
|
92
94
|
|
93
95
|
=== Installing from the tgz/zip file
|
@@ -123,7 +125,7 @@ tasks.
|
|
123
125
|
|
124
126
|
== LICENSE:
|
125
127
|
|
126
|
-
|
128
|
+
RubyTree is licensed under the BSD[http://www.opensource.org/licenses/bsd-license.php] license.
|
127
129
|
|
128
130
|
Copyright (c) 2006, 2007 Anupam Sengupta
|
129
131
|
All rights reserved.
|
@@ -149,4 +151,4 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
|
|
149
151
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
150
152
|
|
151
153
|
|
152
|
-
(Document Revision: $Revision:
|
154
|
+
(Document Revision: $Revision: 164 $ by $Author: anupamsg $)
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Rakefile
|
4
4
|
#
|
5
|
-
# $Revision:
|
5
|
+
# $Revision: 164 $ by $Author: anupamsg $ on $Date: 2010-01-05 00:57:12 +0530 (Tue, 05 Jan 2010) $
|
6
6
|
#
|
7
7
|
# Copyright (c) 2006, 2007 Anupam Sengupta
|
8
8
|
#
|
@@ -50,7 +50,6 @@ begin
|
|
50
50
|
self.extra_rdoc_files = ['README', 'COPYING', 'ChangeLog']
|
51
51
|
self.url = "http://rubytree.rubyforge.org"
|
52
52
|
self.readme_file = 'README'
|
53
|
-
self.extra_deps << ['structured_warnings', '>= 0.1.3']
|
54
53
|
# Set the RDoc Options.
|
55
54
|
self.spec_extras[:rdoc_options] = ['--main', 'README', '--line-numbers']
|
56
55
|
self.spec_extras[:has_rdoc] = true
|
data/lib/tree.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# tree.rb
|
2
2
|
#
|
3
|
-
# $Revision:
|
3
|
+
# $Revision: 164 $ by $Author: anupamsg $ on $Date: 2010-01-05 00:57:12 +0530 (Tue, 05 Jan 2010) $
|
4
4
|
#
|
5
5
|
# = tree.rb - Generic Multi-way Tree implementation
|
6
6
|
#
|
@@ -41,15 +41,13 @@
|
|
41
41
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
42
42
|
#
|
43
43
|
|
44
|
-
require 'structured_warnings' # To enable the deprecation of the depth method.
|
45
|
-
|
46
44
|
# This module provides a TreeNode class which is the primary class for all
|
47
45
|
# nodes represented in the Tree.
|
48
46
|
# This module mixes in the Enumerable module.
|
49
47
|
module Tree
|
50
48
|
|
51
49
|
# Rubytree Package Version
|
52
|
-
VERSION = '0.6.
|
50
|
+
VERSION = '0.6.1'
|
53
51
|
|
54
52
|
# == TreeNode Class Description
|
55
53
|
#
|
@@ -492,7 +490,15 @@ module Tree
|
|
492
490
|
# For correct and conventional behavior, please use Tree::TreeNode#nodeDepth and Tree::TreeNode#nodeHeight methods
|
493
491
|
# instead.
|
494
492
|
def depth
|
495
|
-
|
493
|
+
begin
|
494
|
+
require 'structured_warnings' # To enable a nice way of deprecating of the depth method.
|
495
|
+
warn DeprecatedMethodWarning, 'This method is deprecated. Please use nodeDepth() or nodeHeight() instead (bug # 22535)'
|
496
|
+
rescue LoadError
|
497
|
+
# Oh well. Will use the standard Kernel#warn. Behavior will be identical.
|
498
|
+
warn 'Tree::TreeNode#depth() method is deprecated. Please use nodeDepth() or nodeHeight() instead (bug # 22535)'
|
499
|
+
end
|
500
|
+
|
501
|
+
|
496
502
|
return 1 if isLeaf?
|
497
503
|
1 + @children.collect { |child| child.depth }.max
|
498
504
|
end
|
data/test/test_tree.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# testtree.rb
|
4
4
|
#
|
5
|
-
# $Revision:
|
5
|
+
# $Revision: 164 $ by $Author: anupamsg $ on $Date: 2010-01-05 00:57:12 +0530 (Tue, 05 Jan 2010) $
|
6
6
|
#
|
7
7
|
# Copyright (c) 2006, 2007, 2008, 2009, 2010 Anupam Sengupta
|
8
8
|
#
|
@@ -36,7 +36,6 @@
|
|
36
36
|
|
37
37
|
require 'test/unit'
|
38
38
|
require 'tree'
|
39
|
-
require 'structured_warnings'
|
40
39
|
|
41
40
|
module TestTree
|
42
41
|
# Test class for the Tree node.
|
@@ -511,22 +510,31 @@ module TestTree
|
|
511
510
|
# Test the depth computation algorithm. Note that this is an incorrect computation and actually returns height+1
|
512
511
|
# instead of depth. This method has been deprecated in this release and may be removed in the future.
|
513
512
|
def test_depth
|
514
|
-
|
515
|
-
|
513
|
+
begin
|
514
|
+
require 'structured_warnings'
|
515
|
+
assert_warn(DeprecatedMethodWarning) { do_deprecated_depth }
|
516
|
+
rescue LoadError
|
517
|
+
# Since the structued_warnings package is not present, we revert to good old Kernel#warn behavior.
|
518
|
+
do_deprecated_depth
|
519
|
+
end
|
520
|
+
end
|
516
521
|
|
517
|
-
|
518
|
-
|
522
|
+
# Run the assertions for the deprecated depth method.
|
523
|
+
def do_deprecated_depth
|
524
|
+
assert_equal(1, @root.depth, "A single node's depth is 1")
|
525
|
+
|
526
|
+
@root << @child1
|
527
|
+
assert_equal(2, @root.depth, "This should be of depth 2")
|
519
528
|
|
520
|
-
|
521
|
-
|
529
|
+
@root << @child2
|
530
|
+
assert_equal(2, @root.depth, "This should be of depth 2")
|
522
531
|
|
523
|
-
|
524
|
-
|
525
|
-
|
532
|
+
@child2 << @child3
|
533
|
+
assert_equal(3, @root.depth, "This should be of depth 3")
|
534
|
+
assert_equal(2, @child2.depth, "This should be of depth 2")
|
526
535
|
|
527
|
-
|
528
|
-
|
529
|
-
end
|
536
|
+
@child3 << @child4
|
537
|
+
assert_equal(4, @root.depth, "This should be of depth 4")
|
530
538
|
end
|
531
539
|
|
532
540
|
# Test the height computation algorithm
|
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anupam Sengupta
|
@@ -9,19 +9,9 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-05 00:00:00 +05:30
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: structured_warnings
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.1.3
|
24
|
-
version:
|
25
15
|
- !ruby/object:Gem::Dependency
|
26
16
|
name: hoe
|
27
17
|
type: :development
|
@@ -33,7 +23,7 @@ dependencies:
|
|
33
23
|
version: 2.4.0
|
34
24
|
version:
|
35
25
|
description: |-
|
36
|
-
|
26
|
+
RubyTree is a Ruby implementation of the generic Tree data structure. It provides a generic tree data-structure with
|
37
27
|
ability to store keyed node-elements in the tree. This implementation is node-centric, where the individual nodes on
|
38
28
|
the tree are the primary objects and form the leafs of the structure. The implementation mixes in the Enumerable
|
39
29
|
module.
|
@@ -91,7 +81,7 @@ rubyforge_project: rubytree
|
|
91
81
|
rubygems_version: 1.3.5
|
92
82
|
signing_key:
|
93
83
|
specification_version: 3
|
94
|
-
summary:
|
84
|
+
summary: RubyTree is a Ruby implementation of the generic Tree data structure
|
95
85
|
test_files:
|
96
86
|
- test/test_binarytree.rb
|
97
87
|
- test/test_tree.rb
|