rubytree 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (9) hide show
  1. data/ChangeLog +21 -0
  2. data/LICENSE +31 -0
  3. data/README +136 -2
  4. data/Rakefile +40 -5
  5. data/TAGS +66 -0
  6. data/lib/tree.rb +70 -18
  7. data/test/person.rb +36 -2
  8. data/test/testtree.rb +33 -0
  9. metadata +9 -4
data/ChangeLog ADDED
@@ -0,0 +1,21 @@
1
+ 2007-06-23 Anupam Sengupta <anupamsg@gmail.com>
2
+
3
+ * Rakefile: Added the LICENSE and ChangeLog to the extra RDoc files.
4
+
5
+ * lib/tree.rb: Minor updates to the comments.
6
+
7
+ * test/testtree.rb: Added the Copyright and License header.
8
+
9
+ * test/person.rb: Added the Copyright and License header.
10
+
11
+ * lib/tree.rb: Added the Copyright and License header.
12
+
13
+ * Rakefile: Added the LICENSE and Changelog to be part of the RDoc task.
14
+
15
+ * README: Added documentation in the README, including install
16
+ instructions and an example.
17
+
18
+ * LICENSE: Added the BSD LICENSE file.
19
+
20
+ * Changelog: Added the Changelog file.
21
+
data/LICENSE ADDED
@@ -0,0 +1,31 @@
1
+ RUBYTREE - http://rubytree.rubyforge.org
2
+ ========================================
3
+
4
+ Copyright (c) 2007, Anupam Sengupta
5
+
6
+ All rights reserved.
7
+
8
+ Redistribution and use in source and binary forms, with or without modification,
9
+ are permitted provided that the following conditions are met:
10
+
11
+ - Redistributions of source code must retain the above copyright notice, this
12
+ list of conditions and the following disclaimer.
13
+
14
+ - Redistributions in binary form must reproduce the above copyright notice, this
15
+ list of conditions and the following disclaimer in the documentation and/or
16
+ other materials provided with the distribution.
17
+
18
+ - Neither the name of the organization nor the names of its contributors may
19
+ be used to endorse or promote products derived from this software without
20
+ specific prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README CHANGED
@@ -1,6 +1,140 @@
1
- = Tree Implementation
1
+ = RubyTree
2
2
 
3
+ (c) 2006, 2007 Anupam Sengupta
4
+ http://rubytree.rubyforge.org
3
5
 
4
- Hello
6
+ Document Revision: $Revision: 1.4 $
7
+
8
+ == License
9
+
10
+ RubyTree has been released under the BSD License. See the file LICENSE for
11
+ details.
5
12
 
6
13
  == Introduction
