closure_tree 4.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -4
- data/Rakefile +5 -1
- data/lib/closure_tree/acts_as_tree.rb +1 -1
- data/lib/closure_tree/model.rb +63 -33
- data/lib/closure_tree/numeric_deterministic_ordering.rb +2 -2
- data/lib/closure_tree/support.rb +52 -16
- data/lib/closure_tree/version.rb +1 -1
- data/spec/db/schema.rb +4 -4
- data/spec/label_spec.rb +3 -3
- data/spec/parallel_spec.rb +12 -6
- data/spec/spec_helper.rb +27 -6
- data/spec/support/models.rb +27 -5
- data/spec/tag_examples.rb +421 -0
- data/spec/tag_fixture_examples.rb +136 -0
- data/spec/tag_spec.rb +4 -480
- data/spec/user_spec.rb +8 -8
- data/spec/uuid_tag_spec.rb +6 -0
- metadata +173 -172
- checksums.yaml +0 -15
- data/spec/hash_tree_spec.rb +0 -91
data/spec/user_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe "empty db" do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should create all Users" do
|
43
|
-
User.all.should =~ [@root, @mid, @leaf]
|
43
|
+
User.all.to_a.should =~ [@root, @mid, @leaf]
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should return a root and leaf without middle User" do
|
@@ -65,11 +65,11 @@ describe "empty db" do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def assert_mid_and_leaf_remain
|
68
|
-
ReferralHierarchy.
|
69
|
-
ReferralHierarchy.
|
68
|
+
ReferralHierarchy.where(:ancestor_id => @root_id).should be_empty
|
69
|
+
ReferralHierarchy.where(:descendant_id => @root_id).should be_empty
|
70
70
|
@mid.ancestry_path.should == %w{matt@t.co}
|
71
71
|
@leaf.ancestry_path.should == %w{matt@t.co james@t.co}
|
72
|
-
@mid.self_and_descendants.should =~ [@mid, @leaf]
|
72
|
+
@mid.self_and_descendants.to_a.should =~ [@mid, @leaf]
|
73
73
|
User.roots.should == [@mid]
|
74
74
|
User.leaves.should == [@leaf]
|
75
75
|
end
|
@@ -110,8 +110,8 @@ describe "empty db" do
|
|
110
110
|
c2.children << d
|
111
111
|
|
112
112
|
a.save
|
113
|
-
User.roots.should == [a]
|
114
|
-
User.leaves.should =~ [b1, c1, d]
|
113
|
+
User.roots.to_a.should == [a]
|
114
|
+
User.leaves.to_a.should =~ [b1, c1, d]
|
115
115
|
d.ancestry_path.should == %w(a b2 c2 d)
|
116
116
|
end
|
117
117
|
|
@@ -122,7 +122,7 @@ describe "empty db" do
|
|
122
122
|
b2 = a.children.create(:email => "b2")
|
123
123
|
b3 = a.children.create(:email => "b3")
|
124
124
|
a.siblings.should be_empty
|
125
|
-
b1.siblings.should =~ [b2, b3]
|
125
|
+
b1.siblings.to_a.should =~ [b2, b3]
|
126
126
|
end
|
127
127
|
|
128
128
|
context "when a user is not yet saved" do
|
@@ -133,7 +133,7 @@ describe "empty db" do
|
|
133
133
|
b2 = a.children.create(:email => "b2")
|
134
134
|
b3 = a.children.create(:email => "b3")
|
135
135
|
a.siblings.should be_empty
|
136
|
-
b1.siblings.should =~ [b2, b3]
|
136
|
+
b1.siblings.to_a.should =~ [b2, b3]
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
metadata
CHANGED
@@ -1,190 +1,177 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: closure_tree
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 59
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 4
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 4.1.0
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Matthew McEachen
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
date: 2013-06-02 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 7
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
- 0
|
19
32
|
version: 3.0.0
|
20
33
|
type: :runtime
|
34
|
+
name: activerecord
|
35
|
+
version_requirements: *id001
|
21
36
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 19
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
- 6
|
33
48
|
version: 0.0.6
|
34
49
|
type: :runtime
|
50
|
+
name: with_advisory_lock
|
51
|
+
version_requirements: *id002
|
35
52
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- !ruby/object:Gem::
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
48
63
|
type: :development
|
64
|
+
name: rake
|
65
|
+
version_requirements: *id003
|
49
66
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
- !ruby/object:Gem::
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
62
77
|
type: :development
|
78
|
+
name: yard
|
79
|
+
version_requirements: *id004
|
63
80
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
76
91
|
type: :development
|
92
|
+
name: rspec
|
93
|
+
version_requirements: *id005
|
77
94
|
prerelease: false
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
- !ruby/object:Gem::
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
90
105
|
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
106
|
name: rspec-rails
|
99
|
-
|
100
|
-
requirements:
|
101
|
-
- - ! '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ! '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: mysql2
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
107
|
+
version_requirements: *id006
|
119
108
|
prerelease: false
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
- !ruby/object:Gem::
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
132
119
|
type: :development
|
120
|
+
name: mysql2
|
121
|
+
version_requirements: *id007
|
133
122
|
prerelease: false
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
- !ruby/object:Gem::
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 3
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
146
133
|
type: :development
|
134
|
+
name: pg
|
135
|
+
version_requirements: *id008
|
147
136
|
prerelease: false
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
- !ruby/object:Gem::
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 3
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
160
147
|
type: :development
|
148
|
+
name: sqlite3
|
149
|
+
version_requirements: *id009
|
161
150
|
prerelease: false
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
- !ruby/object:Gem::
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
174
161
|
type: :development
|
162
|
+
name: uuidtools
|
163
|
+
version_requirements: *id010
|
175
164
|
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ! '>='
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
165
|
description: Easily and efficiently make your ActiveRecord model support hierarchies
|
182
|
-
email:
|
166
|
+
email:
|
183
167
|
- matthew-github@mceachen.org
|
184
168
|
executables: []
|
169
|
+
|
185
170
|
extensions: []
|
171
|
+
|
186
172
|
extra_rdoc_files: []
|
187
|
-
|
173
|
+
|
174
|
+
files:
|
188
175
|
- lib/closure_tree/acts_as_tree.rb
|
189
176
|
- lib/closure_tree/deterministic_ordering.rb
|
190
177
|
- lib/closure_tree/model.rb
|
@@ -201,51 +188,65 @@ files:
|
|
201
188
|
- spec/db/schema.rb
|
202
189
|
- spec/fixtures/labels.yml
|
203
190
|
- spec/fixtures/tags.yml
|
204
|
-
- spec/hash_tree_spec.rb
|
205
191
|
- spec/label_spec.rb
|
206
192
|
- spec/namespace_type_spec.rb
|
207
193
|
- spec/parallel_prepend_sibling_spec.rb
|
208
194
|
- spec/parallel_spec.rb
|
209
195
|
- spec/spec_helper.rb
|
210
196
|
- spec/support/models.rb
|
197
|
+
- spec/tag_examples.rb
|
198
|
+
- spec/tag_fixture_examples.rb
|
211
199
|
- spec/tag_spec.rb
|
212
200
|
- spec/user_spec.rb
|
213
|
-
|
201
|
+
- spec/uuid_tag_spec.rb
|
202
|
+
has_rdoc: true
|
203
|
+
homepage: http://mceachen.github.io/closure_tree/
|
214
204
|
licenses: []
|
215
|
-
|
205
|
+
|
216
206
|
post_install_message:
|
217
207
|
rdoc_options: []
|
218
|
-
|
208
|
+
|
209
|
+
require_paths:
|
219
210
|
- lib
|
220
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
211
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
212
|
+
none: false
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
hash: 3
|
217
|
+
segments:
|
218
|
+
- 0
|
219
|
+
version: "0"
|
220
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
|
+
none: false
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
hash: 3
|
226
|
+
segments:
|
227
|
+
- 0
|
228
|
+
version: "0"
|
230
229
|
requirements: []
|
230
|
+
|
231
231
|
rubyforge_project:
|
232
|
-
rubygems_version:
|
232
|
+
rubygems_version: 1.6.2
|
233
233
|
signing_key:
|
234
|
-
specification_version:
|
234
|
+
specification_version: 3
|
235
235
|
summary: Easily and efficiently make your ActiveRecord model support hierarchies
|
236
|
-
test_files:
|
236
|
+
test_files:
|
237
237
|
- spec/cuisine_type_spec.rb
|
238
238
|
- spec/db/database.yml
|
239
239
|
- spec/db/schema.rb
|
240
240
|
- spec/fixtures/labels.yml
|
241
241
|
- spec/fixtures/tags.yml
|
242
|
-
- spec/hash_tree_spec.rb
|
243
242
|
- spec/label_spec.rb
|
244
243
|
- spec/namespace_type_spec.rb
|
245
244
|
- spec/parallel_prepend_sibling_spec.rb
|
246
245
|
- spec/parallel_spec.rb
|
247
246
|
- spec/spec_helper.rb
|
248
247
|
- spec/support/models.rb
|
248
|
+
- spec/tag_examples.rb
|
249
|
+
- spec/tag_fixture_examples.rb
|
249
250
|
- spec/tag_spec.rb
|
250
251
|
- spec/user_spec.rb
|
251
|
-
|
252
|
+
- spec/uuid_tag_spec.rb
|