rubytree 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/API-CHANGES.md +153 -0
- data/Gemfile +2 -6
- data/Gemfile.lock +40 -55
- data/History.md +410 -0
- data/LICENSE.md +1 -1
- data/README.md +21 -24
- data/Rakefile +41 -20
- data/TODO.org +19 -15
- data/examples/example_basic.rb +14 -7
- data/lib/rubytree.rb +2 -3
- data/lib/tree/binarytree.rb +13 -12
- data/lib/tree/tree_deps.rb +2 -5
- data/lib/tree/utils/hash_converter.rb +129 -121
- data/lib/tree/utils/json_converter.rb +80 -77
- data/lib/tree/utils/metrics_methods.rb +14 -47
- data/lib/tree/utils/path_methods.rb +11 -11
- data/lib/tree/utils/tree_merge_handler.rb +80 -80
- data/lib/tree/utils/utils.rb +9 -7
- data/lib/tree/version.rb +3 -4
- data/lib/tree.rb +80 -82
- data/rubytree.gemspec +61 -38
- data/spec/spec_helper.rb +4 -2
- data/spec/tree_spec.rb +129 -28
- data/test/run_test.rb +4 -3
- data/test/test_binarytree.rb +25 -45
- data/test/test_rubytree_require.rb +2 -1
- data/test/test_subclassed_node.rb +2 -20
- data/test/test_thread_and_fiber.rb +4 -4
- data/test/test_tree.rb +126 -199
- metadata +103 -69
- data/API-CHANGES.rdoc +0 -99
- data/History.rdoc +0 -303
- data/lib/tree/utils/camel_case_method_handler.rb +0 -77
- data/setup.rb +0 -1565
data/History.md
ADDED
@@ -0,0 +1,410 @@
|
|
1
|
+
# History of Changes
|
2
|
+
|
3
|
+
### 2.0.0 / 2022-06-21
|
4
|
+
|
5
|
+
* A major release with significant modernization to the code base and removal of
|
6
|
+
legacy cruft, thanks to [jmortlock][].
|
7
|
+
|
8
|
+
* The long deprecated `Tree::TreeNode#depth` method has finally been
|
9
|
+
**removed**. Use [Tree::TreeNode#node_depth][node_depth] instead.
|
10
|
+
|
11
|
+
* Support for `CamelCase` methods has been dropped.
|
12
|
+
|
13
|
+
* The predicate methods beginning with `is_` or `has_` are now aliases to real
|
14
|
+
methods **without** these prefixes. For example, `Tree::TreeNode#is_root?` is
|
15
|
+
now aliased to `Tree::TreeNode#root?`. This is to comply with the Ruby
|
16
|
+
standard. The original prefixed method names should be considered as
|
17
|
+
deprecated and the corresponding non-prefixed method names should be used
|
18
|
+
instead. it is possible that the old prefixed method names might be removed in
|
19
|
+
the future.
|
20
|
+
|
21
|
+
* RubyTree now supports MRI Ruby versions `2.6.x`, `2.7.x`, and `3.0.x`.
|
22
|
+
|
23
|
+
* Explicit support for `rbx` Ruby has been removed (_might_ still work, but not
|
24
|
+
tested.)
|
25
|
+
|
26
|
+
* RubyTree now uses [Github Workflows][workflow] for its CI pipeline.
|
27
|
+
|
28
|
+
* RubyTree now allows proper sub-classing of [Tree::TreeNode][TreeNode]. Thanks to
|
29
|
+
[jack12816][] for this.
|
30
|
+
|
31
|
+
* RubyTree now correctly handles creating detached copies of un-clonable objects
|
32
|
+
such as `:symbol`, `true|false`, etc. Thanks to [igneus][] for this.
|
33
|
+
|
34
|
+
### 1.0.2 / 2021-12-29
|
35
|
+
|
36
|
+
* A minor maintenance version to address a minor but annoying warning for
|
37
|
+
circular dependencies.
|
38
|
+
|
39
|
+
### 1.0.1 / 2021-12-29
|
40
|
+
|
41
|
+
* Updated all dependencies (dev and runtime) to their _latest_ stable
|
42
|
+
releases. This is to primarily address potential CVE exposures from upstream
|
43
|
+
libraries.
|
44
|
+
|
45
|
+
* Updated the supported version of MRI Ruby to `2.7.x`.
|
46
|
+
|
47
|
+
* Minor code cleanup using the safe automated corrections using `rubocop`.
|
48
|
+
|
49
|
+
* Note that this was never released to <https://rubygems.org>.
|
50
|
+
|
51
|
+
### 1.0.0 / 2017-12-21
|
52
|
+
|
53
|
+
* Finally! Released version `1.0.0`.
|
54
|
+
|
55
|
+
* This is a maintenance release that updates the dependent gem versions and
|
56
|
+
addresses a few security vulnerabilities for older upstream gem packages.
|
57
|
+
|
58
|
+
* With this release, Rubytree now requires Ruby version `2.2.x` or higher.
|
59
|
+
|
60
|
+
### 0.9.7 / 2015-12-31
|
61
|
+
|
62
|
+
* Released `0.9.6`. This is a minor bug-fix release.
|
63
|
+
|
64
|
+
* This release allows the [Tree::TreeNode#print_tree][print_tree] method to be
|
65
|
+
used on non-root nodes. Thanks to [Ojab][Ojab].
|
66
|
+
|
67
|
+
* The spaceship operator (`<=>`) now returns `nil` if the object being compared
|
68
|
+
to is _itself_ `nil` or not another [Tree::TreeNode][TreeNode].
|
69
|
+
|
70
|
+
### 0.9.6 / 2015-05-30
|
71
|
+
|
72
|
+
* Released `0.9.6`, which is identical to `0.9.5`, _except_ for an update to the
|
73
|
+
gem's release date.
|
74
|
+
|
75
|
+
### 0.9.5 / 2015-05-30
|
76
|
+
|
77
|
+
* Released `0.9.5`.
|
78
|
+
|
79
|
+
### 0.9.5pre7 / 2015-05-30
|
80
|
+
|
81
|
+
* Added new methods for getting the path of a node as a `string`. These have
|
82
|
+
been added as a new `mixin`
|
83
|
+
[Tree::Utils::TreePathHandler][TreePathHandler]. Thanks to [Marco][].
|
84
|
+
|
85
|
+
### 0.9.5pre5 / 2015-01-01
|
86
|
+
|
87
|
+
* Fixed [bug-32][] and enabled _move_ semantics on the [Tree::TreeNode#add][add]
|
88
|
+
method, so that if a child is added, which has an existing parent, then it
|
89
|
+
will be _removed_ from its old parent, prior to being added to the new location.
|
90
|
+
|
91
|
+
### 0.9.5pre4 / 2014-12-17
|
92
|
+
|
93
|
+
* Added performance improvements to [Tree::TreeNode#is_root?][is_root] and
|
94
|
+
[Tree::Utils::TreeMetricsHandler#node_depth][mnode_depth]. Thanks to [Aidan Steel][Aidan].
|
95
|
+
|
96
|
+
### 0.9.5pre3 / 2014-12-16
|
97
|
+
|
98
|
+
* Minor fix to correct the release date. This release is otherwise identical
|
99
|
+
to `0.9.5pre2`.
|
100
|
+
|
101
|
+
### 0.9.5pre2 / 2014-12-16
|
102
|
+
|
103
|
+
* Added [Tree::TreeNode#rename][rename] and
|
104
|
+
[Tree::TreeNode#rename_child][rename_child] methods by merging in code from
|
105
|
+
[pr-35][]. Thanks to [Evan Sharp][Evan].
|
106
|
+
|
107
|
+
### 0.9.5pre / 2014-11-01
|
108
|
+
|
109
|
+
* Fixed [bug-13][] with the patch provided by [Jen Hamon][jhamon].
|
110
|
+
|
111
|
+
* Fixed a bug in [Tree::TreeNode#print_tree][print_tree] with the patch provided
|
112
|
+
by [Evan Sharp][Evan].
|
113
|
+
|
114
|
+
* Fixed [bug-31][], which was causing incorrect behavior in
|
115
|
+
[Tree::TreeNode#postordered_each][postordered_each] and
|
116
|
+
[Tree::TreeNode#breadth_each][breadth_each] methods when a block was not
|
117
|
+
provided.
|
118
|
+
|
119
|
+
### 0.9.4 / 2014-07-04
|
120
|
+
|
121
|
+
* Changed all references to <http://rubyforge.org>.
|
122
|
+
|
123
|
+
### 0.9.3 / 2014-02-01
|
124
|
+
|
125
|
+
* Fixed the issue with globally unique node names. See [bug-24][].
|
126
|
+
|
127
|
+
### 0.9.2 / 2014-01-03
|
128
|
+
|
129
|
+
* Yanked `R0.9.1` as the `History.rdoc` file was not updated.
|
130
|
+
|
131
|
+
* Updated the gem description.
|
132
|
+
|
133
|
+
* Changed the [travis-ci][] build to include `coverall` support.
|
134
|
+
|
135
|
+
### 0.9.1 / 2014-01-03
|
136
|
+
|
137
|
+
* Updated the gem description.
|
138
|
+
|
139
|
+
* Incorporated code coverage using the `coverall` gem.
|
140
|
+
|
141
|
+
### 0.9.0 / 2014-01-02
|
142
|
+
|
143
|
+
This is a feature and bug-fix release.
|
144
|
+
|
145
|
+
#### The Features
|
146
|
+
|
147
|
+
* Rubytree now supports `postordered` traversal via the
|
148
|
+
[Tree::TreeNode#postordered_each][postordered_each] method. Thanks to [Paul de
|
149
|
+
Courcel][Paul] for this.
|
150
|
+
|
151
|
+
* The Binary tree now supports `inorder` traversal via the
|
152
|
+
[Tree::BinaryTreeNode#inordered_each][inordered_each] method.
|
153
|
+
|
154
|
+
* Ability to merge in another tree at a chosen node, or merge two trees to
|
155
|
+
create a third tree. Thanks to [Darren Oakley][Darren] for this [pr-2][].
|
156
|
+
|
157
|
+
* RubyTree now mixes in the [Comparable][] module.
|
158
|
+
|
159
|
+
#### The Fixes
|
160
|
+
|
161
|
+
* (_Partial_) fix for preventing cyclic graphs in the tree.
|
162
|
+
|
163
|
+
* Refactored the [Tree::TreeNode#each][each] method to prevent stack errors while
|
164
|
+
navigating deep trees ([bug-12][]).
|
165
|
+
|
166
|
+
* Check to ensure that the added node's name is unique to the destination tree
|
167
|
+
([pr-9][]). Thanks to [Youssef Rebahi-Gilbert][Youssef] for the idea and the
|
168
|
+
initial code.
|
169
|
+
|
170
|
+
* Fix for [bug-23][], where the tree traversal on a binary tree would fail if
|
171
|
+
the _left_ child was `nil`.
|
172
|
+
|
173
|
+
* The following traversal methods now correctly return an
|
174
|
+
[Enumerator][] as the return value when no block is given, and
|
175
|
+
return the _receiver node_ if a block was provided. This is consistent with
|
176
|
+
how the standard Ruby collections work.
|
177
|
+
|
178
|
+
* [Tree::TreeNode#each][each],
|
179
|
+
* [Tree::TreeNode#preordered_each][preordered_each],
|
180
|
+
* [Tree::TreeNode#postordered_each][postordered_each] and
|
181
|
+
* [Tree::TreeNode#breadth_each][breadth_each].
|
182
|
+
|
183
|
+
#### Other Changes
|
184
|
+
|
185
|
+
* Structural changes in the code to refactor out the non-core functions into
|
186
|
+
modules (mostly by extracting out non-core code as `mixins`).
|
187
|
+
|
188
|
+
* Significant refactoring of the documentation. The [Yard][] tags are now
|
189
|
+
extensively used.
|
190
|
+
|
191
|
+
* Basic support built-in for including example code in the gem. This will be
|
192
|
+
fully expanded in the next release.
|
193
|
+
|
194
|
+
* Various changes to the [Bundler][], [travis-ci][] and other `Rakefile`
|
195
|
+
changes.
|
196
|
+
|
197
|
+
### 0.8.3 / 2012-08-21
|
198
|
+
|
199
|
+
This is a primarily a bug-fix release, with some packaging changes.
|
200
|
+
|
201
|
+
* Have removed the dependency on [Hoe][]. The build is now based on vanilla
|
202
|
+
[gemspec][].
|
203
|
+
|
204
|
+
* Included support for [gem-testers][].
|
205
|
+
|
206
|
+
* Included support for [Bundler][].
|
207
|
+
|
208
|
+
* Implemented the [Tree::Utils::JSONConverter#as_json][as_json] method to
|
209
|
+
support Rails' `JSON` encoding, by pulling in the changes from [Eric Cline][Eric].
|
210
|
+
|
211
|
+
* Partial fix for [bug-5][]. This is to prevent infinite looping if an existing
|
212
|
+
node is added again elsewhere in the tree.
|
213
|
+
|
214
|
+
* Fixed the issue with using `integers` as node names, and its interaction
|
215
|
+
with the `Tree::TreeNode#[]` access method as documented in [bug-6][].
|
216
|
+
|
217
|
+
* Clarified the need to have _unique_ node names in the documentation ([bug-7][]).
|
218
|
+
|
219
|
+
* Fixed [Tree::TreeNode#siblings][siblings] method to return an _empty_ array
|
220
|
+
for the root node as well (it returned `nil` earlier).
|
221
|
+
|
222
|
+
### 0.8.2 / 2011-12-15
|
223
|
+
|
224
|
+
* Minor bug-fix release to address [bug-1215][] ([Tree::TreeNode#to_s][to_s]
|
225
|
+
breaks if `@content` or `@parent.name` is not a string).
|
226
|
+
|
227
|
+
### 0.8.1 / 2010-10-02
|
228
|
+
|
229
|
+
* This is the public release of `R0.8.0`, with additional bug-fixes. Note that
|
230
|
+
`R0.8.0` will **not be** released separately as a publicly available
|
231
|
+
Rubygem. All changes as listed for `R0.8.0` are available in this release.
|
232
|
+
|
233
|
+
* The main change in `R0.8.0`/`R0.8.1` is conversion of all `CamelCase` method
|
234
|
+
names to `snake_case`. The old `CamelCase` method names will _still_ work (to
|
235
|
+
ensure backwards compatibility), but will also display a warning.
|
236
|
+
|
237
|
+
* The [Tree::TreeNode#add][add] method now accepts an _optional_ child insertion
|
238
|
+
point.
|
239
|
+
|
240
|
+
* The sub-tree from the current node can now be cloned in its _entirety_ using
|
241
|
+
the [Tree::TreeNode#detached_subtree_copy][detached_subtree_copy] method.
|
242
|
+
|
243
|
+
* A major bug-fix for [bug-28613][] which impacted the `Binarytree`
|
244
|
+
implementation.
|
245
|
+
|
246
|
+
* Minor code re-factoring driven by the code-smell checks using
|
247
|
+
[reek][].
|
248
|
+
|
249
|
+
* Inclusion of the `reek` code-smell detection tool in the `Rakefile`.
|
250
|
+
|
251
|
+
### 0.8.0 / 2010-05-04
|
252
|
+
|
253
|
+
* Updated the [Tree::TreeNode#add][add] method to allow the optional
|
254
|
+
specification of an insertion position in the child array.
|
255
|
+
|
256
|
+
* Added a new method
|
257
|
+
[Tree::TreeNode#detached_subtree_copy][detached_subtree_copy] to allow cloning
|
258
|
+
the entire tree (this method is also aliased as `dup`).
|
259
|
+
|
260
|
+
* Converted all `CamelCase` method names to the canonical `ruby_method_names`
|
261
|
+
(underscore separated). The `CamelCase` methods _can still_ be invoked, but
|
262
|
+
will throw a [Deprecated Warning][dep-warning]. The support for old
|
263
|
+
`CamelCase` methods **will** go away some time in the future, so the user is
|
264
|
+
advised to convert all current method invocations to the new names.
|
265
|
+
|
266
|
+
### 0.7.0 / 2010-05-03
|
267
|
+
|
268
|
+
* Added new methods to report the degree-statistics of a node.
|
269
|
+
|
270
|
+
* Added a convenience method alias [Tree::TreeNode#level][level] to `nodeDepth`.
|
271
|
+
|
272
|
+
* Converted the exceptions thrown on invalid arguments to [ArgumentError][]
|
273
|
+
instead of [RuntimeError][].
|
274
|
+
|
275
|
+
* Converted the documentation to [Yard][] format.
|
276
|
+
|
277
|
+
* Added new methods for converting to/from [JSON][] format. Thanks to Dirk
|
278
|
+
[Breuer][] for this [fork](http://github.com/galaxycats/).
|
279
|
+
|
280
|
+
* Added a separate [API-CHANGES.md](file:API-CHANGES.md) documentation file.
|
281
|
+
|
282
|
+
* Added fixes for root related edge conditions to the:
|
283
|
+
|
284
|
+
* [Tree::TreeNode#is_only_child?][is_only_child],
|
285
|
+
* [Tree::TreeNode#next_sibling][next_sibling],
|
286
|
+
* [Tree::TreeNode#previous_sibling][previous_sibling] and
|
287
|
+
* [Tree::TreeNode#remove!][remove] methods.
|
288
|
+
|
289
|
+
* Removed the `ChangeLog` file as this can now be generated from the git logs.
|
290
|
+
|
291
|
+
* Other minor code cleanup.
|
292
|
+
|
293
|
+
### 0.6.2 / 2010-01-30
|
294
|
+
|
295
|
+
* Updated the documentation.
|
296
|
+
|
297
|
+
### 0.6.1 / 2010-01-04
|
298
|
+
|
299
|
+
* Changed the hard-dependency on the [structured_warnings][] gem to a
|
300
|
+
_soft-dependency_ - which lets `RubyTree` still work if this gem is not
|
301
|
+
available. The rationale for this is that we _should not_ require the user to
|
302
|
+
install a separate library just for _one_ edge-case function (in this case, to
|
303
|
+
indicate a deprecated method). However, if the library *is* available on the
|
304
|
+
user's system, then it **will** get used.
|
305
|
+
|
306
|
+
### 0.6.0 / 2010-01-03
|
307
|
+
|
308
|
+
* Fixed [bug-22535][] where the `Tree::TreeNode#depth` method was actually
|
309
|
+
returning `height+1` (**not** the `depth`).
|
310
|
+
|
311
|
+
* Marked the `Tree::TreeNode#depth` method as **deprecated** (and introduced the
|
312
|
+
run-time dependency on the [structured-warnings][] gem).
|
313
|
+
|
314
|
+
### 0.5.3 / 2009-12-31
|
315
|
+
|
316
|
+
* Cleanup of the build system to exclusively use [Hoe][].
|
317
|
+
* Modifications and reformatting to the documentation.
|
318
|
+
* No user visible changes.
|
319
|
+
|
320
|
+
### 0.5.2 / 2007-12-21
|
321
|
+
|
322
|
+
* Added more test cases and enabled [ZenTest][] compatibility for the test case
|
323
|
+
names.
|
324
|
+
|
325
|
+
### 0.5.1 / 2007-12-20
|
326
|
+
|
327
|
+
* Minor code refactoring.
|
328
|
+
|
329
|
+
### 0.5.0 / 2007-12-18
|
330
|
+
|
331
|
+
* Fixed the marshalling code to correctly handle non-string content.
|
332
|
+
|
333
|
+
### 0.4.3 / 2007-10-09
|
334
|
+
|
335
|
+
* Changes to the build mechanism (now uses [Hoe]).
|
336
|
+
|
337
|
+
### 0.4.2 / 2007-10-01
|
338
|
+
|
339
|
+
* Minor code refactoring. Changes in the `Rakefile`.
|
340
|
+
|
341
|
+
[bug-5]: https://github.com/evolve75/RubyTree/issues/5
|
342
|
+
[bug-6]: https://github.com/evolve75/RubyTree/issues/6
|
343
|
+
[bug-7]: https://github.com/evolve75/RubyTree/issues/7
|
344
|
+
[bug-12]: https://github.com/evolve75/RubyTree/issues/12
|
345
|
+
[bug-13]: https://github.com/evolve75/RubyTree/issues/13
|
346
|
+
[bug-23]: https://github.com/evolve75/RubyTree/issues/23
|
347
|
+
[bug-24]: https://github.com/evolve75/RubyTree/issues/24
|
348
|
+
[bug-31]: https://github.com/evolve75/RubyTree/issues/31
|
349
|
+
[bug-32]: https://github.com/evolve75/RubyTree/issues/32
|
350
|
+
[bug-1215]: http://rubyforge.org/tracker/index.php?func=detail&aid=1215&group_id=1215&atid=4793
|
351
|
+
[bug-28613]: http://rubyforge.org/tracker/index.php?func=detail&aid=28613&group_id=1215&atid=4793
|
352
|
+
[bug-22535]: http://rubyforge.org/tracker/index.php?func=detail&aid=22535&group_id=1215&atid=4793
|
353
|
+
|
354
|
+
[pr-2]: https://github.com/evolve75/RubyTree/pull/2
|
355
|
+
[pr-9]: https://github.com/evolve75/RubyTree/pull/9
|
356
|
+
[pr-35]: https://github.com/evolve75/RubyTree/pull/35
|
357
|
+
|
358
|
+
[ArgumentError]: http://www.ruby-doc.org/core-2.0.0/ArgumentError.html
|
359
|
+
[Bundler]: https://bundler.io
|
360
|
+
[Comparable]: http://ruby-doc.org/core-1.8.7/Comparable.html
|
361
|
+
[Enumerator]: http://ruby-doc.org/core-1.8.7/Enumerable.html
|
362
|
+
[Hoe]: http://www.zenspider.com/projects/hoe.html
|
363
|
+
[JSON]: http://www.json.org
|
364
|
+
[RuntimeError]: http://www.ruby-doc.org/core-2.0.0/RuntimeError.html
|
365
|
+
[Yard]: http://yardoc.org
|
366
|
+
[ZenTest]: https://github.com/seattlerb/zentest
|
367
|
+
[dep-warning]: http://rug-b.rubyforge.org/structured_warnings/rdoc/
|
368
|
+
[gem-testers]: https://test.rubygems.org/
|
369
|
+
[gemspec]: https://guides.rubygems.org/specification-reference/
|
370
|
+
[reek]: https://github.com/troessner/reek
|
371
|
+
[structured-warnings]: http://github.com/schmidt/structured_warnings
|
372
|
+
[travis-ci]: https://travis-ci.org
|
373
|
+
[workflow]: https://docs.github.com/en/actions/using-workflows
|
374
|
+
|
375
|
+
[Aidan]: https://github.com/aidansteele
|
376
|
+
[Breuer]: http://github.com/railsbros-dirk
|
377
|
+
[Darren]: https://github.com/dazoakley
|
378
|
+
[Eric]: https://github.com/escline
|
379
|
+
[Evan]: https://github.com/packetmonkey
|
380
|
+
[Marco]: https://github.com/MZic
|
381
|
+
[Ojab]: https://github.com/ojab
|
382
|
+
[Paul]: https://github.com/pdecourcel
|
383
|
+
[Youssef]: https://github.com/ysf
|
384
|
+
[igneus]: https://github.com/igneus
|
385
|
+
[jack12816]: https://github.com/jack12816
|
386
|
+
[jhamon]: https://www.github.com/jhamon
|
387
|
+
[jmortlock]: https://github.com/jmortlock
|
388
|
+
|
389
|
+
[TreeNode]: rdoc-ref:Tree::TreeNode
|
390
|
+
[TreePathHandler]: Tree::Utils::TreePathHandler
|
391
|
+
[add]: rdoc-ref:Tree::TreeNode#add
|
392
|
+
[as_json]: rdoc-ref:Tree::Utils::JSONConverter#as_json
|
393
|
+
[breadth_each]: rdoc-ref:Tree::TreeNode#breadth_each
|
394
|
+
[detached_subtree_copy]: rdoc-ref:Tree::TreeNode#detached_subtree_copy
|
395
|
+
[each]: rdoc-ref:Tree::TreeNode#each
|
396
|
+
[inordered_each]: rdoc-ref:Tree::BinaryTreeNode#inordered_each
|
397
|
+
[is_only_child]: rdoc-ref:Tree::TreeNode#is_only_child?
|
398
|
+
[is_root]: rdoc-ref:Tree::TreeNode#is_root?
|
399
|
+
[level]: rdoc-ref:Tree::TreeNode#level
|
400
|
+
[mnode_depth]: rdoc-ref:Tree::Utils::TreeMetricsHandler#node_depth
|
401
|
+
[next_sibling]: rdoc-ref:Tree::TreeNode#next_sibling
|
402
|
+
[node_depth]: rdoc-ref:Tree::TreeNode#node_depth
|
403
|
+
[postordered_each]: rdoc-ref:Tree::TreeNode#postordered_each
|
404
|
+
[previous_sibling]: rdoc-ref:Tree::TreeNode#previous_sibling
|
405
|
+
[print_tree]: rdoc-ref:Tree::TreeNode#print_tree
|
406
|
+
[remove]: rdoc-ref:Tree::TreeNode#remove!
|
407
|
+
[rename]: rdoc-ref:Tree::TreeNode#rename
|
408
|
+
[rename_child]: rdoc-ref:Tree::TreeNode#rename_child
|
409
|
+
[siblings]: rdoc-ref:Tree::TreeNode#siblings
|
410
|
+
[to_s]: rdoc-ref:Tree::TreeNode#to_s
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
<!--
|
2
|
-
README.md
|
3
|
-
|
4
|
-
Copyright (C) 2006-2017, 2020 Anupam Sengupta (anupamsg@gmail.com)
|
5
|
-
|
6
|
-
-->
|
7
1
|
# **RubyTree** #
|
8
2
|
|
9
3
|
[![Gem Version](https://badge.fury.io/rb/rubytree.png)](http://badge.fury.io/rb/rubytree)
|
10
|
-
[![Travis Build Status](https://secure.travis-ci.org/evolve75/RubyTree.png)](http://travis-ci.org/evolve75/rubytree)
|
11
4
|
[![Code Climate](https://codeclimate.com/github/evolve75/RubyTree.png)](https://codeclimate.com/github/evolve75/RubyTree)
|
12
5
|
[![Coverage Status](https://coveralls.io/repos/evolve75/RubyTree/badge.png)](https://coveralls.io/r/evolve75/RubyTree)
|
13
6
|
|
@@ -39,9 +32,9 @@ The home page for **RubyTree** is at [rubytree.anupamsg.me][rt_site].
|
|
39
32
|
|
40
33
|
## WHAT'S NEW: ##
|
41
34
|
|
42
|
-
See [History](./History.
|
35
|
+
See [History](./History.md) for the detailed Changelog.
|
43
36
|
|
44
|
-
See [API-CHANGES](./API-CHANGES.
|
37
|
+
See [API-CHANGES](./API-CHANGES.md) for the detailed description of
|
45
38
|
API level changes.
|
46
39
|
|
47
40
|
## GETTING STARTED: ##
|
@@ -54,9 +47,7 @@ See the [API][rt_doc] documentation for more details.
|
|
54
47
|
#
|
55
48
|
# example_basic.rb:: Basic usage of the tree library.
|
56
49
|
#
|
57
|
-
#
|
58
|
-
# Time-stamp: <2013-12-28 12:14:20 anupam>
|
59
|
-
# Copyright (C) 2013 Anupam Sengupta <anupamsg@gmail.com>
|
50
|
+
# Copyright (C) 2013-2022 Anupam Sengupta <anupamsg@gmail.com>
|
60
51
|
#
|
61
52
|
# The following example implements this tree structure:
|
62
53
|
#
|
@@ -119,19 +110,21 @@ This example can also be found at
|
|
119
110
|
|
120
111
|
## REQUIREMENTS: ##
|
121
112
|
|
122
|
-
* [Ruby][] 2.
|
113
|
+
* [Ruby][] 2.6.x and above.
|
123
114
|
|
124
115
|
|
125
116
|
* Run-time Dependencies:
|
126
|
-
|
117
|
+
|
127
118
|
* [JSON][] for converting to/from the JSON format
|
128
119
|
|
129
120
|
|
130
121
|
* Development dependencies (not required for installing the gem):
|
122
|
+
|
131
123
|
* [Bundler][] for creating the stable build environment
|
132
124
|
* [Rake][] for building the package
|
133
125
|
* [Yard][] for the documentation
|
134
126
|
* [RSpec][] for additional Ruby Spec test files
|
127
|
+
* [Rubocop][] for linting the code
|
135
128
|
|
136
129
|
## INSTALL: ##
|
137
130
|
|
@@ -144,7 +137,7 @@ have super-user privileges (root/sudo) to successfully install the gem.
|
|
144
137
|
|
145
138
|
## DOCUMENTATION: ##
|
146
139
|
|
147
|
-
The primary class **RubyTree** is
|
140
|
+
The primary class **RubyTree** is [Tree::TreeNode][TreeNode]. See the class
|
148
141
|
documentation for an example of using the library.
|
149
142
|
|
150
143
|
If the *ri* documentation was generated during install, you can use this
|
@@ -180,11 +173,11 @@ The git repository is available at [github.com/evolve75/RubyTree][rt@github].
|
|
180
173
|
|
181
174
|
For cloning the git repository, use one of the following commands:
|
182
175
|
|
183
|
-
$ git clone git://github.com/evolve75/RubyTree.git
|
176
|
+
$ git clone git://github.com/evolve75/RubyTree.git # using ssh
|
184
177
|
|
185
178
|
or
|
186
179
|
|
187
|
-
$ git clone
|
180
|
+
$ git clone https://github.com/evolve75/RubyTree.git # using https
|
188
181
|
|
189
182
|
### Setting up the Development Environment ###
|
190
183
|
|
@@ -195,9 +188,9 @@ After checking out the source, run:
|
|
195
188
|
|
196
189
|
$ gem install bundler
|
197
190
|
$ bundle install
|
198
|
-
$ rake test
|
199
|
-
$ rake doc:yard
|
200
|
-
$ rake gem:package
|
191
|
+
$ bundle exec rake test:all
|
192
|
+
$ bundle exec rake doc:yard
|
193
|
+
$ bundle exec rake gem:package
|
201
194
|
|
202
195
|
These steps will install any missing dependencies, run the tests/specs,
|
203
196
|
generate the documentation, and finally generate the gem file.
|
@@ -225,14 +218,18 @@ A big thanks to the following contributors for helping improve **RubyTree**:
|
|
225
218
|
to `is_root?` and `node_depth`.
|
226
219
|
10. [Marco Ziccadi](https://github.com/MZic) for adding the `path_as_string` and
|
227
220
|
`path_as_array` methods.
|
221
|
+
11. [John Mortlock](https://github.com/jmortlock) for significant modernization
|
222
|
+
of the library code and addition of Github `workflows`.
|
223
|
+
12. [Hermann Mayer](https://github.com/jack12816) for adding support for
|
224
|
+
specialized tree nodes (sub-classes of `Tree::TreeNode`).
|
225
|
+
13. [Jakub Pavlik](https://github.com/igneus) for fixing the creation of
|
226
|
+
detached copies of unclonable objects such as `:symbol`, `true|false`, etc.
|
228
227
|
|
229
228
|
## LICENSE: ##
|
230
229
|
|
231
230
|
**RubyTree** is licensed under the terms of the [BSD][] license. See
|
232
231
|
[LICENSE.md](./LICENSE.md) for details.
|
233
232
|
|
234
|
-
{include:file:LICENSE.md}
|
235
|
-
|
236
233
|
__ _ _
|
237
234
|
/__\_ _| |__ _ _| |_ _ __ ___ ___
|
238
235
|
/ \// | | | '_ \| | | | __| '__/ _ \/ _ \
|
@@ -261,8 +258,8 @@ A big thanks to the following contributors for helping improve **RubyTree**:
|
|
261
258
|
[rt_doc]: http://rubytree.anupamsg.me/rdoc "RubyTree Documentation"
|
262
259
|
[rt_gem]: http://rubygems.org/gems/rubytree "RubyTree Gem"
|
263
260
|
[rt_site]: http://rubytree.anupamsg.me "RubyTree Site"
|
264
|
-
[structured_warnings]: http://github.com/schmidt/structured_warnings "structured_warnings"
|
265
261
|
[tree_data_structure]: http://en.wikipedia.org/wiki/Tree_data_structure "Tree Data Structure"
|
266
262
|
[RSpec]: https://relishapp.com/rspec/
|
263
|
+
[Rubocop]: https://rubocop.org
|
267
264
|
|
268
|
-
[
|
265
|
+
[TreeNode]: rdoc-ref:Tree::TreeNode
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Rakefile - This file is part of the RubyTree package.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2022 Anupam Sengupta
|
6
6
|
#
|
7
7
|
# All rights reserved.
|
8
8
|
#
|
@@ -31,9 +31,13 @@
|
|
31
31
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
32
32
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
33
|
#
|
34
|
+
#
|
35
|
+
# frozen_string_literal: true
|
34
36
|
|
35
37
|
require 'rubygems'
|
36
|
-
|
38
|
+
|
39
|
+
# @todo: Check if Bundler needs to be `require`d.
|
40
|
+
GEM_SPEC = Bundler.load_gemspec(File.join(__dir__, 'rubytree.gemspec'))
|
37
41
|
|
38
42
|
PKG_NAME = GEM_SPEC.name
|
39
43
|
PKG_VER = GEM_SPEC.version
|
@@ -55,6 +59,7 @@ task :version do
|
|
55
59
|
end
|
56
60
|
|
57
61
|
require 'rake/clean'
|
62
|
+
desc 'Remove all generated files.'
|
58
63
|
task clean: 'gem:clobber_package'
|
59
64
|
CLEAN.include('coverage')
|
60
65
|
task clobber: [:clean, 'doc:clobber_rdoc', 'doc:clobber_yard']
|
@@ -70,8 +75,8 @@ namespace :doc do # ................................ Documentation
|
|
70
75
|
require 'rdoc/task'
|
71
76
|
Rake::RDocTask.new do |rdoc|
|
72
77
|
rdoc.rdoc_dir = 'rdoc'
|
73
|
-
rdoc.title = "#{PKG_NAME}-#{PKG_VER}"
|
74
|
-
rdoc.main = 'README.
|
78
|
+
rdoc.title = "RubyTree Documenation: #{PKG_NAME}-#{PKG_VER}"
|
79
|
+
rdoc.main = 'README.md'
|
75
80
|
rdoc.rdoc_files.include(GEM_SPEC.extra_rdoc_files)
|
76
81
|
rdoc.rdoc_files.include('./lib/**/*.rb')
|
77
82
|
end
|
@@ -95,10 +100,14 @@ namespace :doc do # ................................ Documentation
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
98
|
-
desc 'Run the
|
99
|
-
task test:
|
103
|
+
desc 'Run the unit tests'
|
104
|
+
task test: %w[test:unit]
|
105
|
+
|
106
|
+
# ................................ Test related
|
107
|
+
namespace :test do
|
108
|
+
desc 'Run all the tests'
|
109
|
+
task all: %w[test:unit test:spec test:examples]
|
100
110
|
|
101
|
-
namespace :test do # ................................ Test related
|
102
111
|
require 'rake/testtask'
|
103
112
|
Rake::TestTask.new(:unit) do |test|
|
104
113
|
test.libs << 'lib' << 'test'
|
@@ -106,6 +115,18 @@ namespace :test do # ................................ Test related
|
|
106
115
|
test.verbose = false
|
107
116
|
end
|
108
117
|
|
118
|
+
# ................................ rspec tests
|
119
|
+
begin
|
120
|
+
require 'rspec/core/rake_task'
|
121
|
+
|
122
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
123
|
+
t.fail_on_error = false
|
124
|
+
t.rspec_opts = ['--color', '--format doc']
|
125
|
+
end
|
126
|
+
rescue LoadError
|
127
|
+
# Cannot load rspec.
|
128
|
+
end
|
129
|
+
|
109
130
|
desc 'Run the examples'
|
110
131
|
Rake::TestTask.new(:examples) do |example|
|
111
132
|
example.libs << 'lib' << 'examples'
|
@@ -132,18 +153,8 @@ namespace :test do # ................................ Test related
|
|
132
153
|
end
|
133
154
|
end
|
134
155
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
139
|
-
t.fail_on_error = false
|
140
|
-
t.rspec_opts = ['--color', '--format doc']
|
141
|
-
end
|
142
|
-
rescue LoadError
|
143
|
-
# Cannot load rspec.
|
144
|
-
end
|
145
|
-
|
146
|
-
namespace :tag do # ................................ Emacs Tags
|
156
|
+
# ................................ Emacs Tags
|
157
|
+
namespace :tag do
|
147
158
|
require 'rtagstask'
|
148
159
|
RTagsTask.new(:tags) do |rd|
|
149
160
|
rd.vi = false
|
@@ -153,7 +164,8 @@ rescue LoadError
|
|
153
164
|
# Oh well. Can't have everything.
|
154
165
|
end
|
155
166
|
|
156
|
-
|
167
|
+
# ................................ Gem related
|
168
|
+
namespace :gem do
|
157
169
|
require 'rubygems/package_task'
|
158
170
|
Gem::PackageTask.new(GEM_SPEC) do |pkg|
|
159
171
|
pkg.need_zip = true
|
@@ -165,3 +177,12 @@ namespace :gem do # ................................ Gem related
|
|
165
177
|
sh "gem push pkg/#{GEM_NAME}"
|
166
178
|
end
|
167
179
|
end
|
180
|
+
|
181
|
+
# ................................ Ruby linting
|
182
|
+
require 'rubocop/rake_task'
|
183
|
+
|
184
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
185
|
+
t.options = ['--display-cop-names']
|
186
|
+
t.requires << 'rubocop-rake'
|
187
|
+
t.requires << 'rubocop-rspec'
|
188
|
+
end
|