14
+
15
+ RubyTree is a simple implementation of the generic Tree data structure. This
16
+ implementation is node-centric, where the individual nodes on the tree are the
17
+ primary objects and drive the structure.
18
+
19
+ == Getting RubyTree
20
+
21
+ RubyTree is an open source project and is hosted at
22
+ http://rubyforge.org/projects/rubytree
23
+
24
+ The project home page is: http://rubytree.rubyforge.org
25
+
26
+ RubyTree can be downloaded as a Ruby Gem or as a tar/zip file from:
27
+
28
+ http://rubyforge.org/frs/?group_id=1215&release_id=8817
29
+
30
+ The file name is one of:
31
+
32
+ rubytree-<VERSION>.gem
33
+ rubytree-<VERSION>.tgz
34
+ rubytree-<VERSION>.zip
35
+
36
+ Download the appropriate file-type.
37
+
38
+ == Installing RubyTree
39
+
40
+ It is recommended to install RubyTree as a Ruby Gem, as this is an easy way to
41
+ keep the version updated, and keep multiple versions of the library available on
42
+ your system.
43
+
44
+ === Installing the Gem
45
+ To Install the Gem, from a Terminal/CLI command prompt, issue the command:
46
+
47
+ gem install rubytree
48
+
49
+ This should install the gem file for RubyTree. Note that you may need to be a
50
+ super-user (root) to successfully install the gem.
51
+
52
+ === Installing from the tgz/zip file
53
+
54
+ Extract the archive file (tgz or zip) and run the 'rake' command from the
55
+ top-level source directory.
56
+
57
+ == Documentation
58
+
59
+ The primary class for this implementation is Tree::TreeNode. See the
60
+ class documentation for an usage example.
61
+
62
+ From a command line/terminal prompt, you can issue the following command to view
63
+ the text mode ri documentation:
64
+
65
+ ri Tree::TreeNode
66
+
67
+ == Example
68
+
69
+ The following code-snippet implements this tree structure:
70
+
71
+ +------------+
72
+ | ROOT |
73
+ +-----+------+
74
+ +-------------+------------+
75
+ | |
76
+ +-------+-------+ +-------+-------+
77
+ | CHILD 1 | | CHILD 2 |
78
+ +-------+-------+ +---------------+
79
+ |
80
+ |
81
+ +-------+-------+
82
+ | GRANDCHILD 1 |
83
+ +---------------+
84
+
85
+ require 'tree'
86
+
87
+ myTreeRoot = Tree::TreeNode.new("ROOT", "Root Content")
88
+
89
+ myTreeRoot << Tree::TreeNode.new("CHILD1", "Child1 Content") << Tree::TreeNode.new("GRANDCHILD1", "GrandChild1 Content")
90
+
91
+ myTreeRoot << Tree::TreeNode.new("CHILD2", "Child2 Content")
92
+
93
+ myTreeRoot.printTree
94
+
95
+ child1 = myTreeRoot["CHILD1"]
96
+
97
+ grandChild1 = myTreeRoot["CHILD1"]["GRANDCHILD1"]
98
+
99
+ siblingsOfChild1Array = child1.siblings
100
+
101
+ immediateChildrenArray = myTreeRoot.children
102
+
103
+ # Process all nodes
104
+
105
+ myTreeRoot.each { |node| node.content.reverse }
106
+
107
+ myTreeRoot.remove!(child1) # Remove the child
108
+
109
+ == LICENSE
110
+
111
+ RubyTree is licensed under BSD license.
112
+
113
+ Copyright (c) 2007, Anupam Sengupta
114
+
115
+ All rights reserved.
116
+
117
+ Redistribution and use in source and binary forms, with or without modification,
118
+ are permitted provided that the following conditions are met:
119
+
120
+ - Redistributions of source code must retain the above copyright notice, this
121
+ list of conditions and the following disclaimer.
122
+
123
+ - Redistributions in binary form must reproduce the above copyright notice, this
124
+ list of conditions and the following disclaimer in the documentation and/or
125
+ other materials provided with the distribution.
126
+
127
+ - Neither the name of the organization nor the names of its contributors may
128
+ be used to endorse or promote products derived from this software without
129
+ specific prior written permission.
130
+
131
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
132
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
133
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
134
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
135
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
136
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
137
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
138
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
139
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
140
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/Rakefile CHANGED
@@ -1,3 +1,36 @@
1
+ # Rakefile
2
+ #
3
+ # Revision: $Revision: 1.8 $
4
+ #
5
+ # Copyright (c) 2006, 2007 Anupam Sengupta
6
+ #
7
+ # All rights reserved.
8
+ #
9
+ # Redistribution and use in source and binary forms, with or without modification,
10
+ # are permitted provided that the following conditions are met:
11
+ #
12
+ # - Redistributions of source code must retain the above copyright notice, this
13
+ # list of conditions and the following disclaimer.
14
+ #
15
+ # - Redistributions in binary form must reproduce the above copyright notice, this
16
+ # list of conditions and the following disclaimer in the documentation and/or
17
+ # other materials provided with the distribution.
18
+ #
19
+ # - Neither the name of the organization nor the names of its contributors may
20
+ # be used to endorse or promote products derived from this software without
21
+ # specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+
1
34
  require 'rubygems'
