rubytree 0.9.5pre6 → 0.9.5pre7
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.
- checksums.yaml +4 -4
- data/API-CHANGES.rdoc +11 -11
- data/Gemfile.lock +36 -24
- data/History.rdoc +46 -28
- data/LICENSE.md +1 -1
- data/README.md +31 -21
- data/Rakefile +11 -11
- data/TODO.org +2 -0
- data/gem_graph.png +0 -0
- data/lib/rubytree.rb +13 -13
- data/lib/tree.rb +127 -75
- data/lib/tree/binarytree.rb +48 -31
- data/lib/tree/tree_deps.rb +15 -14
- data/lib/tree/utils/camel_case_method_handler.rb +16 -15
- data/lib/tree/utils/hash_converter.rb +35 -21
- data/lib/tree/utils/json_converter.rb +18 -16
- data/lib/tree/utils/metrics_methods.rb +33 -24
- data/lib/tree/utils/path_methods.rb +92 -0
- data/lib/tree/utils/tree_merge_handler.rb +34 -23
- data/lib/tree/utils/utils.rb +14 -14
- data/lib/tree/version.rb +13 -13
- data/rubytree.gemspec +88 -0
- data/setup.rb +1585 -0
- data/test/test_subclassed_node.rb +5 -0
- data/test/test_tree.rb +73 -0
- metadata +8 -4
@@ -4,21 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# Author:: Anupam Sengupta (anupamsg@gmail.com)
|
6
6
|
#
|
7
|
-
# Time-stamp: <
|
7
|
+
# Time-stamp: <2015-05-30 14:23:23 anupam>
|
8
8
|
#
|
9
|
-
# Copyright (C) 2013 Anupam Sengupta <anupamsg@gmail.com>
|
9
|
+
# Copyright (C) 2013, 2015 Anupam Sengupta <anupamsg@gmail.com>
|
10
10
|
#
|
11
11
|
# All rights reserved.
|
12
12
|
#
|
13
|
-
# Redistribution and use in source and binary forms, with or without
|
14
|
-
# are permitted provided that the following conditions are met:
|
13
|
+
# Redistribution and use in source and binary forms, with or without
|
14
|
+
# modification, are permitted provided that the following conditions are met:
|
15
15
|
#
|
16
16
|
# - Redistributions of source code must retain the above copyright notice, this
|
17
17
|
# list of conditions and the following disclaimer.
|
18
18
|
#
|
19
|
-
# - Redistributions in binary form must reproduce the above copyright notice,
|
20
|
-
# list of conditions and the following disclaimer in the documentation
|
21
|
-
# other materials provided with the distribution.
|
19
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
20
|
+
# this list of conditions and the following disclaimer in the documentation
|
21
|
+
# and/or other materials provided with the distribution.
|
22
22
|
#
|
23
23
|
# - Neither the name of the organization nor the names of its contributors may
|
24
24
|
# be used to endorse or promote products derived from this software without
|
@@ -27,13 +27,13 @@
|
|
27
27
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
28
28
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
29
29
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
31
|
-
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
-
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
33
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
34
|
-
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
35
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
36
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
31
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
33
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
34
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
35
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
36
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
37
37
|
#
|
38
38
|
|
39
39
|
require 'structured_warnings'
|
@@ -60,7 +60,8 @@ module Tree::Utils
|
|
60
60
|
# @!attribute [r] length
|
61
61
|
# Convenience synonym for {#size}.
|
62
62
|
#
|
63
|
-
# @deprecated This method name is ambiguous and may be removed.
|
63
|
+
# @deprecated This method name is ambiguous and may be removed. Use
|
64
|
+
# {#size} instead.
|
64
65
|
#
|
65
66
|
# @return [Integer] The total number of nodes in this (sub)tree.
|
66
67
|
# @see #size
|
@@ -85,16 +86,19 @@ module Tree::Utils
|
|
85
86
|
# @!attribute [r] node_depth
|
86
87
|
# Depth of this node in its tree. Depth of a node is defined as:
|
87
88
|
#
|
88
|
-
# Depth:: Length of the node's path to its root.
|
89
|
+
# Depth:: Length of the node's path to its root. Depth of a root node is
|
90
|
+
# zero.
|
89
91
|
#
|
90
|
-
# *Note* that the deprecated method {#depth} was incorrectly computing
|
91
|
-
# Please replace all calls to the old method with
|
92
|
+
# *Note* that the deprecated method {#depth} was incorrectly computing
|
93
|
+
# this value. Please replace all calls to the old method with
|
94
|
+
# {#node_depth} instead.
|
92
95
|
#
|
93
96
|
# {#level} is an alias for this method.
|
94
97
|
#
|
95
98
|
# @return [Integer] Depth of this node.
|
96
99
|
def node_depth
|
97
|
-
|
100
|
+
return 0 if is_root?
|
101
|
+
1 + parent.node_depth
|
98
102
|
end
|
99
103
|
|
100
104
|
# @!attribute [r] level
|
@@ -108,8 +112,8 @@ module Tree::Utils
|
|
108
112
|
# @!attribute [r] depth
|
109
113
|
# Depth of the tree from this node. A single leaf node has a depth of 1.
|
110
114
|
#
|
111
|
-
# This method is *DEPRECATED* and may be removed in the subsequent
|
112
|
-
# Note that the value returned by this method is actually the:
|
115
|
+
# This method is *DEPRECATED* and may be removed in the subsequent
|
116
|
+
# releases. Note that the value returned by this method is actually the:
|
113
117
|
#
|
114
118
|
# _height_ + 1 of the node, *NOT* the _depth_.
|
115
119
|
#
|
@@ -117,11 +121,15 @@ module Tree::Utils
|
|
117
121
|
# {#node_height} methods instead.
|
118
122
|
#
|
119
123
|
# @return [Integer] depth of the node.
|
120
|
-
#
|
124
|
+
#
|
125
|
+
# @deprecated This method returns an incorrect value. Use the
|
126
|
+
# {#node_depth} method instead.
|
121
127
|
#
|
122
128
|
# @see #node_depth
|
123
129
|
def depth
|
124
|
-
warn DeprecatedMethodWarning,
|
130
|
+
warn DeprecatedMethodWarning,
|
131
|
+
"This method is deprecated. "\
|
132
|
+
"Please use node_depth() or node_height() instead (bug # 22535)"
|
125
133
|
|
126
134
|
return 1 if is_leaf?
|
127
135
|
1 + @children.collect { |child| child.depth }.max
|
@@ -144,7 +152,8 @@ module Tree::Utils
|
|
144
152
|
# The incoming edge-count of this node.
|
145
153
|
#
|
146
154
|
# In-degree is defined as:
|
147
|
-
# In-degree:: Number of edges arriving at the node (0 for root, 1 for
|
155
|
+
# In-degree:: Number of edges arriving at the node (0 for root, 1 for
|
156
|
+
# all other nodes)
|
148
157
|
#
|
149
158
|
# - In-degree = 0 for a root or orphaned node
|
150
159
|
# - In-degree = 1 for a node which has a parent
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# path_methods.rb - This file is part of the RubyTree package.
|
2
|
+
#
|
3
|
+
# = path_methods.rb - Provides methods for extracting the node path.
|
4
|
+
#
|
5
|
+
# Author:: Marco Ziccardi and Anupam Sengupta (anupamsg@gmail.com)
|
6
|
+
#
|
7
|
+
# Time-stamp: <2015-05-30 16:04:00 anupam>
|
8
|
+
#
|
9
|
+
# Copyright (C) 2015 Anupam Sengupta <anupamsg@gmail.com>
|
10
|
+
#
|
11
|
+
# All rights reserved.
|
12
|
+
#
|
13
|
+
# Redistribution and use in source and binary forms, with or without
|
14
|
+
# modification, are permitted provided that the following conditions are met:
|
15
|
+
#
|
16
|
+
# - Redistributions of source code must retain the above copyright notice, this
|
17
|
+
# list of conditions and the following disclaimer.
|
18
|
+
#
|
19
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
20
|
+
# this list of conditions and the following disclaimer in the documentation
|
21
|
+
# and/or other materials provided with the distribution.
|
22
|
+
#
|
23
|
+
# - Neither the name of the organization nor the names of its contributors may
|
24
|
+
# be used to endorse or promote products derived from this software without
|
25
|
+
# specific prior written permission.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
28
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
29
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
31
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
33
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
34
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
35
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
36
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
37
|
+
#
|
38
|
+
|
39
|
+
module Tree::Utils
|
40
|
+
# Provides utility methods for path extraction
|
41
|
+
module TreePathHandler
|
42
|
+
def self.included(base)
|
43
|
+
|
44
|
+
# @!group Node Path
|
45
|
+
|
46
|
+
# Returns the path of this node from the root as a string, with the node
|
47
|
+
# names separated using the specified separator. The path is listed left
|
48
|
+
# to right from the root node.
|
49
|
+
#
|
50
|
+
# @param separator The optional separator to use. The default separator is
|
51
|
+
# '+=>+'.
|
52
|
+
#
|
53
|
+
# @return [String] The node path with names separated using the specified
|
54
|
+
# separator.
|
55
|
+
def path_as_string(separator = '=>')
|
56
|
+
path_as_array().join(separator)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns the node-names from this node to the root as an array. The first
|
60
|
+
# element is the root node name, and the last element is this node's name.
|
61
|
+
#
|
62
|
+
# @return [Array] The array containing the node names for the path to this
|
63
|
+
# node
|
64
|
+
def path_as_array()
|
65
|
+
get_path_name_array().reverse
|
66
|
+
end
|
67
|
+
|
68
|
+
# @!visibility private
|
69
|
+
#
|
70
|
+
# Returns the path names in an array. The first element is the name of
|
71
|
+
# this node, and the last element is the root node name.
|
72
|
+
#
|
73
|
+
# @return [Array] An array of the node names for the path from this node
|
74
|
+
# to its root.
|
75
|
+
def get_path_name_array(current_array_path = [])
|
76
|
+
path_array = current_array_path + [name]
|
77
|
+
|
78
|
+
if !parent # If detached node or root node.
|
79
|
+
return path_array
|
80
|
+
else # Else recurse to parent node.
|
81
|
+
path_array = parent.get_path_name_array(path_array)
|
82
|
+
return path_array
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
protected :get_path_name_array
|
87
|
+
|
88
|
+
# @!endgroup
|
89
|
+
end # self.included
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -3,21 +3,21 @@
|
|
3
3
|
# tree_merge_handler.rb
|
4
4
|
#
|
5
5
|
# Author: Anupam Sengupta
|
6
|
-
# Time-stamp: <
|
6
|
+
# Time-stamp: <2015-05-30 16:06:18 anupam>
|
7
7
|
#
|
8
|
-
# Copyright (C) 2013 Anupam Sengupta (anupamsg@gmail.com)
|
8
|
+
# Copyright (C) 2013, 2015 Anupam Sengupta (anupamsg@gmail.com)
|
9
9
|
#
|
10
10
|
# All rights reserved.
|
11
11
|
#
|
12
|
-
# Redistribution and use in source and binary forms, with or without
|
13
|
-
# are permitted provided that the following conditions are met:
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
14
|
#
|
15
15
|
# - Redistributions of source code must retain the above copyright notice, this
|
16
16
|
# list of conditions and the following disclaimer.
|
17
17
|
#
|
18
|
-
# - Redistributions in binary form must reproduce the above copyright notice,
|
19
|
-
# list of conditions and the following disclaimer in the documentation
|
20
|
-
# other materials provided with the distribution.
|
18
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
19
|
+
# this list of conditions and the following disclaimer in the documentation
|
20
|
+
# and/or other materials provided with the distribution.
|
21
21
|
#
|
22
22
|
# - Neither the name of the organization nor the names of its contributors may
|
23
23
|
# be used to endorse or promote products derived from this software without
|
@@ -26,13 +26,13 @@
|
|
26
26
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
27
27
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
28
28
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
29
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
30
|
-
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
31
|
-
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
32
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
33
|
-
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
34
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
35
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
30
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
31
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
32
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
33
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
34
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
35
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
36
|
#
|
37
37
|
|
38
38
|
# Provides utility methods to merge two {Tree::TreeNode} based trees.
|
@@ -41,7 +41,8 @@ module Tree::Utils::TreeMergeHandler
|
|
41
41
|
|
42
42
|
# @!group Merging Trees
|
43
43
|
|
44
|
-
# Merge two trees that share the same root node and returns <em>a new
|
44
|
+
# Merge two trees that share the same root node and returns <em>a new
|
45
|
+
# tree</em>.
|
45
46
|
#
|
46
47
|
# The new tree contains the contents of the merge between _other_tree_ and
|
47
48
|
# self. Duplicate nodes (coming from _other_tree_) will *NOT* be overwritten
|
@@ -52,11 +53,15 @@ module Tree::Utils::TreeMergeHandler
|
|
52
53
|
# @param [Tree::TreeNode] other_tree The other tree to merge with.
|
53
54
|
# @return [Tree::TreeNode] the resulting tree following the merge.
|
54
55
|
#
|
55
|
-
# @raise [TypeError] This exception is raised if _other_tree_ is not a
|
56
|
-
#
|
56
|
+
# @raise [TypeError] This exception is raised if _other_tree_ is not a
|
57
|
+
# {Tree::TreeNode}.
|
58
|
+
#
|
59
|
+
# @raise [ArgumentError] This exception is raised if _other_tree_ does not
|
60
|
+
# have the same root node as self.
|
57
61
|
def merge(other_tree)
|
58
62
|
check_merge_prerequisites(other_tree)
|
59
|
-
new_tree = merge_trees(
|
63
|
+
new_tree = merge_trees(self.root.dup, other_tree.root)
|
64
|
+
return new_tree
|
60
65
|
end
|
61
66
|
|
62
67
|
# Merge in another tree (that shares the same root node) into +this+ tree.
|
@@ -67,8 +72,11 @@ module Tree::Utils::TreeMergeHandler
|
|
67
72
|
#
|
68
73
|
# @param [Tree::TreeNode] other_tree The other tree to merge with.
|
69
74
|
#
|
70
|
-
# @raise [TypeError] This exception is raised if _other_tree_ is not a
|
71
|
-
#
|
75
|
+
# @raise [TypeError] This exception is raised if _other_tree_ is not a
|
76
|
+
# {Tree::TreeNode}.
|
77
|
+
#
|
78
|
+
# @raise [ArgumentError] This exception is raised if _other_tree_ does not
|
79
|
+
# have the same root node as self.
|
72
80
|
def merge!(other_tree)
|
73
81
|
check_merge_prerequisites( other_tree )
|
74
82
|
merge_trees( self.root, other_tree.root )
|
@@ -84,11 +92,13 @@ module Tree::Utils::TreeMergeHandler
|
|
84
92
|
# @see #merge!
|
85
93
|
def check_merge_prerequisites(other_tree)
|
86
94
|
unless other_tree.is_a?(Tree::TreeNode)
|
87
|
-
raise TypeError,
|
95
|
+
raise TypeError,
|
96
|
+
'You can only merge in another instance of Tree::TreeNode'
|
88
97
|
end
|
89
98
|
|
90
99
|
unless self.root.name == other_tree.root.name
|
91
|
-
raise ArgumentError,
|
100
|
+
raise ArgumentError,
|
101
|
+
'Unable to merge trees as they do not share the same root'
|
92
102
|
end
|
93
103
|
end
|
94
104
|
|
@@ -97,7 +107,8 @@ module Tree::Utils::TreeMergeHandler
|
|
97
107
|
# @author Darren Oakley (https://github.com/dazoakley)
|
98
108
|
#
|
99
109
|
# @param [Tree::TreeNode] tree1 The target tree to merge into.
|
100
|
-
# @param [Tree::TreeNode] tree2 The donor tree (that will be merged
|
110
|
+
# @param [Tree::TreeNode] tree2 The donor tree (that will be merged
|
111
|
+
# into target).
|
101
112
|
# @raise [Tree::TreeNode] The merged tree.
|
102
113
|
def merge_trees(tree1, tree2)
|
103
114
|
names1 = tree1.has_children? ? tree1.children.map { |child| child.name } : []
|
data/lib/tree/utils/utils.rb
CHANGED
@@ -4,21 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# Author:: Anupam Sengupta (anupamsg@gmail.com)
|
6
6
|
#
|
7
|
-
# Time-stamp: <
|
7
|
+
# Time-stamp: <2015-05-30 14:25:57 anupam>
|
8
8
|
#
|
9
|
-
# Copyright (C) 2012 Anupam Sengupta <anupamsg@gmail.com>
|
9
|
+
# Copyright (C) 2012, 2015 Anupam Sengupta <anupamsg@gmail.com>
|
10
10
|
#
|
11
11
|
# All rights reserved.
|
12
12
|
#
|
13
|
-
# Redistribution and use in source and binary forms, with or without
|
14
|
-
# are permitted provided that the following conditions are met:
|
13
|
+
# Redistribution and use in source and binary forms, with or without
|
14
|
+
# modification, are permitted provided that the following conditions are met:
|
15
15
|
#
|
16
16
|
# - Redistributions of source code must retain the above copyright notice, this
|
17
17
|
# list of conditions and the following disclaimer.
|
18
18
|
#
|
19
|
-
# - Redistributions in binary form must reproduce the above copyright notice,
|
20
|
-
# list of conditions and the following disclaimer in the documentation
|
21
|
-
# other materials provided with the distribution.
|
19
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
20
|
+
# this list of conditions and the following disclaimer in the documentation
|
21
|
+
# and/or other materials provided with the distribution.
|
22
22
|
#
|
23
23
|
# - Neither the name of the organization nor the names of its contributors may
|
24
24
|
# be used to endorse or promote products derived from this software without
|
@@ -27,13 +27,13 @@
|
|
27
27
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
28
28
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
29
29
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
31
|
-
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
-
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
33
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
34
|
-
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
35
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
36
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
31
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
33
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
34
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
35
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
36
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
37
37
|
|
38
38
|
# Provides utilities and mixin modules for RubyTree.
|
39
39
|
module Tree::Utils
|
data/lib/tree/version.rb
CHANGED
@@ -8,15 +8,15 @@
|
|
8
8
|
#
|
9
9
|
# All rights reserved.
|
10
10
|
#
|
11
|
-
# Redistribution and use in source and binary forms, with or without
|
12
|
-
# are permitted provided that the following conditions are met:
|
11
|
+
# Redistribution and use in source and binary forms, with or without
|
12
|
+
# modification, are permitted provided that the following conditions are met:
|
13
13
|
#
|
14
14
|
# - Redistributions of source code must retain the above copyright notice, this
|
15
15
|
# list of conditions and the following disclaimer.
|
16
16
|
#
|
17
|
-
# - Redistributions in binary form must reproduce the above copyright notice,
|
18
|
-
# list of conditions and the following disclaimer in the documentation
|
19
|
-
# other materials provided with the distribution.
|
17
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
20
|
#
|
21
21
|
# - Neither the name of the organization nor the names of its contributors may
|
22
22
|
# be used to endorse or promote products derived from this software without
|
@@ -25,17 +25,17 @@
|
|
25
25
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
26
26
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
27
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
|
29
|
-
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
30
|
-
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
31
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
32
|
-
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
33
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
34
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
29
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
30
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
31
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
32
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
33
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
34
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35
35
|
#
|
36
36
|
|
37
37
|
#
|
38
38
|
module Tree
|
39
39
|
# Rubytree Package Version
|
40
|
-
VERSION = '0.9.
|
40
|
+
VERSION = '0.9.5pre7'
|
41
41
|
end
|
data/rubytree.gemspec
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# gemspec for the rubytree gem.
|
4
|
+
#
|
5
|
+
# Author:: Anupam Sengupta (anupamsg@gmail.com)
|
6
|
+
#
|
7
|
+
# Copyright (c) 2012, 2013, 2014, 2015 Anupam Sengupta
|
8
|
+
# All rights reserved.
|
9
|
+
|
10
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
11
|
+
require "tree/version"
|
12
|
+
|
13
|
+
Gem::Specification.new do |s|
|
14
|
+
s.name = 'rubytree'
|
15
|
+
s.date = '2015-01-04'
|
16
|
+
s.version = Tree::VERSION
|
17
|
+
s.license = 'BSD'
|
18
|
+
|
19
|
+
s.platform = Gem::Platform::RUBY
|
20
|
+
s.author = 'Anupam Sengupta'
|
21
|
+
s.email = 'anupamsg@gmail.com'
|
22
|
+
s.homepage = 'http://rubytree.anupamsg.me'
|
23
|
+
|
24
|
+
s.required_ruby_version = '>=1.8.7'
|
25
|
+
|
26
|
+
s.summary = %q{A generic tree data structure.}
|
27
|
+
s.description = <<-EOF
|
28
|
+
|
29
|
+
RubyTree is a pure Ruby implementation of the generic tree data structure. It
|
30
|
+
provides a node-based model to store named nodes in the tree, and provides
|
31
|
+
simple APIs to access, modify and traverse the structure.
|
32
|
+
|
33
|
+
The implementation is node-centric, where individual nodes in the tree are the
|
34
|
+
primary structural elements. All common tree-traversal methods (pre-order,
|
35
|
+
post-order, and breadth-first) are supported.
|
36
|
+
|
37
|
+
The library mixes in the Enumerable and Comparable modules to allow access to
|
38
|
+
the tree as a standard collection (iteration, comparison, etc.).
|
39
|
+
|
40
|
+
A Binary tree is also provided, which provides the in-order traversal in
|
41
|
+
addition to the other methods.
|
42
|
+
|
43
|
+
RubyTree supports importing from, and exporting to JSON, and also supports the
|
44
|
+
Ruby's standard object marshaling.
|
45
|
+
|
46
|
+
This is a BSD licensed open source project, and is hosted at
|
47
|
+
http://github.com/evolve75/RubyTree, and is available as a standard gem from
|
48
|
+
http://rubygems.org/gems/rubytree.
|
49
|
+
|
50
|
+
The home page for RubyTree is at http://rubytree.anupamsg.me.
|
51
|
+
|
52
|
+
EOF
|
53
|
+
|
54
|
+
s.files = Dir['lib/**/*.rb'] # The actual code
|
55
|
+
s.files += Dir['[A-Z]*'] # Various documentation files
|
56
|
+
s.files += Dir['test/**/*.rb'] # Test cases
|
57
|
+
s.files += Dir['examples/**/*.rb'] # Examples
|
58
|
+
|
59
|
+
s.files += ['.gemtest'] # Support for gem-test
|
60
|
+
|
61
|
+
s.require_paths = ['lib']
|
62
|
+
|
63
|
+
s.test_files = Dir.glob('test/**/test_*.rb')
|
64
|
+
|
65
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE.md',
|
66
|
+
'API-CHANGES.rdoc', 'History.rdoc']
|
67
|
+
s.rdoc_options = ["--title", "Rubytree Documentation", "--quiet"]
|
68
|
+
|
69
|
+
s.add_runtime_dependency 'structured_warnings' , '~> 0.2'
|
70
|
+
s.add_runtime_dependency 'json' , '~> 1.8'
|
71
|
+
|
72
|
+
# Note: Rake is added as a development and test dependency in the Gemfile.
|
73
|
+
s.add_development_dependency 'bundler' , '~> 1.7'
|
74
|
+
s.add_development_dependency 'rdoc' , '~> 4.2'
|
75
|
+
s.add_development_dependency 'yard' , '~> 0.8'
|
76
|
+
s.add_development_dependency 'rtagstask' , '~> 0.0'
|
77
|
+
|
78
|
+
s.post_install_message = <<-EOF
|
79
|
+
========================================================================
|
80
|
+
Thank you for installing RubyTree.
|
81
|
+
|
82
|
+
Note:: As of 0.9.5, the Tree::TreeNode#add method has 'move' semantics.
|
83
|
+
|
84
|
+
Details of the API changes are documented in the API-CHANGES file.
|
85
|
+
========================================================================
|
86
|
+
EOF
|
87
|
+
|
88
|
+
end
|