acts_as_better_tree 1.0.0 → 1.1.1
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 +5 -5
- data/Gemfile +2 -2
- data/Gemfile.lock +184 -79
- data/lib/acts_as_better_tree/version.rb +1 -1
- data/lib/acts_as_better_tree.rb +21 -8
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6086b1b15a5ae37e65f0214a558f18717e0d56f6f87669ec044334abd2c6f399
|
4
|
+
data.tar.gz: 9984975d678640134812db774ae4ed99b94e37ff0653e5ad3f16b66970e4ca49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1095e1017f8b6bd8145e49ebeb71ff1336afaa098e040eb38fd44ded7e245355747d26ef6ac39c8933a12741738a2a3176bd4b82aec3aac6bb3b0f649586c2b3
|
7
|
+
data.tar.gz: 8da3c096d3ffd1194cc731fdf9050eb1e8859fbc50005f8ba944ad17d6ebd21cbcf3a525565aceb8a04690f5e7b5f27cfbc1cfc3267058f3f984dd6201f79177
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,80 +1,180 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acts_as_better_tree (
|
4
|
+
acts_as_better_tree (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
actionpack (=
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
9
|
+
actioncable (8.0.2)
|
10
|
+
actionpack (= 8.0.2)
|
11
|
+
activesupport (= 8.0.2)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
zeitwerk (~> 2.6)
|
15
|
+
actionmailbox (8.0.2)
|
16
|
+
actionpack (= 8.0.2)
|
17
|
+
activejob (= 8.0.2)
|
18
|
+
activerecord (= 8.0.2)
|
19
|
+
activestorage (= 8.0.2)
|
20
|
+
activesupport (= 8.0.2)
|
21
|
+
mail (>= 2.8.0)
|
22
|
+
actionmailer (8.0.2)
|
23
|
+
actionpack (= 8.0.2)
|
24
|
+
actionview (= 8.0.2)
|
25
|
+
activejob (= 8.0.2)
|
26
|
+
activesupport (= 8.0.2)
|
27
|
+
mail (>= 2.8.0)
|
28
|
+
rails-dom-testing (~> 2.2)
|
29
|
+
actionpack (8.0.2)
|
30
|
+
actionview (= 8.0.2)
|
31
|
+
activesupport (= 8.0.2)
|
32
|
+
nokogiri (>= 1.8.5)
|
33
|
+
rack (>= 2.2.4)
|
34
|
+
rack-session (>= 1.0.1)
|
35
|
+
rack-test (>= 0.6.3)
|
36
|
+
rails-dom-testing (~> 2.2)
|
37
|
+
rails-html-sanitizer (~> 1.6)
|
38
|
+
useragent (~> 0.16)
|
39
|
+
actiontext (8.0.2)
|
40
|
+
actionpack (= 8.0.2)
|
41
|
+
activerecord (= 8.0.2)
|
42
|
+
activestorage (= 8.0.2)
|
43
|
+
activesupport (= 8.0.2)
|
44
|
+
globalid (>= 0.6.0)
|
45
|
+
nokogiri (>= 1.8.5)
|
46
|
+
actionview (8.0.2)
|
47
|
+
activesupport (= 8.0.2)
|
48
|
+
builder (~> 3.1)
|
49
|
+
erubi (~> 1.11)
|
50
|
+
rails-dom-testing (~> 2.2)
|
51
|
+
rails-html-sanitizer (~> 1.6)
|
52
|
+
activejob (8.0.2)
|
53
|
+
activesupport (= 8.0.2)
|
54
|
+
globalid (>= 0.3.6)
|
55
|
+
activemodel (8.0.2)
|
56
|
+
activesupport (= 8.0.2)
|
57
|
+
activerecord (8.0.2)
|
58
|
+
activemodel (= 8.0.2)
|
59
|
+
activesupport (= 8.0.2)
|
60
|
+
timeout (>= 0.4.0)
|
61
|
+
activestorage (8.0.2)
|
62
|
+
actionpack (= 8.0.2)
|
63
|
+
activejob (= 8.0.2)
|
64
|
+
activerecord (= 8.0.2)
|
65
|
+
activesupport (= 8.0.2)
|
66
|
+
marcel (~> 1.0)
|
67
|
+
activesupport (8.0.2)
|
68
|
+
base64
|
69
|
+
benchmark (>= 0.3)
|
70
|
+
bigdecimal
|
71
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
72
|
+
connection_pool (>= 2.2.5)
|
73
|
+
drb
|
74
|
+
i18n (>= 1.6, < 2)
|
75
|
+
logger (>= 1.4.2)
|
76
|
+
minitest (>= 5.1)
|
77
|
+
securerandom (>= 0.3)
|
78
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
79
|
+
uri (>= 0.13.1)
|
80
|
+
base64 (0.2.0)
|
81
|
+
benchmark (0.4.0)
|
82
|
+
bigdecimal (3.1.9)
|
83
|
+
builder (3.3.0)
|
84
|
+
concurrent-ruby (1.3.5)
|
85
|
+
connection_pool (2.5.0)
|
86
|
+
crass (1.0.6)
|
87
|
+
csv (3.3.3)
|
88
|
+
date (3.4.1)
|
38
89
|
diff-lcs (1.1.3)
|
39
|
-
|
90
|
+
drb (2.2.1)
|
91
|
+
erubi (1.13.1)
|
40
92
|
factory_girl (3.6.1)
|
41
93
|
activesupport (>= 3.0.0)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
94
|
+
globalid (1.2.1)
|
95
|
+
activesupport (>= 6.1)
|
96
|
+
i18n (1.14.7)
|
97
|
+
concurrent-ruby (~> 1.0)
|
98
|
+
io-console (0.8.0)
|
99
|
+
irb (1.15.2)
|
100
|
+
pp (>= 0.6.0)
|
101
|
+
rdoc (>= 4.0.0)
|
102
|
+
reline (>= 0.4.2)
|
103
|
+
logger (1.7.0)
|
104
|
+
loofah (2.24.0)
|
105
|
+
crass (~> 1.0.2)
|
106
|
+
nokogiri (>= 1.12.0)
|
107
|
+
mail (2.8.1)
|
108
|
+
mini_mime (>= 0.1.1)
|
109
|
+
net-imap
|
110
|
+
net-pop
|
111
|
+
net-smtp
|
112
|
+
marcel (1.0.4)
|
113
|
+
mini_mime (1.1.5)
|
114
|
+
mini_portile2 (2.8.8)
|
115
|
+
minitest (5.25.5)
|
116
|
+
net-imap (0.5.6)
|
117
|
+
date
|
118
|
+
net-protocol
|
119
|
+
net-pop (0.1.2)
|
120
|
+
net-protocol
|
121
|
+
net-protocol (0.2.2)
|
122
|
+
timeout
|
123
|
+
net-smtp (0.5.1)
|
124
|
+
net-protocol
|
125
|
+
nio4r (2.7.4)
|
126
|
+
nokogiri (1.18.7)
|
127
|
+
mini_portile2 (~> 2.8.2)
|
128
|
+
racc (~> 1.4)
|
129
|
+
pp (0.6.2)
|
130
|
+
prettyprint
|
131
|
+
prettyprint (0.2.0)
|
132
|
+
psych (5.2.3)
|
133
|
+
date
|
134
|
+
stringio
|
135
|
+
racc (1.8.1)
|
136
|
+
rack (3.1.12)
|
137
|
+
rack-session (2.1.0)
|
138
|
+
base64 (>= 0.1.0)
|
139
|
+
rack (>= 3.0.0)
|
140
|
+
rack-test (2.2.0)
|
141
|
+
rack (>= 1.3)
|
142
|
+
rackup (2.2.1)
|
143
|
+
rack (>= 3)
|
144
|
+
rails (8.0.2)
|
145
|
+
actioncable (= 8.0.2)
|
146
|
+
actionmailbox (= 8.0.2)
|
147
|
+
actionmailer (= 8.0.2)
|
148
|
+
actionpack (= 8.0.2)
|
149
|
+
actiontext (= 8.0.2)
|
150
|
+
actionview (= 8.0.2)
|
151
|
+
activejob (= 8.0.2)
|
152
|
+
activemodel (= 8.0.2)
|
153
|
+
activerecord (= 8.0.2)
|
154
|
+
activestorage (= 8.0.2)
|
155
|
+
activesupport (= 8.0.2)
|
156
|
+
bundler (>= 1.15.0)
|
157
|
+
railties (= 8.0.2)
|
158
|
+
rails-dom-testing (2.2.0)
|
159
|
+
activesupport (>= 5.0.0)
|
160
|
+
minitest
|
161
|
+
nokogiri (>= 1.6)
|
162
|
+
rails-html-sanitizer (1.6.2)
|
163
|
+
loofah (~> 2.21)
|
164
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
165
|
+
railties (8.0.2)
|
166
|
+
actionpack (= 8.0.2)
|
167
|
+
activesupport (= 8.0.2)
|
168
|
+
irb (~> 1.13)
|
169
|
+
rackup (>= 1.0.0)
|
170
|
+
rake (>= 12.2)
|
171
|
+
thor (~> 1.0, >= 1.2.2)
|
172
|
+
zeitwerk (~> 2.6)
|
173
|
+
rake (13.2.1)
|
174
|
+
rdoc (6.13.1)
|
175
|
+
psych (>= 4.0.0)
|
176
|
+
reline (0.6.1)
|
177
|
+
io-console (~> 0.5)
|
78
178
|
rspec (2.11.0)
|
79
179
|
rspec-core (~> 2.11.0)
|
80
180
|
rspec-expectations (~> 2.11.0)
|
@@ -83,24 +183,29 @@ GEM
|
|
83
183
|
rspec-expectations (2.11.2)
|
84
184
|
diff-lcs (~> 1.1.3)
|
85
185
|
rspec-mocks (2.11.1)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
186
|
+
securerandom (0.4.1)
|
187
|
+
stringio (3.1.6)
|
188
|
+
thor (1.3.2)
|
189
|
+
timeout (0.4.3)
|
190
|
+
tzinfo (2.0.6)
|
191
|
+
concurrent-ruby (~> 1.0)
|
192
|
+
uri (1.0.3)
|
193
|
+
useragent (0.16.11)
|
194
|
+
websocket-driver (0.7.7)
|
195
|
+
base64
|
196
|
+
websocket-extensions (>= 0.1.0)
|
197
|
+
websocket-extensions (0.1.5)
|
198
|
+
zeitwerk (2.7.2)
|
97
199
|
|
98
200
|
PLATFORMS
|
99
201
|
ruby
|
100
202
|
|
101
203
|
DEPENDENCIES
|
102
204
|
acts_as_better_tree!
|
205
|
+
csv
|
103
206
|
factory_girl
|
104
207
|
rails (>= 3.2.5)
|
105
208
|
rspec
|
106
|
-
|
209
|
+
|
210
|
+
BUNDLED WITH
|
211
|
+
2.6.5
|
data/lib/acts_as_better_tree.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "acts_as_better_tree/version"
|
2
|
-
require "csv"
|
3
2
|
module ActiveRecord
|
4
3
|
module Acts
|
5
4
|
module BetterTree
|
@@ -12,10 +11,24 @@ module ActiveRecord
|
|
12
11
|
configuration = {:order => "id ASC", :destroy_dependent => true }
|
13
12
|
configuration.update(options) if options.is_a?(Hash)
|
14
13
|
|
15
|
-
belongs_to :parent,
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
belongs_to :parent,
|
15
|
+
class_name: name,
|
16
|
+
foreign_key: :parent_id
|
17
|
+
has_many :children,
|
18
|
+
-> { order(configuration[:order]) },
|
19
|
+
class_name: name,
|
20
|
+
foreign_key: :parent_id,
|
21
|
+
dependent: configuration[:destroy_dependent] ? :destroy : nil
|
22
|
+
has_many :parents_children,
|
23
|
+
-> { order(configuration[:order]) },
|
24
|
+
class_name: name,
|
25
|
+
primary_key: :parent_id,
|
26
|
+
foreign_key: :parent_id
|
27
|
+
belongs_to :root,
|
28
|
+
class_name: name,
|
29
|
+
foreign_key: :root_id,
|
30
|
+
optional: true,
|
31
|
+
dependent: :destroy
|
19
32
|
scope :roots, -> {order(configuration[:order]).where(:parent_id => nil)}
|
20
33
|
after_create :assign_csv_ids
|
21
34
|
after_validation :update_csv_ids, :on => :update
|
@@ -116,11 +129,11 @@ module ActiveRecord
|
|
116
129
|
end
|
117
130
|
|
118
131
|
def move_to_child_of(category)
|
119
|
-
self.
|
132
|
+
self.update(parent_id: category.id)
|
120
133
|
end
|
121
134
|
|
122
135
|
def make_root
|
123
|
-
self.
|
136
|
+
self.update(parent_id: nil)
|
124
137
|
end
|
125
138
|
|
126
139
|
def to_csv(nodes = self.children)
|
@@ -157,7 +170,7 @@ module ActiveRecord
|
|
157
170
|
end
|
158
171
|
|
159
172
|
def assign_csv_ids
|
160
|
-
self.
|
173
|
+
self.update(csv_ids: build_csv_ids, root_id: build_root_id)
|
161
174
|
end
|
162
175
|
|
163
176
|
def update_csv_ids
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_better_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Sloan
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-17 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: acts_as_better_tree is great for anyone who needs a fast tree capable
|
14
13
|
of handling millions of nodes without slowing down on writes like nestedset or on
|
@@ -34,7 +33,6 @@ files:
|
|
34
33
|
homepage: https://github.com/isaacsloan/acts_as_better_tree
|
35
34
|
licenses: []
|
36
35
|
metadata: {}
|
37
|
-
post_install_message:
|
38
36
|
rdoc_options: []
|
39
37
|
require_paths:
|
40
38
|
- lib
|
@@ -49,9 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
47
|
- !ruby/object:Gem::Version
|
50
48
|
version: '0'
|
51
49
|
requirements: []
|
52
|
-
|
53
|
-
rubygems_version: 2.4.5.1
|
54
|
-
signing_key:
|
50
|
+
rubygems_version: 3.6.2
|
55
51
|
specification_version: 4
|
56
52
|
summary: acts_as_better_tree is backwards compatible with acts_as_tree and remains
|
57
53
|
fast with large datasets by storing the ancestry of every node in the field csv_ids.
|