acts_as_recursive_tree 2.1.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +44 -0
  3. data/.github/workflows/lint.yml +31 -0
  4. data/.github/workflows/rubygem.yml +37 -0
  5. data/.gitignore +3 -1
  6. data/.rubocop.yml +33 -1
  7. data/.rubocop_todo.yml +28 -281
  8. data/Appraisals +21 -0
  9. data/CHANGELOG.md +16 -1
  10. data/Gemfile +2 -0
  11. data/README.md +9 -0
  12. data/Rakefile +8 -8
  13. data/acts_as_recursive_tree.gemspec +27 -18
  14. data/gemfiles/ar_52.gemfile +8 -0
  15. data/gemfiles/ar_60.gemfile +8 -0
  16. data/gemfiles/ar_61.gemfile +8 -0
  17. data/gemfiles/ar_70.gemfile +8 -0
  18. data/lib/acts_as_recursive_tree/acts_macro.rb +6 -6
  19. data/lib/acts_as_recursive_tree/associations.rb +10 -8
  20. data/lib/acts_as_recursive_tree/builders/ancestors.rb +3 -2
  21. data/lib/acts_as_recursive_tree/builders/descendants.rb +3 -1
  22. data/lib/acts_as_recursive_tree/builders/leaves.rb +7 -8
  23. data/lib/acts_as_recursive_tree/builders/relation_builder.rb +14 -10
  24. data/lib/acts_as_recursive_tree/builders/{strategy → strategies}/ancestor.rb +3 -1
  25. data/lib/acts_as_recursive_tree/builders/{strategy → strategies}/descendant.rb +3 -1
  26. data/lib/acts_as_recursive_tree/builders/{strategy → strategies}/join.rb +5 -3
  27. data/lib/acts_as_recursive_tree/builders/{strategy → strategies}/subselect.rb +3 -1
  28. data/lib/acts_as_recursive_tree/builders/{strategy.rb → strategies.rb} +3 -9
  29. data/lib/acts_as_recursive_tree/config.rb +2 -0
  30. data/lib/acts_as_recursive_tree/model.rb +9 -8
  31. data/lib/acts_as_recursive_tree/options/depth_condition.rb +3 -2
  32. data/lib/acts_as_recursive_tree/options/query_options.rb +4 -2
  33. data/lib/acts_as_recursive_tree/options/values.rb +28 -18
  34. data/lib/acts_as_recursive_tree/railtie.rb +2 -0
  35. data/lib/acts_as_recursive_tree/scopes.rb +8 -4
  36. data/lib/acts_as_recursive_tree/version.rb +3 -1
  37. data/lib/acts_as_recursive_tree.rb +7 -11
  38. data/spec/builders_spec.rb +21 -12
  39. data/spec/db/database.rb +13 -4
  40. data/spec/db/database.yml +2 -5
  41. data/spec/db/models.rb +12 -11
  42. data/spec/db/schema.rb +3 -4
  43. data/spec/model/location_spec.rb +7 -11
  44. data/spec/model/node_spec.rb +35 -49
  45. data/spec/model/relation_spec.rb +6 -11
  46. data/spec/spec_helper.rb +54 -55
  47. data/spec/values_spec.rb +30 -19
  48. metadata +111 -26
  49. data/lib/acts_as_recursive_tree/builders.rb +0 -14
  50. data/lib/acts_as_recursive_tree/options.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa1a901a4881db96a5aff4515cb0fe5f5b52d8713c7277aa67b4c5e3ffba70d4
4
- data.tar.gz: 5201f9c51c39a944b2fcb7e8abafe24d07722870f2545cf0cfb1116a46567238
3
+ metadata.gz: b3681366c263bd90e2479c6a4761042825547241a15e828678c260789f05ad54
4
+ data.tar.gz: c526e787809100bcba957ddeae424ffa068afe7f10e8e2ece1aec354cce6c70b
5
5
  SHA512:
