rubytree 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/.dir-locals.el ADDED
@@ -0,0 +1,5 @@
1
+ ;;; Directory Local Variables
2
+ ;;; See Info node `(emacs) Directory Variables' for more information.
3
+
4
+ ((nil . ((projectile-mode . t)
5
+ (fill-column . 80))))
@@ -1,3 +1,5 @@
1
+ # @markup rdoc
2
+
1
3
  = API Changes in RubyTree
2
4
 
3
5
  This file documents various API level changes that have been made to the RubyTree package.
@@ -5,6 +7,10 @@ This file documents various API level changes that have been made to the RubyTre
5
7
  Note: API level changes are expected to reduce dramatically after the 1.x release. In most cases, an alternative will
6
8
  be provided to ensure relatively smooth transition to the new APIs.
7
9
 
10
+ == Release 8.8.3 Changes
11
+
12
+ - {Tree::TreeNode#siblings} will now return an empty array for the root node.
13
+
8
14
  == Release 0.8.0 Changes
9
15
 
10
16
  - Added the ability to specify an optional insertion position in the {Tree::TreeNode#add} method. Idea and original
@@ -24,28 +30,25 @@ be provided to ensure relatively smooth transition to the new APIs.
24
30
  - {Tree::TreeNode#[]}
25
31
  - {Tree::BinaryTreeNode#add}
26
32
 
27
- - Added {Tree::TreeNode#level} as an alias for {Tree::TreeNode#nodeDepth}
33
+ - Added {Tree::TreeNode#level} as an alias for {Tree::TreeNode#node_depth}
28
34
 
29
35
  - Added new methods {Tree::TreeNode#in_degree} and {Tree::TreeNode#out_degree} to report the node's degree stats
30
36
 
31
- - {Tree::TreeNode#isOnlyChild?} now returns +true+ for a root node.
37
+ - {Tree::TreeNode#is_only_child?} now returns +true+ for a root node.
32
38
 
33
- - {Tree::TreeNode#nextSibling} and {Tree::TreeNode#previousSibling} now return +nil+ for a root node.
39
+ - {Tree::TreeNode#next_sibling} and {Tree::TreeNode#previous_sibling} now return +nil+ for a root node.
34
40
 
35
41
  - {Tree::TreeNode#add} and {Tree::TreeNode#<<} now throw an ArgumentError exception if a +nil+ node is passed as an argument.
36
42
 
37
- - Added new methods {Tree::TreeNode#to_json} and {Tree::TreeNode::json_create} to convert to/from the JSON format.
43
+ - Added new methods {Tree::TreeNode#to_json} and Tree::TreeNode::json_create to convert to/from the JSON format.
38
44
  Thanks to Dirk[http://github.com/railsbros-dirk] for this change.
39
45
 
40
46
  == Release 0.6.1 Changes
41
47
 
42
48
  - Deprecated the {Tree::TreeNode#depth} method as it was returning an incorrect depth value. Have introduced a new replacement
43
- method {Tree::TreeNode#nodeDepth} which returns the correct result.
44
-
45
-
46
-
49
+ method {Tree::TreeNode#node_depth} which returns the correct result.
47
50
 
48
51
  # Local Variables:
49
- # mode: text
52
+ # mode: rdoc
50
53
  # coding: utf-8-unix
51
54
  # End:
@@ -2,7 +2,7 @@
2
2
 
3
3
  http://rubytree.rubyforge.org
4
4
 
5
- Copyright (c) 2006, 2007, 2008, 2009, 2010 Anupam Sengupta (anupamsg at gmail dot com)
5
+ Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Anupam Sengupta (anupamsg at gmail dot com)
6
6
 
7
7
  All rights reserved.
8
8
 
@@ -26,18 +26,7 @@ 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$
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
29
  # Local Variables:
41
- # mode: text
30
+ # mode: rdoc
42
31
  # coding: utf-8-unix
43
32
  # End:
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubytree.gemspec
4
+ gemspec
5
+
6
+ # Local Variables:
7
+ # mode: ruby
8
+ # End:
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubytree (0.8.3)
5
+ json (>= 1.7.5)
6
+ structured_warnings (>= 0.1.3)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ json (1.7.5)
12
+ rake (0.9.2.2)
13
+ rcov (0.9.11)
14
+ rtags (0.98)
15
+ rtagstask (0.0.4)
16
+ rtags (> 0.0.0)
17
+ structured_warnings (0.1.3)
18
+ yard (0.8.2.1)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ rake (>= 0.9.2.2)
25
+ rcov (~> 0.9.0)
26
+ rtagstask (>= 0.0.4)
27
+ rubytree!
28
+ yard (>= 0.8.2.1)
@@ -1,3 +1,35 @@
1
+ # @markup rdoc
2
+
3
+ = History of Changes
4
+
5
+ === 0.8.3 / 2012-08-31
6
+
7
+ This is a primarily a bug-fix release, with some packaging changes.
8
+
9
+ * Have removed the dependency on Hoe. The build is now vanilla gemspec based.
10
+
11
+ * Included support for {gem-testers}[http://test.rubygems.org/].
12
+
13
+ * Included support for {Bundler}[http://gembundler.com/].
14
+
15
+ * Implemented the +as_json+ method to support Rails' JSON encoding,
16
+ by pulling in the changes by Eric Cline (https://github.com/escline).
17
+
18
+ * Partial fix for {Github Bug
19
+ #5}[https://github.com/evolve75/RubyTree/issues/5]. This is to
20
+ prevent infinite looping is an existing node is added again
21
+ elsewhere in the tree.
22
+
23
+ * Fixed the issue with using +integers+ as node names, and its
24
+ interaction with the +TreeNode#[]+ access method {Github Bug
25
+ #6}[https://github.com/evolve75/RubyTree/issues/6].
26
+
27
+ * Clarified the need to have unique node names {Github Bug
28
+ #7}[https://github.com/evolve75/RubyTree/issues/7] (documentation).
29
+
30
+ * Fixed +siblings+ method to return an empty array for the root node as
31
+ well (it returned +nil+ earlier).
32
+
1
33
  === 0.8.2 / 2011-12-15
2
34
 
3
35
  * Minor bug-fix release to address bug #1215 (Tree::TreeNode#to_s
@@ -107,4 +139,6 @@
107
139
 
108
140
  * Minor code refactoring. Changes in the Rakefile.
109
141
 
110
- $Id$
142
+ ;; Local Variables:
143
+ ;; mode: rdoc
144
+ ;; End:
@@ -6,7 +6,7 @@
6
6
  \/ \_/\__,_|_.__/ \__, |\__|_| \___|\___|
7
7
  |___/
8
8
 
9
- Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Anupam Sengupta (anupamsg at gmail dot com)
9
+ Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Anupam Sengupta (anupamsg at gmail dot com)
10
10
 
11
11
  http://rubytree.rubyforge.org
12
12
 
@@ -70,10 +70,10 @@ As an example, the following code-snippet implements this tree structure:
70
70
 
71
71
  * Ruby 1.8+ (http://www.ruby-lang.org)
72
72
 
73
- * Optional but recommended:
74
- * structured_warnings (http://github.com/schmidt/structured_warnings) Rubygem
73
+ * Run-time Dependencies:
74
+ * structured_warnings (http://github.com/schmidt/structured_warnings) rubygem
75
75
  * Yard (http://yardoc.org) Rubygem for the documentation
76
- * JSON (http://flori.github.com/json) Rubygem for converting to/from the JSON format
76
+ * JSON (http://flori.github.com/json) rubygem for converting to/from the JSON format
77
77
 
78
78
  * Development dependencies (not required for installing the gem):
79
79
  * Hoe (http://seattlerb.rubyforge.org/hoe/Hoe.html) Rubygem
@@ -184,6 +184,7 @@ I would like to acknowledge the following contributors for helping improve RubyT
184
184
 
185
185
  1. Dirk Breuer (http://github.com/railsbros-dirk) for contributing the JSON conversion code.
186
186
  2. Vincenzo Farruggia for contributing the (sub)tree cloning code.
187
+ 3. Eric Cline (https://github.com/escline) for the Rails JSON encoding fix.
187
188
 
188
189
  == LICENSE:
189
190
 
@@ -212,10 +213,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSE
212
213
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
213
214
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
214
215
 
215
-
216
- (Document Revision: $Revision$ by $Author$)
217
-
218
216
  # Local Variables:
219
- # mode: text
217
+ # mode: rdoc
220
218
  # coding: utf-8-unix
221
219
  # End:
data/Rakefile CHANGED
@@ -2,9 +2,7 @@
2
2
  #
3
3
  # Rakefile - This file is part of the RubyTree package.
4
4
  #
5
- # $Revision$ by $Author$ on $Date$
6
- #
7
- # Copyright (c) 2006, 2007, 2009, 2010 Anupam Sengupta
5
+ # Copyright (c) 2006, 2007, 2009, 2010, 2011, 2012 Anupam Sengupta
8
6
  #
9
7
  # All rights reserved.
10
8
  #
@@ -34,114 +32,92 @@
34
32
  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
33
  #
36
34
 
37
- PKG_NAME = "rubytree"
38
-
39
- # Default is to create a rubygem.
40
- desc "Default Task (create the gem)"
41
- task :default => :gem
42
-
43
- # Use Hoe to define the rake tasks.
44
- begin
45
- require 'hoe'
46
- Hoe.plugin :yard
47
-
48
- Hoe.spec PKG_NAME do
49
- # The GemSpec settings
50
- self.rubyforge_name = PKG_NAME
51
- developer "Anupam Sengupta", "anupamsg@gmail.com"
52
-
53
- self.url = "http://rubytree.rubyforge.org"
54
- self.readme_file = 'README'
55
-
56
- # Set the Yard Options
57
- extra_docs = ["COPYING", "API-CHANGES"]
58
- extra_docs.each { |file| self.yard_files << file }
59
- self.yard_options = ["--files", extra_docs.join(",") ]
60
-
61
- # Now the publishing settings
62
- self.remote_rdoc_dir = 'rdoc'
35
+ require 'rubygems'
36
+ GEM_SPEC = eval(File.read("rubytree.gemspec")) # Load the gemspec.
63
37
 
64
- # Support additional package formats
65
- self.need_tar = true
66
- self.need_zip = true
38
+ PKG_NAME = GEM_SPEC.name
39
+ PKG_VER = GEM_SPEC.version
40
+ GEM_NAME = "#{PKG_NAME}-#{PKG_VER}.gem"
67
41
 
68
- # Post installation message
69
- self.post_install_message = <<MSGEND
70
- ========================================================================
42
+ desc "Default Task (Run the tests)"
43
+ task :default => 'test:rcov'
71
44
 
72
- Thank you for installing #{PKG_NAME}.
73
-
74
- WARNING: SIGNIFICANT API CHANGE in 0.8.0 !
75
- ------------------------------------------
76
-
77
- Please note that as of 0.8.0 the CamelCase method names are DEPRECATED.
45
+ desc "Display the current gem version"
46
+ task :version do
47
+ puts "Current Version: #{GEM_NAME}"
48
+ end
78
49
 
79
- The new method names follow the ruby_convention (separated by '_').
50
+ require 'rake/clean'
51
+ task :clean => 'gem:clobber_package'
52
+ CLEAN.include('coverage')
53
+ task :clobber => [:clean, 'doc:clobber_rdoc', 'doc:clobber_yard', 'tag:clobber_tags']
80
54
 
81
- The old CamelCase methods still work (a warning will be displayed),
82
- but may go away in the future.
55
+ desc "Open an irb session preloaded with this library"
56
+ task :console do
57
+ sh "irb -rubygems -r ./lib/tree.rb"
58
+ end
83
59
 
84
- Details of the API changes are documented in the API-CHANGES file.
60
+ namespace :doc do # ................................ Documentation
85
61
 
86
- ========================================================================
87
- MSGEND
62
+ require 'rdoc/task'
63
+ Rake::RDocTask.new do |rdoc|
64
+ rdoc.rdoc_dir = 'rdoc'
65
+ rdoc.title = "#{PKG_NAME}-#{PKG_VER}"
66
+ rdoc.main = 'README.rdoc'
67
+ rdoc.rdoc_files.include(GEM_SPEC.extra_rdoc_files)
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
88
70
 
89
- # Code Metrics ...
90
- self.flay_threshold = timebomb 1200, 100 # Default is 1200, 100
91
- self.flog_threshold = timebomb 1200, 100 # Default is 1200, 100
71
+ require 'yard'
72
+ YARD::Rake::YardocTask.new do |t|
73
+ t.files = ['lib/**/*.rb', '-', GEM_SPEC.extra_rdoc_files]
74
+ t.options = ['--no-private', '--embed-mixins']
92
75
  end
93
76
 
94
- rescue LoadError # If Hoe is not found ...
95
- $stderr.puts <<-END
96
- ERROR!!! You do not seem to have Hoe installed!
77
+ desc "Remove YARD Documentation"
78
+ task :clobber_yard do
79
+ rm_rf 'doc'
80
+ end
81
+ end
97
82
 
98
- The Hoe gem is required for running the rake tasks for building the rubytree gem.
83
+ desc "Run the test cases"
84
+ task :test => 'test:unit'
99
85
 
100
- You can download Hoe as a Rubygem by running as root (or sudo):
86
+ namespace :test do # ................................ Test related
101
87
 
102
- $ gem install hoe
88
+ require 'rake/testtask'
89
+ Rake::TestTask.new(:unit) do |test|
90
+ test.libs << 'lib' << 'test'
91
+ test.pattern = 'test/**/test_*.rb'
92
+ test.verbose = false
93
+ end
103
94
 
104
- More details can be found at http://seattlerb.rubyforge.org/hoe/Hoe.html
95
+ require 'rcov/rcovtask'
96
+ Rcov::RcovTask.new(:rcov) do |t|
97
+ t.libs << "test"
98
+ t.test_files = FileList['test/**/test_*.rb']
99
+ t.verbose = true
100
+ t.rcov_opts << '--exclude /gems/,/Library/,/usr/,spec,lib/tasks'
101
+ end
105
102
 
106
- END
107
103
  end
108
104
 
109
-
110
- # The following tasks are loaded independently of Hoe
111
- # ===================================================
112
-
113
- # Optional TAGS Task.
114
- # Needs http://rubyforge.org/projects/rtagstask/
115
- begin
105
+ namespace :tag do # ................................ Emacs Tags
116
106
  require 'rtagstask'
117
- RTagsTask.new do |rd|
107
+ RTagsTask.new(:tags) do |rd|
118
108
  rd.vi = false
119
109
  end
120
- rescue LoadError
121
- $stderr.puts <<-END
122
- ERROR!!! You need to have the rtagstask (https://rubyforge.org/projects/rtagstask/) for generating the TAGS file.
123
-
124
- You can install the rtags gem by running the following command as root (or sudo):
125
-
126
- $ gem install rtagstask
127
-
128
- END
129
110
  end
130
111
 
131
- begin
132
- require 'reek/rake/task'
133
- Reek::Rake::Task.new do |t|
134
- t.verbose = false
135
- t.source_files = 'lib/**/*.rb'
112
+ namespace :gem do # ................................ Gem related
113
+ require 'rubygems/package_task'
114
+ Gem::PackageTask.new(GEM_SPEC) do |pkg|
115
+ pkg.need_zip = true
116
+ pkg.need_tar = true
136
117
  end
137
- rescue LoadError
138
- $stderr.puts <<-END
139
- ERROR!!! You need to have reek (http://github.com/kevinrutherford/reek) for detecing the code smell.
140
-
141
- You can install the reek gem by running the following command as root (or sudo):
142
-
143
- $ gem install reek
144
-
145
- END
146
118
 
119
+ desc "Push the gem into the Rubygems repository"
120
+ task :push => :gem do
121
+ sh "gem push pkg/#{GEM_NAME}"
122
+ end
147
123
  end
data/TODO.org ADDED
@@ -0,0 +1,174 @@
1
+ # -*- mode: org; coding: utf-8-unix; fill-column: 120; -*-
2
+ #+OPTIONS: ^:{}
3
+
4
+ * R0.7.0 :ARCHIVE:
5
+ *** DONE Start using signed tags from R0.7.0 :ARCHIVE:
6
+ *** DONE Add a check in the Tree::TreeNode.add method to prevent addition of nil child nodes :ARCHIVE:
7
+ CLOSED: [2010-02-23 Tue 23:07]
8
+ *** DONE Fix the edge condition for Tree::TreeNode.isOnlyChild? when the root node is the receiver. :ARCHIVE:
9
+ CLOSED: [2010-02-23 Tue 22:03]
10
+ There really is no good default to this situation. We will return 'true' simply because there is no other sibling
11
+ to a root. However, a good case can be made that a root node does not have any parent either.
12
+ *** DONE Add a convenience 'level' method to the TreeNode class (will be an alias to nodeDepth) :ARCHIVE:
13
+ CLOSED: [2010-02-21 Sun 01:02]
14
+ *** DONE Add a API-CHANGES file to document the various API changes made till date :ARCHIVE:
15
+ CLOSED: [2010-01-31 Sun 00:52]
16
+ *** DONE Add new methods to return the degree counts of the receiver node (in-degree and out-degree) :ARCHIVE:
17
+ CLOSED: [2010-01-30 Sat 23:56]
18
+
19
+
20
+
21
+
22
+ * R0.8.0 :ARCHIVE:
23
+ *** DONE Convert all method names to the canonical /^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ pattern :ARCHIVE:
24
+ See Roodi report at http://getcaliper.com/caliper/tool?tool=roodi&repo=git://github.com/evolve75/RubyTree.git
25
+ *** DONE Integrate the subtree cloning patch submitted by Vincenzo Farrugia. :ARCHIVE:
26
+
27
+
28
+
29
+ * R0.8.1 :ARCHIVE:
30
+ *** DONE Fix [[http://rubyforge.org/tracker/index.php?func%3Ddetail&aid%3D28613&group_id%3D1215&atid%3D4793][bug #28613]] which was affecting the `leftChild=' and `rightChild=' methods for binary trees. :ARCHIVE:
31
+
32
+
33
+
34
+ * R0.8.3
35
+
36
+ This is a bugfix release.
37
+
38
+ *** TODO [#A] Resolve the infinite loop bug if a node is added to itself as a child :Partial:
39
+ Issue https://github.com/evolve75/RubyTree/issues/5
40
+
41
+ This is a subtle problem to resolve. The specific case of a node
42
+ being added to itself is trivial to resolve, and the fix has been
43
+ put in for 0.8.3.
44
+
45
+ However, the general problem is that in the current code, a node
46
+ can be added as a child to any portion of the tree down the
47
+ hierarchy (e.g., as a grandchild), which will need a more thorough
48
+ detection code in the ~TreeNode#add~ method, if it is to be done at
49
+ runtime.
50
+
51
+ The issue is really to prevent the tree becoming a graph. Note
52
+ that the issue is with duplicate nodes, /not/ duplicated content.
53
+
54
+ A few options exist:
55
+ 1. Perform a runtime check in the ~TreeNode#add~ method. This will
56
+ cause a performance hit as the tree becomes larger.
57
+ 2. Allow the additions to go through, but create a new ~validate~
58
+ method that checks for such cycles.
59
+ 3. Create separate configuration object which can be attached to
60
+ the root of the tree, which allows per-tree configuration of
61
+ the behavior - this does allow for the user to take control,
62
+ but also introduces complications during tree mergers and
63
+ spitting subtrees.
64
+ 4. Create a registry (to be maintained at the root?) of all nodes,
65
+ and use this for validating the node additions (and preventing
66
+ duplicates). This needs to be a hash (to allow O(1) access),
67
+ and will sacrifice memory. There might be a need to
68
+ restructure the internals to make better use of memory.
69
+
70
+
71
+ *** DONE Make Rubytree compatible with Bundler :ARCHIVE:
72
+ CLOSED: [2012-08-21 Tue 21:04]
73
+
74
+ *** DONE Make Rubytree compatible wth gem-testers :ARCHIVE:
75
+ CLOSED: [2012-08-21 Tue 21:04]
76
+
77
+ *** DONE Remove the dependency on Hoe :ARCHIVE:
78
+ CLOSED: [2012-08-21 Tue 21:05]
79
+ *** DONE Resolve the _tree.rb_ file conflict with the [[http://netaddr.rubyforge.org/][netaddr gem]] :ARCHIVE:
80
+ CLOSED: [2012-08-20 Mon 01:03]
81
+ Issue https://github.com/evolve75/RubyTree/issues/8
82
+
83
+ *** DONE Update documentation to be more explicit about duplicate node names :ARCHIVE:
84
+ CLOSED: [2012-08-19 Sun 21:46]
85
+ Issue https://github.com/evolve75/RubyTree/issues/7
86
+ Update documentation for :name attribute in tree.rb. There is no
87
+ specific code fix needed.
88
+
89
+ *** DONE Allow integers to be used as node names (clarify the scenario). Fixed issue #6. :ARCHIVE:
90
+ CLOSED: [2012-08-19 Sun 15:17]
91
+ Issue https://github.com/evolve75/RubyTree/issues/6
92
+ We will need to warn the user when an Integer is used as a name
93
+ for the node (but still allow the usage),
94
+ and
95
+ also add an optional flag to the TreeNode#[] method to allow the
96
+ user to explicitly indicate use of the Integer parameter as a
97
+ literal name, and not as an /index/ to the children array.
98
+
99
+ *** DONE Clarify (or fix) the scenario whether a root node without children is a leaf :ARCHIVE:
100
+ CLOSED: [2012-08-19 Sun 15:09]
101
+ Issue http://rubyforge.org/tracker/index.php?func=detail&aid=29549&group_id=1215&atid=4793
102
+
103
+ #+begin_src ruby -n :eval no
104
+ tree.each_leaf do |tree_leaf|
105
+ tree_leaf_parent = tree_leaf.parent
106
+ tree_leaf.remove_from_parent!
107
+ puts tree_leaf_parent.is_leaf?
108
+ end
109
+ #+end_src
110
+
111
+ will return ~false~, while technically ~tree_leaf_parent~ becomes leaf itself when ~tree_leaf~ is removed.
112
+
113
+ The problem here is that the code above is trying to concurrently modify the collection over which the ~each_leaf~
114
+ iterator is looping, which has unpredicable results. As an example, try this with an array:
115
+
116
+ #+begin_src ruby -n
117
+ a = Array(1..5)
118
+ a.each do |e|
119
+ a.delete(e)
120
+ end
121
+ a
122
+ #+end_src
123
+
124
+ #+RESULTS:
125
+ | 2 | 4 |
126
+
127
+ The result is surprising, as not all elements are being deleted. A good explanation is available in [[https://groups.google.com/forum/?fromgroups#!topic/ruby-talk-google/iEDF8qhojss%255B1-25%255D][this thread]] on
128
+ Ruby-Talk @ Google.
129
+
130
+ The correct way to handle the original need is:
131
+
132
+ #+begin_src ruby -n :eval no
133
+ leafs = @root.each_leaf
134
+ parents = leafs.collect {|leaf| leaf.parent }
135
+ leafs.each {|leaf| leaf.remove_from_parent!}
136
+ parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?}
137
+ #+end_src
138
+
139
+ Basically, the parent removal is done in a separate block, and *then* the check for the parents becoming leafs is done.
140
+
141
+ *** DONE Fix the ~first_sibling~ and ~last_sibling~ for the root :ARCHIVE:
142
+ CLOSED: [2012-08-19 Sun 21:01]
143
+ The current behavior is correct, and has been left as is.
144
+ *** DONE Fix the ~siblings~ method to return an empty array for root :ARCHIVE:
145
+ CLOSED: [2012-08-19 Sun 21:03]
146
+ *** DONE Fix the TreeNode#root method to return nil for root's root. :ARCHIVE:
147
+ CLOSED: [2012-08-19 Sun 21:13]
148
+
149
+ Left the code as-is, since we need some way to un-ambiguously find the root, regardless of the node given.
150
+
151
+
152
+ * R0.9.0
153
+ *** TODO Fix the inconsistency of returning root as its first sibling, and returning a nil instead. Ditto for last sibling.
154
+ *** TODO fix the inconsistency of returning nil for the root, and an empty array for nodes which have no siblings.
155
+ *** TODO We should perhaps return nil as root's root.
156
+ *** TODO The semantic of length is probably unclear. Should return the node_depth instead (or remove the method)
157
+ The current equivalence of length to size should also be removed.
158
+
159
+
160
+ * Unplanned / Not assigned to any release
161
+ *** TODO Create the basic UML diagrams and upload to the Site
162
+ DEADLINE: <2010-01-04 Mon>
163
+
164
+ *** TODO Add a YAML export method to the TreeNode class.
165
+
166
+ *** TODO marshal_load method probably should be a class method. It currently clobbers self.
167
+ *** DONE Fix bug # [[http://rubyforge.org/tracker/index.php%3Ffunc%3Ddetail&aid%3D22535&group_id%3D1215&atid%3D4793][22535]]: The method Tree::TreeNode#depth is a misnomer. The current definition actually provides the height function. :ARCHIVE:
168
+ DEADLINE: <2010-01-09 Sat> CLOSED: [2010-01-03 Sun 22:15]
169
+
170
+ *** DONE Get the version control moved from CVS to Subversion (request submitted to RubyForge) :ARCHIVE:
171
+ CLOSED: [2010-01-02 Sat 17:58]
172
+
173
+ *** DONE Add logic in Rakefile to read the file list from Manifest.txt file. :ARCHIVE:
174
+ CLOSED: [2009-12-31 Thu 23:37]