2
35
  require 'rake/clean'
3
36
  require 'rake/gempackagetask'
@@ -7,7 +40,7 @@ require 'rake/rdoctask'
7
40
  desc "Default Task"
8
41
  task :default => :gem
9
42
 
10
- PKG_VERSION = '0.2.3'
43
+ PKG_VERSION = '0.2.4'
11
44
  PKG_FILES = FileList[
12
45
  '[A-Z]*',
13
46
  'lib/**/*.rb',
@@ -23,13 +56,15 @@ spec = Gem::Specification.new do |s|
23
56
  s.summary = "Ruby implementation of the Tree data structure."
24
57
 
25
58
  s.description = <<-END
26
- Provides a generic tree data structure with ability to
27
- store keyed node elements in the tree. The implementation
59
+ Provides a generic tree data-structure with ability to
60
+ store keyed node-elements in the tree. The implementation
28
61
  mixes in the Enumerable module.
62
+
63
+ Website: http://rubytree.rubyforge.org/
29
64
  END
30
65
 
31
66
  s.has_rdoc = true
32
- s.extra_rdoc_files = ['README']
67
+ s.extra_rdoc_files = ['README', 'LICENSE', 'ChangeLog']
33
68
  s.autorequire = "tree"
34
69
  s.files = PKG_FILES.to_a
35
70
  s.test_files = Dir.glob('test/test*.rb')
@@ -47,7 +82,7 @@ Rake::TestTask.new do |t|
47
82
  end
48
83
 
49
84
  Rake::RDocTask.new do |rd|
50
- rd.rdoc_files.include("README", "lib/**/*.rb")
85
+ rd.rdoc_files.include("README", "LICENSE", "ChangeLog", "lib/**/*.rb")
51
86
  end
52
87
 
53
88
 
data/TAGS ADDED
@@ -0,0 +1,66 @@
1
+
2
+ ./lib/tree.rb,1809
3
+ module Tree::Tree11,250
4
+ class TreeNode::Tree::TreeNode40,1061
5
+ attr_reader :content, :name, :parent::Tree::TreeNode#content43,1112
6
+ attr_reader :content, :name, :parent::Tree::TreeNode#name43,1112
7
+ attr_reader :content, :name, :parent::Tree::TreeNode#parent43,1112
8
+ attr_writer :content::Tree::TreeNode#content44,1157
9
+ def initialize::Tree::TreeNode#Tree::TreeNode.new55,1473
10
+ def to_s::Tree::TreeNode#to_s69,1866
11
+ def parent=::Tree::TreeNode#parent=79,2266
12
+ def <<::Tree::TreeNode#<<87,2532
13
+ def add::Tree::TreeNode#add95,2825
14
+ def remove!::Tree::TreeNode#remove!109,3285
15
+ def removeFromParent!::Tree::TreeNode#removeFromParent!118,3601
16
+ def removeAll!::Tree::TreeNode#removeAll!123,3749
17
+ def hasContent?::Tree::TreeNode#hasContent?133,4013
18
+ def setAsRoot!::Tree::TreeNode#setAsRoot!138,4139
19
+ def isRoot?::Tree::TreeNode#isRoot?144,4327
20
+ def hasChildren?::Tree::TreeNode#hasChildren?149,4461
21
+ def children::Tree::TreeNode#children155,4655
22
+ def each::Tree::TreeNode#each165,4932
23
+ def []::Tree::TreeNode#[]177,5366
24
+ def size::Tree::TreeNode#size189,5712
25
+ def length::Tree::TreeNode#length194,5850
26
+ def printTree::Tree::TreeNode#printTree199,5957
27
+ def root::Tree::TreeNode#root205,6149
28
+ def siblings::Tree::TreeNode#siblings214,6454
29
+ def <=>::Tree::TreeNode#<=>230,6982
30
+ def freezeTree!::Tree::TreeNode#freezeTree!236,7148
31
+ def createDumpRep::Tree::TreeNode#createDumpRep241,7273
32
+ def _dump::Tree::TreeNode#_dump247,7487
33
+ def TreeNode.loadDumpRep::Tree::TreeNode.loadDumpRep253,7639
34
+ def TreeNode._load::Tree::TreeNode._load270,8265
35
+
36
+ ./test/person.rb,305
37
+ class Person::Person1,0
38
+ attr_reader :first, :last
39
+ attr_reader :first, :last
40
+ attr_writer :first, :last
41
+ attr_writer :first, :last
42
+ def initialize::Person#Person.new4,80
43
+ def to_s::Person#to_s9,182
44
+
45
+ ./test/testtree.rb,1164
46
+ class TC_TreeTest::TC_TreeTest8,106
47
+ def setup::TC_TreeTest#setup10,161
48
+ def loadChildren::TC_TreeTest#loadChildren20,503
49
+ def teardown::TC_TreeTest#teardown26,615
50
+ def test_root_setup::TC_TreeTest#test_root_setup30,668
51
+ def test_root::TC_TreeTest#test_root44,1348
52
+ def test_siblings::TC_TreeTest#test_siblings52,1591
53
+ def test_add::TC_TreeTest#test_add71,2221
54
+ def test_remove::TC_TreeTest#test_remove90,2743
55
+ def test_removeAll::TC_TreeTest#test_removeAll117,3521
56
+ def test_removeFromParent::TC_TreeTest#test_removeFromParent126,3789
57
+ def test_children::TC_TreeTest#test_children142,4413
58
+ def test_find::TC_TreeTest#test_find167,5289
59
+ def test_each::TC_TreeTest#test_each181,5859
60
+ def test_parent::TC_TreeTest#test_parent198,6530
61
+ def test_indexed_access::TC_TreeTest#test_indexed_access207,6939
62
+ def test_printTree::TC_TreeTest#test_printTree215,7233
63
+ def test_dump::TC_TreeTest#test_dump221,7320
64
+ def test_collect::TC_TreeTest#test_collect237,7901
65
+ def test_freezeTree::TC_TreeTest#test_freezeTree246,8152
66
+ def test_content::TC_TreeTest#test_content255,8444
data/lib/tree.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # tree.rb
2
+ #
3
+ # Revision: $Revision: 1.6 $
1
4
  #
2
5
  # = tree.rb - Generic Tree implementation
3
6
  #
@@ -8,12 +11,59 @@
8
11
  # Author:: Anupam Sengupta (anupamsg@gmail.com)
9
12
  #
10
13
 
14
+ # Copyright (c) 2006, 2007 Anupam Sengupta
15
+ #
16
+ # All rights reserved.
17
+ #
18
+ # Redistribution and use in source and binary forms, with or without modification,
19
+ # are permitted provided that the following conditions are met:
20
+ #
21
+ # - Redistributions of source code must retain the above copyright notice, this
22
+ # list of conditions and the following disclaimer.
23
+ #
24
+ # - Redistributions in binary form must reproduce the above copyright notice, this
25
+ # list of conditions and the following disclaimer in the documentation and/or
26
+ # other materials provided with the distribution.
27
+ #
28
+ # - Neither the name of the organization nor the names of its contributors may
29
+ # be used to endorse or promote products derived from this software without
30
+ # specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
36
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
39
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
+
43
+
11
44
  module Tree
12
45
 
13
46
  # The Tree node class implementation. Mixes in the Enumerable
14
47
  # module.
48
+ #
15
49
  # == Example
16
50
  #
51
+ # The following code-snippet implements this tree structure:
52
+ #
53
+ # +------------+
54
+ # | ROOT |
55
+ # +-----+------+
56
+ # +-------------+------------+
57
+ # | |
58
+ # +-------+-------+ +-------+-------+
59
+ # | CHILD 1 | | CHILD 2 |
60
+ # +-------+-------+ +---------------+
61
+ # |
62
+ # |
63
+ # +-------+-------+
64
+ # | GRANDCHILD 1 |
65
+ # +---------------+
66
+ #
17
67
  # require 'tree'
18
68
  #
19
69
  # myTreeRoot = Tree::TreeNode.new("ROOT", "Root Content")
@@ -45,17 +95,17 @@ module Tree
45
95
 
46
96
  @@fieldSep = '|'
47
97
  @@recordSep = "\n"
48
-
98
+
49
99
  # Constructor which expects the name of the node
50
100
  #
51
- # name of the node is expected to be unique across the
101
+ # Name of the node is expected to be unique across the
52
102
  # tree.
53
103
  #
54
104
  # The content can be of any type, and is defaulted to _nil_.
55
105
  def initialize(name, content = nil)
56
-
106
+
57
107
  raise "Node name HAS to be provided" if name == nil
58
-
108
+
59
109
  @name = name
60
110
  @content = content
61
111
 
@@ -80,7 +130,7 @@ module Tree
80
130
  @parent = parent
81
131
  end
82
132
 
83
- # Convenience synonym for Tree#add method.
133
+ # Convenience synonym for Tree#add method.
84
134
  # This method allows a convenient method to add
85
135
  # children hierarchies in the tree.
86
136
  # E.g. root << child << grand_child
@@ -118,7 +168,7 @@ module Tree
118
168
  def removeFromParent!
119
169
  @parent.remove!(self) unless isRoot?
120
170
  end
121
-
171
+
122
172
  # Removes all children from the receiver node.
123
173
  def removeAll!
124
174
  for child in @children
@@ -169,14 +219,14 @@ module Tree
169
219
 
170
220
  # Returns the requested node from the set of immediate
171
221
  # children.
172
- #
222
+ #
173
223
  # If the key is _numeric_, then the in-sequence array of
174
224
  # children is accessed (see Tree#children).
175
225
  # If the key is not _numeric_, then it is assumed to be
176
226
  # the *name* of the child node to be returned.
177
227
  def [](key)
178
228
  raise "Key needs to be provided" if key == nil
179
-
229
+
180
230
  if key.kind_of?(Integer)
181
231
  @children[key]
182
232
  else
@@ -201,7 +251,7 @@ module Tree
201
251
  children {|child| child.printTree(tab + 4)}
202
252
  end
203
253
 
204
- # Returns the root for this node.
254
+ # Returns the root for this tree.
205
255
  def root
206
256
  root = self
207
257
  root = root.parent while !root.isRoot?
@@ -215,7 +265,7 @@ module Tree
215
265
  return nil if isRoot?
216
266
  if block_given?
217
267
  for sibling in parent.children
218
- yield sibling if sibling != self
268
+ yield sibling if sibling != self
219
269
  end
220
270
  else
221
271
  siblings = []
@@ -236,20 +286,21 @@ module Tree
236
286
  def freezeTree!
237
287
  each {|node| node.freeze}
238
288
  end
239
-
240
- # Creates a dump representation
289
+
290
+ # Creates a dump representation and returns the same as a string
241
291
  def createDumpRep
242
292
  strRep = String.new
243
293
  strRep << @name << @@fieldSep << (isRoot? ? @name : @parent.name)
244
294
  strRep << @@fieldSep << Marshal.dump(@content) << @@recordSep
245
295
  end
246
-
296
+
247
297
  def _dump(depth)
248
298
  strRep = String.new
249
299
  each {|node| strRep << node.createDumpRep}
250
300
  strRep
251
301
  end
252
-
302
+
303
+ # Loads a dump representation of the tree from the specified string
253
304
  def TreeNode.loadDumpRep(str)
254
305
  nodeHash = Hash.new
255
306
  rootNode = nil
@@ -266,13 +317,14 @@ module Tree
266
317
  end
267
318
  rootNode
268
319
  end
269
-
320
+
321
+ # Loads a dump representation of the tree from the specified string.
270
322
  def TreeNode._load(str)
271
323
  loadDumpRep(str)
272
324
  end
273
-
325
+
274
326
  protected :parent=, :setAsRoot!
275
327
  private_class_method :loadDumpRep
276
-
328
+
277
329
  end
278
- end
330
+ end
data/test/person.rb CHANGED
@@ -1,3 +1,37 @@
1
+ # person.rb
2
+ #
3
+ # Revision: $Revision: 1.4 $
4
+ #
5
+ # Copyright (c) 2006, 2007 Anupam Sengupta
6
+ #
7
+ # All rights reserved.
8
+ #
9
+ # Redistribution and use in source and binary forms, with or without modification,
10
+ # are permitted provided that the following conditions are met:
11
+ #
12
+ # - Redistributions of source code must retain the above copyright notice, this
13
+ # list of conditions and the following disclaimer.
14
+ #
15
+ # - Redistributions in binary form must reproduce the above copyright notice, this
16
+ # list of conditions and the following disclaimer in the documentation and/or
17
+ # other materials provided with the distribution.
18
+ #
19
+ # - Neither the name of the organization nor the names of its contributors may
20
+ # be used to endorse or promote products derived from this software without
21
+ # specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+
34
+ # Define a simple class for testing the RubyTree implementation
1
35
  class Person
2
36
  attr_reader :first, :last
3
37
  attr_writer :first, :last
@@ -5,9 +39,9 @@ class Person
5
39
  @first = first
6
40
  @last = last
7
41
  end
8
-
42
+
9
43
  def to_s
10
44
  "#@first, #@last"
11
45
  end
12
-
46
+
13
47
  end
data/test/testtree.rb CHANGED
@@ -1,5 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # testtree.rb
4
+ #
5
+ # Revision: $Revision: 1.5 $
6
+ #
7
+ # Copyright (c) 2006, 2007 Anupam Sengupta
8
+ #
9
+ # All rights reserved.
10
+ #
11
+ # Redistribution and use in source and binary forms, with or without modification,
12
+ # are permitted provided that the following conditions are met:
13
+ #
14
+ # - Redistributions of source code must retain the above copyright notice, this
15
+ # list of conditions and the following disclaimer.
16
+ #
17
+ # - Redistributions in binary form must reproduce the above copyright notice, this
18
+ # list of conditions and the following disclaimer in the documentation and/or
19
+ # other materials provided with the distribution.
20
+ #
21
+ # - Neither the name of the organization nor the names of its contributors may
22
+ # be used to endorse or promote products derived from this software without
23
+ # specific prior written permission.
24
+ #
25
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
29
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
3
36
  require 'test/unit'
4
37
  require 'tree'
5
38
  require 'person'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rubytree
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.3
7
- date: 2007-01-05 00:00:00 -07:00
6
+ version: 0.2.4
7
+ date: 2007-06-23 00:00:00 -07:00
8
8
  summary: Ruby implementation of the Tree data structure.
9
9
  require_paths:
10
10
  - lib
11
11
  email: anupamsg@gmail.com
12
12
  homepage:
13
13
  rubyforge_project:
14
- description: Provides a generic tree data structure with ability to store keyed node elements in the tree. The implementation mixes in the Enumerable module.
14
+ description: "Provides a generic tree data-structure with ability to store keyed node-elements in the tree. The implementation mixes in the Enumerable module. Website: http://rubytree.rubyforge.org/"
15
15
  autorequire: tree
16
16
  default_executable:
17
17
  bindir: bin
@@ -29,8 +29,11 @@ post_install_message:
29
29
  authors:
30
30
  - Anupam Sengupta
31
31
  files:
32
+ - ChangeLog
33
+ - LICENSE
32
34
  - Rakefile
33
35
  - README
36
+ - TAGS
34
37
  - lib/tree.rb
35
38
  - test/person.rb
36
39
  - test/testtree.rb
@@ -40,6 +43,8 @@ rdoc_options: []
40
43
 
41
44
  extra_rdoc_files:
42
45
  - README
46
+ - LICENSE
47
+ - ChangeLog
43
48
  executables: []
44
49
 
45
50
  extensions: []