6
- metadata.gz: '028d295a1d44a545798862a602448f635dd854bc63373d654ebaa217b41d8fded8327d6c10d0d64a566d7fd96beef3430261f66a135bdb1d7484cbcd25d3cae7'
7
- data.tar.gz: 0a0746c45165e981ef5965bb751d5bfc88ac8ffdb07edc898799b4fa781a2f302d12c57b4ee2582e41c8b5c439d9c50b0019aa60f0b21a270f8388911dcc1939
6
+ metadata.gz: 2b4e5b9a5a1462b39cc8c2cc0184d8db0653b1d02be8728d2bf46fa309d847224765c3e6b8ac885f064a42f64b34375d9e032e888d5588c9940d55225ceced4a
7
+ data.tar.gz: 4e8a2077169e98b889671412c87c80d21f03541bbcdc62cefe520e47c626459c29ff1ee6a07bb54a9ebd94ca8418c4369d27ff9950a3c559b0bd7ef41970afc6
@@ -0,0 +1,44 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: CI
9
+
10
+ on:
11
+ push:
12
+ branches: [ main ]
13
+ pull_request:
14
+ branches: [ '**' ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.5', '2.6', '2.7', '3.0']
23
+ gemfile: [ar_52, ar_60, ar_61, ar_70]
24
+ exclude:
25
+ - ruby-version: '3.0'
26
+ gemfile: ar_52
27
+ - ruby-version: '2.5'
28
+ gemfile: ar_70
29
+ - ruby-version: '2.6'
30
+ gemfile: ar_70
31
+ env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
32
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+ - name: Set up Ruby
36
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
37
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
38
+ uses: ruby/setup-ruby@v1
39
+ # uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
40
+ with:
41
+ ruby-version: ${{ matrix.ruby-version }}
42
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
43
+ - name: Run tests
44
+ run: bundle exec rake
@@ -0,0 +1,31 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: LINT
9
+
10
+ on:
11
+ push:
12
+ branches: [ main ]
13
+ pull_request:
14
+ branches: [ '**' ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
24
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
25
+ uses: ruby/setup-ruby@v1
26
+ # uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
27
+ with:
28
+ ruby-version: 2.7
29
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
30
+ - name: Run rubocop
31
+ run: bundle exec rubocop
@@ -0,0 +1,37 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+
6
+ name: Ruby Gem
7
+
8
+ on:
9
+ # Manually publish
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ build:
14
+ name: Build + Publish
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ packages: write
18
+ contents: read
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: 2.7
26
+ - run: bundle install
27
+ - name: Publish to RubyGems
28
+ env:
29
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
30
+ run: |
31
+ mkdir -p $HOME/.gem
32
+ touch $HOME/.gem/credentials
33
+ chmod 0600 $HOME/.gem/credentials
34
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
35
+ gem build *.gemspec
36
+ gem push *.gem
37
+
data/.gitignore CHANGED
@@ -14,4 +14,6 @@
14
14
  mkmf.log
15
15
  /.idea
16
16
  db.log
17
- test.sqlite3
17
+ test.sqlite3
18
+ /gemfiles/*.lock
19
+ /gemfiles/.bundle
data/.rubocop.yml CHANGED
@@ -1 +1,33 @@
1
- inherit_from: .rubocop_todo.yml
1
+ require:
2
+ - rubocop-rails
3
+ - rubocop-rspec
4
+
5
+ inherit_from: .rubocop_todo.yml
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 2.5
9
+ NewCops: enable
10
+ SuggestExtensions: false
11
+
12
+ Gemspec/RequireMFA:
13
+ Enabled: false
14
+
15
+ Metrics/AbcSize:
16
+ Max: 20
17
+
18
+ Rails/RakeEnvironment:
19
+ Enabled: false
20
+
21
+ RSpec/NestedGroups:
22
+ Max: 4
23
+
24
+ Style/Alias:
25
+ EnforcedStyle: prefer_alias
26
+
27
+ Style/FrozenStringLiteralComment:
28
+ Exclude:
29
+ - 'gemfiles/**/*'
30
+
31
+ Style/StringLiterals:
32
+ Exclude:
33
+ - 'gemfiles/**/*'
data/.rubocop_todo.yml CHANGED
@@ -1,321 +1,68 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-01-22 09:50:37 +0100 using RuboCop version 0.51.0.
3
+ # on 2021-08-02 08:58:28 UTC using RuboCop version 1.18.4.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 4
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: SupportedStyles, IndentOneStep, IndentationWidth.
12
- # SupportedStyles: case, end
13
- Layout/CaseIndentation:
14
- EnforcedStyle: end
15
-
16
- # Offense count: 1
17
- # Cop supports --auto-correct.
18
- Layout/CommentIndentation:
19
- Exclude:
20
- - 'spec/spec_helper.rb'
21
-
22
- # Offense count: 1
23
- # Cop supports --auto-correct.
24
- Layout/EmptyLineAfterMagicComment:
25
- Exclude:
26
- - 'acts_as_recursive_tree.gemspec'
9
+ # Offense count: 6
10
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
11
+ # IgnoredMethods: refine
12
+ Metrics/BlockLength:
13
+ Max: 87
27
14
 
28
15
  # Offense count: 1
29
- # Cop supports --auto-correct.
30
- # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
31
- Layout/EmptyLineBetweenDefs:
32
- Exclude:
33
- - 'lib/acts_as_recursive_tree/model.rb'
34
-
35
- # Offense count: 5
36
- # Cop supports --auto-correct.
37
- Layout/EmptyLines:
38
- Exclude:
39
- - 'lib/acts_as_recursive_tree/model.rb'
40
- - 'spec/db/models.rb'
41
- - 'spec/model/node_spec.rb'
42
- - 'spec/spec_helper.rb'
16
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
17
+ Metrics/MethodLength:
18
+ Max: 15
43
19
 
44
- # Offense count: 25
45
- # Cop supports --auto-correct.
46
- # Configuration parameters: EnforcedStyle, SupportedStyles.
47
- # SupportedStyles: empty_lines, no_empty_lines
48
- Layout/EmptyLinesAroundBlockBody:
20
+ # Offense count: 18
21
+ # Configuration parameters: Prefixes.
22
+ # Prefixes: when, with, without
23
+ RSpec/ContextWording:
49
24
  Exclude:
50
- - 'lib/acts_as_recursive_tree/scopes.rb'
51
- - 'spec/db/schema.rb'
25
+ - 'spec/builders_spec.rb'
52
26
  - 'spec/model/location_spec.rb'
53
27
  - 'spec/model/node_spec.rb'
54
28
  - 'spec/model/relation_spec.rb'
55
29
  - 'spec/values_spec.rb'
56
30
 
57
- # Offense count: 11
58
- # Cop supports --auto-correct.
59
- # Configuration parameters: EnforcedStyle, SupportedStyles.
60
- # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
61
- Layout/EmptyLinesAroundClassBody:
31
+ # Offense count: 37
32
+ # Configuration parameters: AssignmentOnly.
33
+ RSpec/InstanceVariable:
62
34
  Exclude:
63
- - 'lib/acts_as_recursive_tree/builders/ancestors.rb'
64
- - 'lib/acts_as_recursive_tree/builders/leaves.rb'
65
- - 'lib/acts_as_recursive_tree/builders/relation_builder.rb'
66
- - 'lib/acts_as_recursive_tree/options/depth_condition.rb'
67
- - 'lib/acts_as_recursive_tree/options/query_options.rb'
68
- - 'spec/db/models.rb'
69
-
70
- # Offense count: 6
71
- # Cop supports --auto-correct.
72
- Layout/EmptyLinesAroundMethodBody:
73
- Exclude:
74
- - 'lib/acts_as_recursive_tree/acts_macro.rb'
75
- - 'lib/acts_as_recursive_tree/builders/leaves.rb'
76
- - 'lib/acts_as_recursive_tree/options/values.rb'
77
- - 'spec/model/node_spec.rb'
78
- - 'spec/model/relation_spec.rb'
79
-
80
- # Offense count: 2
81
- # Cop supports --auto-correct.
82
- # Configuration parameters: EnforcedStyle, SupportedStyles.
83
- # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
84
- Layout/EmptyLinesAroundModuleBody:
85
- Exclude:
86
- - 'lib/acts_as_recursive_tree/acts_macro.rb'
87
- - 'lib/acts_as_recursive_tree/model.rb'
88
-
89
- # Offense count: 6
90
- # Cop supports --auto-correct.
91
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
92
- # SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
93
- Layout/FirstParameterIndentation:
94
- Exclude:
95
- - 'lib/acts_as_recursive_tree/builders/leaves.rb'
96
- - 'lib/acts_as_recursive_tree/model.rb'
97
- - 'spec/model/relation_spec.rb'
98
-
99
- # Offense count: 1
100
- # Cop supports --auto-correct.
101
- # Configuration parameters: EnforcedStyle, SupportedStyles, SupportedStylesForEmptyBraces.
102
- # SupportedStyles: space, no_space
103
- # SupportedStylesForEmptyBraces: space, no_space
104
- Layout/SpaceBeforeBlockBraces:
105
- Exclude:
106
- - 'spec/values_spec.rb'
107
-
108
- # Offense count: 2
109
- # Cop supports --auto-correct.
110
- # Configuration parameters: EnforcedStyle, SupportedStyles.
111
- # SupportedStyles: require_no_space, require_space
112
- Layout/SpaceInLambdaLiteral:
113
- Exclude:
114
- - 'lib/acts_as_recursive_tree/scopes.rb'
115
- - 'spec/builders_spec.rb'
116
-
117
- # Offense count: 2
118
- # Cop supports --auto-correct.
119
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
120
- # SupportedStyles: space, no_space
121
- # SupportedStylesForEmptyBraces: space, no_space
122
- Layout/SpaceInsideBlockBraces:
123
- Exclude:
124
- - 'spec/values_spec.rb'
125
-
126
- # Offense count: 2
127
- # Cop supports --auto-correct.
128
- Layout/SpaceInsidePercentLiteralDelimiters:
129
- Exclude:
130
- - 'Rakefile'
131
-
132
- # Offense count: 10
133
- # Cop supports --auto-correct.
134
- # Configuration parameters: EnforcedStyle, SupportedStyles.
135
- # SupportedStyles: final_newline, final_blank_line
136
- Layout/TrailingBlankLines:
137
- Exclude:
138
- - 'lib/acts_as_recursive_tree/acts_macro.rb'
139
- - 'lib/acts_as_recursive_tree/options/depth_condition.rb'
140
- - 'lib/acts_as_recursive_tree/options/values.rb'
141
- - 'spec/db/database.rb'
142
- - 'spec/db/models.rb'
143
- - 'spec/db/schema.rb'
144
35
  - 'spec/model/location_spec.rb'
145
36
  - 'spec/model/node_spec.rb'
146
37
  - 'spec/model/relation_spec.rb'
147
- - 'spec/values_spec.rb'
148
-
149
- # Offense count: 14
150
- Lint/AmbiguousRegexpLiteral:
151
- Exclude:
152
- - 'spec/builders_spec.rb'
153
- - 'spec/values_spec.rb'
154
38
 
155
39
  # Offense count: 1
156
- # Cop supports --auto-correct.
157
- Lint/DeprecatedClassMethods:
40
+ RSpec/MultipleDescribes:
158
41
  Exclude:
159
- - 'Rakefile'
160
-
161
- # Offense count: 1
162
- # Cop supports --auto-correct.
163
- # Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
164
- # SupportedStylesAlignWith: keyword, variable, start_of_line
165
- Lint/EndAlignment:
166
- Exclude:
167
- - 'lib/acts_as_recursive_tree/options/values.rb'
168
-
169
- # Offense count: 1
170
- Lint/HandleExceptions:
171
- Exclude:
172
- - 'Rakefile'
173
-
174
- # Offense count: 1
175
- # Cop supports --auto-correct.
176
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
177
- Lint/UnusedMethodArgument:
178
- Exclude:
179
- - 'lib/acts_as_recursive_tree/builders/leaves.rb'
180
-
181
- # Offense count: 5
182
- Metrics/AbcSize:
183
- Max: 44
184
-
185
- # Offense count: 8
186
- # Configuration parameters: CountComments, ExcludedMethods.
187
- Metrics/BlockLength:
188
- Max: 89
189
-
190
- # Offense count: 41
191
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
192
- # URISchemes: http, https
193
- Metrics/LineLength:
194
- Max: 291
42
+ - 'spec/builders_spec.rb'
195
43
 
196
44
  # Offense count: 2
197
- # Configuration parameters: CountComments.
198
- Metrics/MethodLength:
199
- Max: 13
45
+ RSpec/MultipleExpectations:
46
+ Max: 2
200
47
 
201
- # Offense count: 1
202
- # Cop supports --auto-correct.
203
- Security/YAMLLoad:
204
- Exclude:
205
- - 'spec/db/database.rb'
206
-
207
- # Offense count: 1
208
- # Cop supports --auto-correct.
209
- # Configuration parameters: EnforcedStyle, SupportedStyles.
210
- # SupportedStyles: prefer_alias, prefer_alias_method
211
- Style/Alias:
212
- Exclude:
213
- - 'lib/acts_as_recursive_tree/acts_macro.rb'
214
-
215
- # Offense count: 1
216
- # Cop supports --auto-correct.
217
- Style/BlockComments:
218
- Exclude:
219
- - 'spec/spec_helper.rb'
220
-
221
- # Offense count: 1
222
- # Cop supports --auto-correct.
223
- Style/ColonMethodCall:
224
- Exclude:
225
- - 'spec/db/database.rb'
226
-
227
- # Offense count: 20
48
+ # Offense count: 17
49
+ # Configuration parameters: AllowedConstants.
228
50
  Style/Documentation:
229
51
  Exclude:
230
- - 'spec/**/*'
231
- - 'test/**/*'
232
52
  - 'lib/acts_as_recursive_tree.rb'
233
53
  - 'lib/acts_as_recursive_tree/acts_macro.rb'
234
- - 'lib/acts_as_recursive_tree/associations.rb'
235
- - 'lib/acts_as_recursive_tree/builders.rb'
236
54
  - 'lib/acts_as_recursive_tree/builders/ancestors.rb'
237
55
  - 'lib/acts_as_recursive_tree/builders/descendants.rb'
238
56
  - 'lib/acts_as_recursive_tree/builders/leaves.rb'
239
- - 'lib/acts_as_recursive_tree/builders/relation_builder.rb'
240
57
  - 'lib/acts_as_recursive_tree/model.rb'
241
- - 'lib/acts_as_recursive_tree/options.rb'
242
58
  - 'lib/acts_as_recursive_tree/options/depth_condition.rb'
243
59
  - 'lib/acts_as_recursive_tree/options/query_options.rb'
244
60
  - 'lib/acts_as_recursive_tree/options/values.rb'
245
61
  - 'lib/acts_as_recursive_tree/railtie.rb'
246
- - 'lib/acts_as_recursive_tree/scopes.rb'
247
-
248
- # Offense count: 2
249
- # Cop supports --auto-correct.
250
- # Configuration parameters: EnforcedStyle, SupportedStyles.
251
- # SupportedStyles: compact, expanded
252
- Style/EmptyMethod:
253
- Exclude:
254
- - 'lib/acts_as_recursive_tree/options/values.rb'
255
62
 
256
- # Offense count: 2
257
- # Cop supports --auto-correct.
258
- Style/Encoding:
259
- Exclude:
260
- - 'acts_as_recursive_tree.gemspec'
261
- - 'spec/db/schema.rb'
262
-
263
- # Offense count: 1
63
+ # Offense count: 9
264
64
  # Cop supports --auto-correct.
265
- # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
266
- # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
267
- Style/HashSyntax:
268
- Exclude:
269
- - 'spec/db/schema.rb'
270
-
271
- # Offense count: 2
272
- # Cop supports --auto-correct.
273
- # Configuration parameters: MaxLineLength.
274
- Style/IfUnlessModifier:
275
- Exclude:
276
- - 'spec/model/node_spec.rb'
277
- - 'spec/model/relation_spec.rb'
278
-
279
- # Offense count: 1
280
- # Cop supports --auto-correct.
281
- # Configuration parameters: InverseMethods, InverseBlocks.
282
- Style/InverseMethods:
283
- Exclude:
284
- - 'lib/acts_as_recursive_tree/model.rb'
285
-
286
- # Offense count: 6
287
- # Cop supports --auto-correct.
288
- # Configuration parameters: EnforcedStyle, SupportedStyles.
289
- # SupportedStyles: line_count_dependent, lambda, literal
290
- Style/Lambda:
291
- Exclude:
292
- - 'lib/acts_as_recursive_tree/scopes.rb'
293
-
294
- # Offense count: 1
295
- # Cop supports --auto-correct.
296
- Style/MultilineIfModifier:
297
- Exclude:
298
- - 'lib/acts_as_recursive_tree/scopes.rb'
299
-
300
- # Offense count: 2
301
- # Cop supports --auto-correct.
302
- # Configuration parameters: PreferredDelimiters.
303
- Style/PercentLiteralDelimiters:
304
- Exclude:
305
- - 'Rakefile'
306
- - 'acts_as_recursive_tree.gemspec'
307
-
308
- # Offense count: 17
309
- # Cop supports --auto-correct.
310
- Style/RedundantSelf:
311
- Exclude:
312
- - 'lib/acts_as_recursive_tree/acts_macro.rb'
313
- - 'lib/acts_as_recursive_tree/associations.rb'
314
- - 'lib/acts_as_recursive_tree/model.rb'
315
- - 'lib/acts_as_recursive_tree/scopes.rb'
316
-
317
- # Offense count: 2
318
- # Cop supports --auto-correct.
319
- Style/UnneededPercentQ:
320
- Exclude:
321
- - 'acts_as_recursive_tree.gemspec'
65
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
66
+ # URISchemes: http, https
67
+ Layout/LineLength:
68
+ Max: 291
data/Appraisals ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'ar-52' do
4
+ gem 'activerecord', '~> 5.2.0'
5
+ gem 'activesupport', '~> 5.2.0'
6
+ end
7
+
8
+ appraise 'ar-60' do
9
+ gem 'activerecord', '~> 6.0.0'
10
+ gem 'activesupport', '~> 6.0.0'
11
+ end
12
+
13
+ appraise 'ar-61' do
14
+ gem 'activerecord', '~> 6.1.0'
15
+ gem 'activesupport', '~> 6.1.0'
16
+ end
17
+
18
+ appraise 'ar-70' do
19
+ gem 'activerecord', '~> 7.0.0'
20
+ gem 'activesupport', '~> 7.0.0'
21
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ### Version 3.1.0
2
+ - Rails 7 support
3
+
4
+ ### Version 3.0.0
5
+ - BREAKING: Dropped support for Rails < 5.2
6
+ - BREAKING: Increased minimum Ruby version to 2.5
7
+ - ADD: initial support for Rails < 7
8
+ - CHANGE: Using zeitwerk for auto loading
9
+
10
+ ### Version 2.2.1
11
+ - Rails 6.1 support
12
+
13
+ ### Version 2.2.0
14
+ - Rails 6.0 support
15
+
1
16
  ### Version 2.1.1
2
17
  - Enabled subselect query when using depth
3
18
  - new QueryOption query_strategy for forcing a specific strategy (:join, :subselect)
@@ -29,4 +44,4 @@
29
44
  - BUGFIX: ordering result when querying ancestors
30
45
 
31
46
  ### Version 1.0.0
32
- - inital release using AREL
47
+ - initial release using AREL
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in acts_as_recursive_tree.gemspec
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ActsAsRecursiveTree
2
2
 
3
+ [![CI Status](https://github.com/1and1/acts_as_recursive_tree/workflows/CI/badge.svg?branch=main)](https://github.com/1and1/acts_as_recursive_tree/actions?query=workflow%3ACI+branch%3Amaster)
4
+ [![Gem Version](https://badge.fury.io/rb/acts_as_recursive_tree.svg)](https://badge.fury.io/rb/acts_as_recursive_tree)
5
+
3
6
  Use the power of recursive SQL statements in your Rails application.
4
7
 
5
8
  When you have tree based data in your application, you always to struggle with retrieving data. There are solutions, but the always come at a price:
@@ -9,6 +12,12 @@ When you have tree based data in your application, you always to struggle with r
9
12
 
10
13
  Luckily, there is already a SQL standard that makes it very easy to retrieve data in the traditional parent/child relation. Currently this is only supported in sqlite and Postgres. With this it is possible to query complete trees without the need of extra tables or indices.
11
14
 
15
+ ## Supported environments
16
+ ActsAsRecursiveTree currently supports following ActiveRecord versions and is tested for compatibility:
17
+ * ActiveRecord 5.2.x
18
+ * ActiveRecord 6.0.x
19
+ * ActiveRecord 6.1.x
20
+ * ActiveRecord 7.0.x
12
21
 
13
22
  ## Installation
14
23
 
data/Rakefile CHANGED
@@ -1,15 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
- begin
3
- require 'rspec/core/rake_task'
4
- RSpec::Core::RakeTask.new(:spec)
4
+ require 'rspec/core/rake_task'
5
5
 
6
- task default: [:spec]
7
- rescue LoadError
8
- end
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: [:spec]
9
9
 
10
10
  desc 'Deletes temporary files'
11
11
  task :clean_tmp_files do
12
- %w( db.log test.sqlite3 ).each do |file|
13
- File.delete(file) if File.exists?(file)
12
+ %w[db.log test.sqlite3].each do |file|
13
+ File.delete(file) if File.exist?(file)
14
14
  end
15
15
  end
@@ -1,30 +1,39 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'acts_as_recursive_tree/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'acts_as_recursive_tree'
8
- spec.version = ActsAsRecursiveTree::VERSION
9
- spec.authors = ['Wolfgang Wedelich-John']
10
- spec.email = ['wolfgang.wedelich@1und1.de']
11
- spec.summary = %q{Drop in replacement for acts_as_tree but using recursive queries}
12
- spec.description = %q{
13
- This is a ruby gem that provides drop in replacement for acts_as_tree but makes use of SQL recursive statement. Be sure to have a DBMS that supports recursive queries when using this gem (e.g. PostgreSQL or SQLite). }
14
- spec.homepage = 'https://github.com/1and1/acts_as_recursive_tree'
15
- spec.license = 'MIT'
16
-
17
- spec.required_ruby_version = '>= 2.0.0'
8
+ spec.name = 'acts_as_recursive_tree'
9
+ spec.version = ActsAsRecursiveTree::VERSION
10
+ spec.authors = ['Wolfgang Wedelich-John', 'Willem Mulder']
11
+ spec.email = %w[wolfgang.wedelich@ionos.com 14mRh4X0r@gmail.com]
12
+ spec.summary = 'Drop in replacement for acts_as_tree but using recursive queries'
13
+ spec.description = '
14
+ This is a ruby gem that provides drop in replacement for acts_as_tree but makes use of SQL recursive statement. Be sure to have a DBMS that supports recursive queries when using this gem (e.g. PostgreSQL or SQLite). '
15
+ spec.homepage = 'https://github.com/1and1/acts_as_recursive_tree'
16
+ spec.license = 'MIT'
17
+ spec.metadata = {
18
+ 'bug_tracker_uri' => 'https://github.com/1and1/acts_as_recursive_tree/issues',
19
+ 'changelog_uri' => 'https://github.com/1and1/acts_as_recursive_tree/blob/main/CHANGELOG.md'
20
+ }
21
+ spec.required_ruby_version = '>= 2.5.0'
18
22
  spec.files = `git ls-files -z`.split("\x0")
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
23
  spec.test_files = spec.files.grep(%r{^spec/})
21
24
  spec.require_paths = ['lib']
22
25
 
23
- spec.add_runtime_dependency 'activerecord', '>= 5.0.0', '< 6.0.0'
26
+ spec.add_runtime_dependency 'activerecord', '>= 5.2.0', '< 7.1'
27
+ spec.add_runtime_dependency 'activesupport', '>= 5.2.0', '< 7.1'
28
+ spec.add_runtime_dependency 'zeitwerk', '>= 2.4'
24
29
 
25
- spec.add_development_dependency 'bundler', '~> 1.7'
30
+ spec.add_development_dependency 'appraisal', '~> 2.4'
26
31
  spec.add_development_dependency 'database_cleaner', '~> 1.5'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec-rails', '~> 3.5'
32
+ spec.add_development_dependency 'rake'
33
+ spec.add_development_dependency 'rspec-rails', '>= 3.5'
34
+ spec.add_development_dependency 'rubocop', '~> 1.23.0'
35
+ spec.add_development_dependency 'rubocop-rails', '~> 2.12.0'
36
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.6.0'
37
+
29
38
  spec.add_development_dependency 'sqlite3', '~> 1.3'
30
39
  end