acts_as_archival 1.3.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/.rubocop.yml +19 -28
- data/.rubocop_todo.yml +92 -1
- data/.travis.yml +8 -17
- data/Appraisals +4 -12
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +71 -0
- data/README.md +23 -4
- data/acts_as_archival.gemspec +25 -16
- data/gemfiles/{rails_4.1.gemfile → rails_6.1.gemfile} +2 -2
- data/gemfiles/{rails_4.2.gemfile → rails_7.0.gemfile} +2 -2
- data/lib/acts_as_archival/version.rb +1 -1
- data/lib/acts_as_archival.rb +2 -0
- data/lib/expected_behavior/acts_as_archival.rb +14 -33
- data/lib/expected_behavior/acts_as_archival_active_record_methods.rb +17 -12
- data/lib/expected_behavior/association_operation/base.rb +5 -1
- data/test/callbacks_test.rb +14 -33
- data/test/fixtures/another_polys_holder.rb +11 -0
- data/test/fixtures/{callback_archival_4.rb → callback_archival.rb} +7 -4
- data/test/polymorphic_test.rb +23 -0
- data/test/relations_test.rb +63 -0
- data/test/responds_test.rb +0 -16
- data/test/schema.rb +8 -7
- data/test/scope_test.rb +7 -10
- data/test/test_helper.rb +9 -20
- metadata +36 -60
- data/gemfiles/rails_5.0.gemfile +0 -7
- data/gemfiles/rails_5.1.gemfile +0 -7
- data/test/fixtures/callback_archival_5.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ebfd9690765e2b7676db8c90e2459ccccf3ff2ef9f6b94898fafa565cfdc708a
|
4
|
+
data.tar.gz: 303ee5fb63bd23c6bc35ef69b23eab80c455acd75632e3ca41a03b378fb3a471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d559c3b334d403418304225720db0b4cc78517bc4fd7fd43d6e3cb0bae8704c7f7e05288202658bec3d1622395e76583d538dca5ba942fbb4108a77060e19988
|
7
|
+
data.tar.gz: 1e64b71d7f09a82d38e68abb807c36a70f7ce6fe577ec45047a1f1cfb6cf466280634fae78acfb4c83f9b81a9a801a68c79095cd2f5102dc7e28ab9cf6eb1716
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -4,6 +4,25 @@ AllCops:
|
|
4
4
|
Exclude:
|
5
5
|
- vendor/**/*
|
6
6
|
- gemfiles/**/*
|
7
|
+
MinimumTargetRubyVersion: 2.7.3
|
8
|
+
NewCops: enable
|
9
|
+
SuggestExtensions: false
|
10
|
+
|
11
|
+
|
12
|
+
################
|
13
|
+
# Layout Rules #
|
14
|
+
################
|
15
|
+
Layout/EmptyLinesAroundClassBody:
|
16
|
+
EnforcedStyle: empty_lines_except_namespace
|
17
|
+
|
18
|
+
Layout/EmptyLinesAroundModuleBody:
|
19
|
+
EnforcedStyle: empty_lines_except_namespace
|
20
|
+
|
21
|
+
Layout/LineLength:
|
22
|
+
Max: 140
|
23
|
+
|
24
|
+
Layout/SpaceInsideHashLiteralBraces:
|
25
|
+
EnforcedStyle: space
|
7
26
|
|
8
27
|
|
9
28
|
################
|
@@ -17,9 +36,6 @@ Metrics/BlockLength:
|
|
17
36
|
Metrics/AbcSize:
|
18
37
|
Max: 25
|
19
38
|
|
20
|
-
Metrics/LineLength:
|
21
|
-
Max: 140
|
22
|
-
|
23
39
|
Metrics/MethodLength:
|
24
40
|
Max: 10
|
25
41
|
CountComments: false
|
@@ -43,39 +59,14 @@ Style/Documentation:
|
|
43
59
|
Style/DoubleNegation:
|
44
60
|
Enabled: false
|
45
61
|
|
46
|
-
Style/EmptyLinesAroundClassBody:
|
47
|
-
EnforcedStyle: empty_lines_except_namespace
|
48
|
-
|
49
|
-
Style/EmptyLinesAroundModuleBody:
|
50
|
-
EnforcedStyle: empty_lines_except_namespace
|
51
|
-
|
52
62
|
Style/FrozenStringLiteralComment:
|
53
63
|
EnforcedStyle: never
|
54
64
|
|
55
65
|
Style/HashSyntax:
|
56
66
|
EnforcedStyle: ruby19
|
57
67
|
|
58
|
-
# TODO: replace the [] below with default once a new version of
|
59
|
-
# rubocop comes out, since there is a PR for it:
|
60
|
-
# https://github.com/bbatsov/rubocop/pull/4038
|
61
|
-
Style/PercentLiteralDelimiters:
|
62
|
-
PreferredDelimiters:
|
63
|
-
'%': '{}'
|
64
|
-
'%i': '[]'
|
65
|
-
'%I': '[]'
|
66
|
-
'%q': '{}'
|
67
|
-
'%Q': '{}'
|
68
|
-
'%r': '{}'
|
69
|
-
'%s': '[]'
|
70
|
-
'%w': '[]'
|
71
|
-
'%W': '[]'
|
72
|
-
'%x': '[]'
|
73
|
-
|
74
68
|
Style/RaiseArgs:
|
75
69
|
EnforcedStyle: compact
|
76
70
|
|
77
|
-
Style/SpaceInsideHashLiteralBraces:
|
78
|
-
EnforcedStyle: space
|
79
|
-
|
80
71
|
Style/StringLiterals:
|
81
72
|
EnforcedStyle: double_quotes
|
data/.rubocop_todo.yml
CHANGED
@@ -1,7 +1,98 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2020-04-28 17:17:25 +0200 using RuboCop version 0.82.0.
|
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
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Layout/EmptyLineAfterMagicComment:
|
12
|
+
Exclude:
|
13
|
+
- 'acts_as_archival.gemspec'
|
14
|
+
- 'test/scope_test.rb'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
19
|
+
# SupportedStylesForExponentOperator: space, no_space
|
20
|
+
Layout/SpaceAroundOperators:
|
21
|
+
Exclude:
|
22
|
+
- 'test/deep_nesting_test.rb'
|
23
|
+
|
24
|
+
# Offense count: 1
|
25
|
+
# Cop supports --auto-correct.
|
26
|
+
Lint/ScriptPermission:
|
27
|
+
Exclude:
|
28
|
+
- 'Rakefile'
|
29
|
+
|
30
|
+
# Offense count: 7
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
Lint/SendWithMixinArgument:
|
33
|
+
Exclude:
|
34
|
+
- 'init.rb'
|
35
|
+
- 'lib/acts_as_archival.rb'
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: EnforcedStyle.
|
39
|
+
# SupportedStyles: lowercase, uppercase
|
40
|
+
Naming/HeredocDelimiterCase:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/expected_behavior/acts_as_archival.rb'
|
43
|
+
|
44
|
+
# Offense count: 3
|
45
|
+
# Configuration parameters: ForbiddenDelimiters.
|
46
|
+
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
47
|
+
Naming/HeredocDelimiterNaming:
|
48
|
+
Exclude:
|
49
|
+
- 'acts_as_archival.gemspec'
|
50
|
+
- 'lib/expected_behavior/acts_as_archival.rb'
|
51
|
+
|
52
|
+
# Offense count: 12
|
53
|
+
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
|
54
|
+
# SupportedStyles: inline, group
|
55
|
+
Style/AccessModifierDeclarations:
|
56
|
+
Exclude:
|
57
|
+
- 'lib/expected_behavior/acts_as_archival.rb'
|
58
|
+
- 'test/fixtures/callback_archival_4.rb'
|
59
|
+
- 'test/fixtures/callback_archival_5.rb'
|
60
|
+
|
61
|
+
# Offense count: 2
|
62
|
+
# Cop supports --auto-correct.
|
63
|
+
Style/Encoding:
|
64
|
+
Exclude:
|
65
|
+
- 'acts_as_archival.gemspec'
|
66
|
+
- 'test/scope_test.rb'
|
67
|
+
|
68
|
+
# Offense count: 1
|
69
|
+
Style/EvalWithLocation:
|
70
|
+
Exclude:
|
71
|
+
- 'lib/expected_behavior/acts_as_archival.rb'
|
72
|
+
|
73
|
+
# Offense count: 1
|
74
|
+
# Cop supports --auto-correct.
|
75
|
+
Style/ExpandPathArguments:
|
76
|
+
Exclude:
|
77
|
+
- 'acts_as_archival.gemspec'
|
78
|
+
|
79
|
+
# Offense count: 1
|
80
|
+
# Cop supports --auto-correct.
|
81
|
+
Style/IfUnlessModifier:
|
82
|
+
Exclude:
|
83
|
+
- 'test/test_helper.rb'
|
84
|
+
|
85
|
+
# Offense count: 1
|
86
|
+
# Cop supports --auto-correct.
|
87
|
+
# Configuration parameters: EnforcedStyle.
|
88
|
+
# SupportedStyles: implicit, explicit
|
89
|
+
Style/RescueStandardError:
|
90
|
+
Exclude:
|
91
|
+
- 'lib/expected_behavior/acts_as_archival.rb'
|
92
|
+
|
93
|
+
# Offense count: 3
|
94
|
+
# Cop supports --auto-correct.
|
95
|
+
# Configuration parameters: MinSize.
|
96
|
+
# SupportedStyles: percent, brackets
|
97
|
+
Style/SymbolArray:
|
98
|
+
EnforcedStyle: brackets
|
data/.travis.yml
CHANGED
@@ -1,32 +1,23 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
|
-
dist: trusty
|
4
2
|
cache: bundler
|
5
|
-
script: "bundle exec rake"
|
6
3
|
|
7
4
|
rvm:
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
11
|
-
- 2.
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
|
+
- 2.6
|
8
|
+
- 2.7
|
12
9
|
|
13
10
|
gemfile:
|
14
|
-
- gemfiles/rails_4.1.gemfile
|
15
|
-
- gemfiles/rails_4.2.gemfile
|
16
11
|
- gemfiles/rails_5.0.gemfile
|
17
12
|
- gemfiles/rails_5.1.gemfile
|
13
|
+
- gemfiles/rails_5.2.gemfile
|
14
|
+
- gemfiles/rails_6.0.gemfile
|
18
15
|
|
19
16
|
before_install:
|
20
17
|
- gem update --system
|
21
|
-
- gem update bundler
|
22
|
-
- gem cleanup bundler
|
23
18
|
|
24
19
|
matrix:
|
25
20
|
fast_finish: true
|
26
21
|
exclude:
|
27
|
-
-
|
28
|
-
|
29
|
-
- rvm: 2.1.10
|
30
|
-
gemfile: gemfiles/rails_5.1.gemfile
|
31
|
-
- rvm: 2.4.0
|
32
|
-
gemfile: gemfiles/rails_4.1.gemfile
|
22
|
+
- gemfile: gemfiles/rails_6.0.gemfile
|
23
|
+
rvm: 2.4
|
data/Appraisals
CHANGED
@@ -1,15 +1,7 @@
|
|
1
|
-
appraise "rails-
|
2
|
-
gem "rails", "~>
|
1
|
+
appraise "rails-6.1" do
|
2
|
+
gem "rails", "~> 6.1"
|
3
3
|
end
|
4
4
|
|
5
|
-
appraise "rails-
|
6
|
-
gem "rails", "~>
|
7
|
-
end
|
8
|
-
|
9
|
-
appraise "rails-5.0" do
|
10
|
-
gem "rails", "~> 5.0.0"
|
11
|
-
end
|
12
|
-
|
13
|
-
appraise "rails-5.1" do
|
14
|
-
gem "rails", "~> 5.1.0"
|
5
|
+
appraise "rails-7.0" do
|
6
|
+
gem "rails", "~> 7.0"
|
15
7
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
* **BREAKING CHANGE** Drop support for Rails 5.2 and 6.0 (6.1 support remains)
|
5
|
+
* Add support for Rails 7
|
6
|
+
* Fix deprecation warnings
|
7
|
+
* Need Ruby >=2.7 for Rails 7 support
|
8
|
+
|
9
|
+
## 2.0.0
|
10
|
+
|
11
|
+
* **BREAKING CHANGE** Drop support for Rails 4.2
|
12
|
+
* **BREAKING CHANGE** Drop support for Rails 5.0
|
13
|
+
* **BREAKING CHANGE** Drop support for Rails 5.1
|
14
|
+
* **BREAKING CHANGE** Removed deprecated methods
|
15
|
+
* Fix Rails 6 deprecation warnings
|
16
|
+
* Add offical support for Rails 6.1
|
17
|
+
|
18
|
+
## 1.4.0 - July 10, 2019
|
19
|
+
* **BREAKING CHANGE** drop support for rails 4.1
|
20
|
+
* **BREAKING CHANGE** drop support for Ruby <2.4
|
21
|
+
* **BUGFIX** polymorphic associations that are archived/unarchived can be acted on safely if they share the same ID.
|
22
|
+
* add support officially for rails 5.2
|
23
|
+
* sqlite upgrades for various rails
|
24
|
+
* new methods `#archive_all!` and `#unarchive_all` that can be called off scopes
|
25
|
+
|
26
|
+
|
3
27
|
## 1.3.0 - October 21, 2017
|
4
28
|
* deprecate `#archive` and `#unarchive` in favor of `#archive!` and `#unarchive!` [#36](https://github.com/expectedbehavior/acts_as_archival/pull/36)
|
5
29
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
acts_as_archival (2.1.0)
|
5
|
+
activerecord (>= 6.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (7.0.3)
|
11
|
+
activesupport (= 7.0.3)
|
12
|
+
activerecord (7.0.3)
|
13
|
+
activemodel (= 7.0.3)
|
14
|
+
activesupport (= 7.0.3)
|
15
|
+
activesupport (7.0.3)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
appraisal (2.2.0)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
thor (>= 0.14.0)
|
24
|
+
assertions-eb (1.7.3)
|
25
|
+
ast (2.4.2)
|
26
|
+
concurrent-ruby (1.1.10)
|
27
|
+
database_cleaner (1.8.4)
|
28
|
+
i18n (1.10.0)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
minitest (5.16.1)
|
31
|
+
parallel (1.22.1)
|
32
|
+
parser (3.1.2.0)
|
33
|
+
ast (~> 2.4.1)
|
34
|
+
rainbow (3.1.1)
|
35
|
+
rake (13.0.1)
|
36
|
+
regexp_parser (2.5.0)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rr (1.2.1)
|
39
|
+
rubocop (1.30.1)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 3.1.0.0)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.8, < 3.0)
|
44
|
+
rexml (>= 3.2.5, < 4.0)
|
45
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
48
|
+
rubocop-ast (1.18.0)
|
49
|
+
parser (>= 3.1.1.0)
|
50
|
+
ruby-progressbar (1.11.0)
|
51
|
+
sqlite3 (1.4.2)
|
52
|
+
thor (1.0.1)
|
53
|
+
tzinfo (2.0.4)
|
54
|
+
concurrent-ruby (~> 1.0)
|
55
|
+
unicode-display_width (2.1.0)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
acts_as_archival!
|
62
|
+
appraisal
|
63
|
+
assertions-eb
|
64
|
+
database_cleaner
|
65
|
+
rake
|
66
|
+
rr
|
67
|
+
rubocop (~> 1.30.1)
|
68
|
+
sqlite3
|
69
|
+
|
70
|
+
BUNDLED WITH
|
71
|
+
2.1.4
|
data/README.md
CHANGED
@@ -79,6 +79,25 @@ r.archived_at # => nil
|
|
79
79
|
r.archived? # => false
|
80
80
|
```
|
81
81
|
|
82
|
+
### Relations
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
Hole.create!
|
86
|
+
Hole.create!
|
87
|
+
Hole.create!
|
88
|
+
|
89
|
+
holes = Hole.all
|
90
|
+
|
91
|
+
# All records in the relation will be archived with the same archive_number.
|
92
|
+
# Dependent/Destroy relationships will be archived, and callbacks will still be honored.
|
93
|
+
holes.archive_all! # => [array of Hole records in the relation]
|
94
|
+
|
95
|
+
holes.first.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
|
96
|
+
holes.last.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
|
97
|
+
|
98
|
+
holes.unarchive_all! # => [array of Hole records in the relation]
|
99
|
+
```
|
100
|
+
|
82
101
|
### Scopes
|
83
102
|
|
84
103
|
``` ruby
|
@@ -95,9 +114,7 @@ Hole.unarchived.size # => 0
|
|
95
114
|
``` ruby
|
96
115
|
h = Hole.create #
|
97
116
|
h.archival? # => true
|
98
|
-
h.is_archival? # => true # deprecated
|
99
117
|
Hole.archival? # => true
|
100
|
-
Hole.is_archival? # => true # deprecated
|
101
118
|
```
|
102
119
|
|
103
120
|
### Options
|
@@ -144,8 +161,8 @@ end
|
|
144
161
|
|
145
162
|
#### Halting the callback chain
|
146
163
|
|
147
|
-
* Rails 4.
|
148
|
-
* Rails
|
164
|
+
* Rails 4.2 - the callback method should return a `false`/`nil` value.
|
165
|
+
* Rails 5.x - the callback should `throw(:abort)`/`raise(:abort)`.
|
149
166
|
|
150
167
|
## Caveats
|
151
168
|
|
@@ -190,6 +207,8 @@ ActsAsParanoid and PermanentRecords were both inspirations for this:
|
|
190
207
|
* Anthony Panozzo
|
191
208
|
* Aaron Milam
|
192
209
|
* Anton Rieder
|
210
|
+
* Josh Menden
|
211
|
+
* Sergey Gnuskov
|
193
212
|
|
194
213
|
Thanks!
|
195
214
|
|
data/acts_as_archival.gemspec
CHANGED
@@ -5,6 +5,7 @@ require "acts_as_archival/version"
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "acts_as_archival"
|
7
7
|
gem.summary = "Atomic archiving/unarchiving for ActiveRecord-based apps"
|
8
|
+
gem.licenses = ['MIT']
|
8
9
|
gem.version = ActsAsArchival::VERSION
|
9
10
|
gem.authors = ["Joel Meador",
|
10
11
|
"Michael Kuehl",
|
@@ -14,40 +15,48 @@ Gem::Specification.new do |gem|
|
|
14
15
|
"Dave Woodward",
|
15
16
|
"Miles Sterrett",
|
16
17
|
"James Hill",
|
17
|
-
"Maarten Claes"
|
18
|
+
"Maarten Claes",
|
19
|
+
"Anthony Panozzo",
|
20
|
+
"Aaron Milam",
|
21
|
+
"Anton Rieder",
|
22
|
+
"Josh Menden",
|
23
|
+
"Sergey Gnuskov"]
|
18
24
|
gem.email = ["joel@expectedbehavior.com",
|
19
25
|
"matt@expectedbehavior.com",
|
20
26
|
"jason@expectedbehavior.com",
|
21
27
|
"nathan@expectedbehavior.com"]
|
22
28
|
gem.homepage = "http://github.com/expectedbehavior/acts_as_archival"
|
23
29
|
|
30
|
+
gem.metadata["rubygems_mfa_required"] = "true"
|
31
|
+
|
24
32
|
gem.files = `git ls-files`.split("\n")
|
25
|
-
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
33
|
gem.require_paths = ["lib"]
|
34
|
+
gem.required_ruby_version = ">= 2.7.3"
|
27
35
|
|
28
|
-
gem.add_dependency "activerecord", ">=
|
36
|
+
gem.add_dependency "activerecord", ">= 6.1"
|
29
37
|
|
30
38
|
gem.add_development_dependency "appraisal"
|
31
39
|
gem.add_development_dependency "assertions-eb"
|
32
40
|
gem.add_development_dependency "database_cleaner"
|
33
41
|
gem.add_development_dependency "rake"
|
34
42
|
gem.add_development_dependency "rr"
|
43
|
+
gem.add_development_dependency "rubocop", "~> 1.30.1"
|
35
44
|
gem.add_development_dependency "sqlite3"
|
36
|
-
gem.add_development_dependency "rubocop", "~> 0.47.1"
|
37
45
|
|
38
|
-
gem.description =
|
39
|
-
|
46
|
+
gem.description =
|
47
|
+
<<~END
|
48
|
+
*Atomic archiving/unarchiving for ActiveRecord-based apps*
|
40
49
|
|
41
|
-
We had the problem that acts_as_paranoid and similar plugins/gems always work on
|
42
|
-
a record by record basis and made it very difficult to restore records
|
43
|
-
atomically (or archive them, for that matter).
|
50
|
+
We had the problem that acts_as_paranoid and similar plugins/gems always work on
|
51
|
+
a record by record basis and made it very difficult to restore records
|
52
|
+
atomically (or archive them, for that matter).
|
44
53
|
|
45
|
-
Because the archive and unarchive methods are in transactions, and every
|
46
|
-
archival record involved gets the same archive number upon archiving, you can
|
47
|
-
easily restore or remove an entire set of records without having to worry about
|
48
|
-
partial deletion or restoration.
|
54
|
+
Because the archive and unarchive methods are in transactions, and every
|
55
|
+
archival record involved gets the same archive number upon archiving, you can
|
56
|
+
easily restore or remove an entire set of records without having to worry about
|
57
|
+
partial deletion or restoration.
|
49
58
|
|
50
|
-
Additionally, other plugins generally screw with how destroy/delete work.
|
51
|
-
don't because we actually want to be able to destroy records.
|
52
|
-
END
|
59
|
+
Additionally, other plugins generally screw with how destroy/delete work. We
|
60
|
+
don't because we actually want to be able to destroy records.
|
61
|
+
END
|
53
62
|
end
|
data/lib/acts_as_archival.rb
CHANGED
@@ -15,3 +15,5 @@ else
|
|
15
15
|
ActiveRecord::Base.send :include, ExpectedBehavior::ActsAsArchival
|
16
16
|
ActiveRecord::Base.send :include, ExpectedBehavior::ActsAsArchivalActiveRecordMethods
|
17
17
|
end
|
18
|
+
|
19
|
+
ActiveRecord::Relation.send :include, ExpectedBehavior::ActsAsArchivalActiveRecordMethods::ARRelationMethods
|
@@ -3,13 +3,13 @@ module ExpectedBehavior
|
|
3
3
|
|
4
4
|
require "digest/md5"
|
5
5
|
|
6
|
-
unless defined?(MissingArchivalColumnError) == "constant" && MissingArchivalColumnError.
|
6
|
+
unless defined?(MissingArchivalColumnError) == "constant" && MissingArchivalColumnError.instance_of?(Class)
|
7
7
|
MissingArchivalColumnError = Class.new(ActiveRecord::ActiveRecordError)
|
8
8
|
end
|
9
|
-
unless defined?(CouldNotArchiveError) == "constant" && CouldNotArchiveError.
|
9
|
+
unless defined?(CouldNotArchiveError) == "constant" && CouldNotArchiveError.instance_of?(Class)
|
10
10
|
CouldNotArchiveError = Class.new(ActiveRecord::ActiveRecordError)
|
11
11
|
end
|
12
|
-
unless defined?(CouldNotUnarchiveError) == "constant" && CouldNotUnarchiveError.
|
12
|
+
unless defined?(CouldNotUnarchiveError) == "constant" && CouldNotUnarchiveError.instance_of?(Class)
|
13
13
|
CouldNotUnarchiveError = Class.new(ActiveRecord::ActiveRecordError)
|
14
14
|
end
|
15
15
|
|
@@ -37,7 +37,7 @@ module ExpectedBehavior
|
|
37
37
|
end
|
38
38
|
|
39
39
|
private def setup_scopes
|
40
|
-
scope :archived, -> { where.not(archived_at: nil
|
40
|
+
scope :archived, -> { where.not(archived_at: nil).where.not(archive_number: nil) }
|
41
41
|
scope :unarchived, -> { where(archived_at: nil, archive_number: nil) }
|
42
42
|
scope :archived_from_archive_number, (lambda do |head_archive_number|
|
43
43
|
where(["archived_at IS NOT NULL AND archive_number = ?", head_archive_number])
|
@@ -53,11 +53,7 @@ module ExpectedBehavior
|
|
53
53
|
end
|
54
54
|
|
55
55
|
private def setup_activerecord_callbacks(callbackable_actions)
|
56
|
-
|
57
|
-
define_callbacks(*[callbackable_actions].flatten)
|
58
|
-
elsif ActiveSupport::VERSION::MAJOR >= 4
|
59
|
-
define_callbacks(*[callbackable_actions, { terminator: ->(_, result) { result == false } }].flatten)
|
60
|
-
end
|
56
|
+
define_callbacks(*[callbackable_actions].flatten)
|
61
57
|
end
|
62
58
|
|
63
59
|
private def define_callback_dsl_methods(callbackable_actions)
|
@@ -70,6 +66,7 @@ module ExpectedBehavior
|
|
70
66
|
|
71
67
|
private def define_callback_dsl_method(callbackable_type, action)
|
72
68
|
# rubocop:disable Security/Eval
|
69
|
+
# rubocop:disable Style/DocumentDynamicEvalDefinition
|
73
70
|
eval <<-end_callbacks
|
74
71
|
unless defined?(#{callbackable_type}_#{action})
|
75
72
|
def #{callbackable_type}_#{action}(*args, &blk)
|
@@ -77,6 +74,7 @@ module ExpectedBehavior
|
|
77
74
|
end
|
78
75
|
end
|
79
76
|
end_callbacks
|
77
|
+
# rubocop:enable Style/DocumentDynamicEvalDefinition
|
80
78
|
# rubocop:enable Security/Eval
|
81
79
|
end
|
82
80
|
|
@@ -104,14 +102,6 @@ module ExpectedBehavior
|
|
104
102
|
!!(archived_at? && archive_number)
|
105
103
|
end
|
106
104
|
|
107
|
-
def archive(head_archive_number = nil)
|
108
|
-
ActiveSupport::Deprecation.warn <<-EOS.strip_heredoc.gsub(/\s+/, " ")
|
109
|
-
'.archive' is deprecated and will be removed in future versions of acts_as_archival.
|
110
|
-
Please use '.archive!' instead.
|
111
|
-
EOS
|
112
|
-
archive!(head_archive_number)
|
113
|
-
end
|
114
|
-
|
115
105
|
def archive!(head_archive_number = nil)
|
116
106
|
execute_archival_action(:archive) do
|
117
107
|
unless archived?
|
@@ -124,14 +114,6 @@ module ExpectedBehavior
|
|
124
114
|
end
|
125
115
|
end
|
126
116
|
|
127
|
-
def unarchive(head_archive_number = nil)
|
128
|
-
ActiveSupport::Deprecation.warn <<-EOS.strip_heredoc.gsub(/\s+/, " ")
|
129
|
-
'.unarchive' is deprecated and will be removed in future versions of acts_as_archival.
|
130
|
-
Please use '.unarchive!' instead.
|
131
|
-
EOS
|
132
|
-
unarchive!(head_archive_number)
|
133
|
-
end
|
134
|
-
|
135
117
|
def unarchive!(head_archive_number = nil)
|
136
118
|
execute_archival_action(:unarchive) do
|
137
119
|
if archived?
|
@@ -152,16 +134,15 @@ module ExpectedBehavior
|
|
152
134
|
AssociationOperation::Unarchive.new(self, head_archive_number).execute
|
153
135
|
end
|
154
136
|
|
155
|
-
private def execute_archival_action(action)
|
137
|
+
private def execute_archival_action(action, &block)
|
138
|
+
result = false
|
156
139
|
self.class.transaction do
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
rescue => e
|
161
|
-
handle_archival_action_exception(e)
|
162
|
-
end
|
140
|
+
result = !!run_callbacks(action, &block)
|
141
|
+
rescue => e
|
142
|
+
handle_archival_action_exception(e)
|
163
143
|
end
|
164
|
-
|
144
|
+
|
145
|
+
result
|
165
146
|
end
|
166
147
|
|
167
148
|
private def handle_archival_action_exception(exception)
|
@@ -12,13 +12,6 @@ module ExpectedBehavior
|
|
12
12
|
included_modules.include?(ExpectedBehavior::ActsAsArchival::InstanceMethods)
|
13
13
|
end
|
14
14
|
|
15
|
-
# rubocop:disable Style/PredicateName
|
16
|
-
def is_archival?
|
17
|
-
ActiveSupport::Deprecation.warn(".is_archival? is deprecated in favor of .archival?")
|
18
|
-
archival?
|
19
|
-
end
|
20
|
-
# rubocop:enable Style/PredicateName
|
21
|
-
|
22
15
|
end
|
23
16
|
|
24
17
|
module ARInstanceMethods
|
@@ -27,12 +20,24 @@ module ExpectedBehavior
|
|
27
20
|
self.class.archival?
|
28
21
|
end
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
module ARRelationMethods
|
26
|
+
|
27
|
+
def archive_all!
|
28
|
+
error_message = "The #{klass} must implement 'act_on_archivals' in order to call `archive_all!`"
|
29
|
+
raise NotImplementedError.new(error_message) unless archival?
|
30
|
+
|
31
|
+
head_archive_number = Digest::MD5.hexdigest("#{klass}#{Time.now.utc.to_i}")
|
32
|
+
each { |record| record.archive!(head_archive_number) }.tap { reset }
|
33
|
+
end
|
34
|
+
|
35
|
+
def unarchive_all!
|
36
|
+
error_message = "The #{klass} must implement 'act_on_archivals' in order to call `unarchive_all!`"
|
37
|
+
raise NotImplementedError.new(error_message) unless archival?
|
38
|
+
|
39
|
+
each(&:unarchive!).tap { reset }
|
34
40
|
end
|
35
|
-
# rubocop:enable Style/PredicateName
|
36
41
|
|
37
42
|
end
|
38
43
|
|
@@ -36,7 +36,11 @@ module ExpectedBehavior
|
|
36
36
|
|
37
37
|
def act_on_association(association)
|
38
38
|
key = association.respond_to?(:foreign_key) ? association.foreign_key : association.primary_key_name
|
39
|
-
|
39
|
+
scope_conditions = { key => model.id }
|
40
|
+
# polymorphic associations need a type so we don't accidentally act on multiple associated objects
|
41
|
+
# that have the same ID
|
42
|
+
scope_conditions[association.type] = model.class.base_class.name if association.type
|
43
|
+
scope = association.klass.where(scope_conditions)
|
40
44
|
act_on_archivals(scope)
|
41
45
|
end
|
42
46
|
|
data/test/callbacks_test.rb
CHANGED
@@ -2,40 +2,21 @@ require_relative "test_helper"
|
|
2
2
|
|
3
3
|
class CallbacksTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
test "can be halted" do
|
15
|
-
archival = CallbackArchival5.create
|
16
|
-
archival.set_this_value = "a test string"
|
17
|
-
archival.pass_callback = false
|
18
|
-
assert_nil archival.settable_field
|
19
|
-
archival.archive!
|
20
|
-
assert_nil archival.reload.settable_field
|
21
|
-
end
|
22
|
-
else
|
23
|
-
test "can set a value as part of archiving" do
|
24
|
-
archival = CallbackArchival4.create
|
25
|
-
archival.set_this_value = "a test string"
|
26
|
-
assert_nil archival.settable_field
|
27
|
-
archival.archive!
|
28
|
-
assert_equal "a test string", archival.reload.settable_field
|
29
|
-
end
|
5
|
+
test "can set a value as part of archiving" do
|
6
|
+
archival = CallbackArchival.create
|
7
|
+
archival.set_this_value = "a test string"
|
8
|
+
assert_nil archival.settable_field
|
9
|
+
archival.archive!
|
10
|
+
assert_equal "a test string", archival.reload.settable_field
|
11
|
+
end
|
30
12
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
13
|
+
test "can be halted" do
|
14
|
+
archival = CallbackArchival.create
|
15
|
+
archival.set_this_value = "a test string"
|
16
|
+
archival.pass_callback = false
|
17
|
+
assert_nil archival.settable_field
|
18
|
+
archival.archive!
|
19
|
+
assert_nil archival.reload.settable_field
|
39
20
|
end
|
40
21
|
|
41
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class CallbackArchival < ApplicationRecord
|
2
2
|
|
3
3
|
acts_as_archival
|
4
4
|
|
@@ -8,12 +8,15 @@ class CallbackArchival4 < ActiveRecord::Base
|
|
8
8
|
before_archive :set_value,
|
9
9
|
:conditional_callback_passer
|
10
10
|
|
11
|
-
private
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_value
|
12
14
|
self.settable_field = set_this_value
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
def conditional_callback_passer
|
18
|
+
# we want to throw only for the value false
|
19
|
+
throw(:abort) unless pass_callback || pass_callback.nil?
|
17
20
|
end
|
18
21
|
|
19
22
|
end
|
data/test/polymorphic_test.rb
CHANGED
@@ -11,6 +11,15 @@ class PolymorphicTest < ActiveSupport::TestCase
|
|
11
11
|
assert poly.reload.archived?
|
12
12
|
end
|
13
13
|
|
14
|
+
test "does not archive polymorphic association of different item with same id" do
|
15
|
+
archival = Archival.create!
|
16
|
+
another_polys_holder = AnotherPolysHolder.create!(id: archival.id)
|
17
|
+
poly = another_polys_holder.polys.create!
|
18
|
+
archival.archive!
|
19
|
+
|
20
|
+
assert_not poly.reload.archived?
|
21
|
+
end
|
22
|
+
|
14
23
|
test "unarchive item with polymorphic association" do
|
15
24
|
archive_attributes = {
|
16
25
|
archive_number: "test",
|
@@ -24,4 +33,18 @@ class PolymorphicTest < ActiveSupport::TestCase
|
|
24
33
|
assert_not poly.reload.archived?
|
25
34
|
end
|
26
35
|
|
36
|
+
test "does not unarchive polymorphic association of different item with same id" do
|
37
|
+
archive_attributes = {
|
38
|
+
archive_number: "test",
|
39
|
+
archived_at: Time.now
|
40
|
+
}
|
41
|
+
|
42
|
+
archival = Archival.create!(archive_attributes)
|
43
|
+
another_polys_holder = AnotherPolysHolder.create!(archive_attributes.merge(id: archival.id))
|
44
|
+
poly = another_polys_holder.polys.create!(archive_attributes)
|
45
|
+
archival.unarchive!
|
46
|
+
|
47
|
+
assert poly.reload.archived?
|
48
|
+
end
|
49
|
+
|
27
50
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class RelationsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "archive_all! archives all records in an AR Association" do
|
6
|
+
3.times { Archival.create! }
|
7
|
+
|
8
|
+
archivals = Archival.all
|
9
|
+
archivals.archive_all!
|
10
|
+
assert archivals.first.archived?
|
11
|
+
assert archivals.last.archived?
|
12
|
+
end
|
13
|
+
|
14
|
+
test "archive_all! archives all records with the same archival number" do
|
15
|
+
3.times { Archival.create! }
|
16
|
+
|
17
|
+
archivals = Archival.all
|
18
|
+
archivals.archive_all!
|
19
|
+
assert_equal archivals.first.archive_number, archivals.last.archive_number
|
20
|
+
end
|
21
|
+
|
22
|
+
test "archive_all! archives children records" do
|
23
|
+
3.times do
|
24
|
+
parent = Archival.create!
|
25
|
+
2.times do
|
26
|
+
parent.archivals.create!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
parents = Archival.all
|
31
|
+
parents.archive_all!
|
32
|
+
|
33
|
+
assert parents.first.archivals.first.archived?
|
34
|
+
assert parents.first.archivals.last.archived?
|
35
|
+
end
|
36
|
+
|
37
|
+
test "unarchive_all! unarchives all records in an AR Assocation" do
|
38
|
+
3.times { Archival.create! }
|
39
|
+
|
40
|
+
archivals = Archival.all
|
41
|
+
archivals.archive_all!
|
42
|
+
archivals.unarchive_all!
|
43
|
+
assert_not archivals.first.archived?
|
44
|
+
assert_not archivals.last.archived?
|
45
|
+
end
|
46
|
+
|
47
|
+
test "unarchive_all! unarchives children records" do
|
48
|
+
3.times do
|
49
|
+
parent = Archival.create!
|
50
|
+
2.times do
|
51
|
+
parent.archivals.create!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
parents = Archival.all
|
56
|
+
parents.archive_all!
|
57
|
+
parents.unarchive_all!
|
58
|
+
|
59
|
+
assert_not parents.first.archivals.first.archived?
|
60
|
+
assert_not parents.first.archivals.last.archived?
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/test/responds_test.rb
CHANGED
@@ -12,20 +12,4 @@ class RespondsTest < ActiveSupport::TestCase
|
|
12
12
|
assert_not Plain.new.archival?
|
13
13
|
end
|
14
14
|
|
15
|
-
### Deprecation Zone ###
|
16
|
-
|
17
|
-
test "archival class responds correctly to 'is_archival?'" do
|
18
|
-
ActiveSupport::Deprecation.silence do
|
19
|
-
assert Archival.is_archival?
|
20
|
-
assert_not Plain.is_archival?
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
test "archival object responds correctly to 'is_archival?'" do
|
25
|
-
ActiveSupport::Deprecation.silence do
|
26
|
-
assert Archival.new.is_archival?
|
27
|
-
assert_not Plain.new.is_archival?
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
15
|
end
|
data/test/schema.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
ActiveRecord::Schema.define(version: 1) do
|
2
|
+
create_table :another_polys_holders, force: true do |t|
|
3
|
+
t.column :name, :string
|
4
|
+
t.column :archival_id, :integer
|
5
|
+
t.column :archive_number, :string
|
6
|
+
t.column :archived_at, :datetime
|
7
|
+
end
|
8
|
+
|
2
9
|
create_table :archivals, force: true do |t|
|
3
10
|
t.column :name, :string
|
4
11
|
t.column :archival_id, :integer
|
@@ -69,13 +76,7 @@ ActiveRecord::Schema.define(version: 1) do
|
|
69
76
|
t.column :archived_at, :datetime
|
70
77
|
end
|
71
78
|
|
72
|
-
create_table :
|
73
|
-
t.column :settable_field, :string
|
74
|
-
t.column :archive_number, :string
|
75
|
-
t.column :archived_at, :datetime
|
76
|
-
end
|
77
|
-
|
78
|
-
create_table :callback_archival5s, force: true do |t|
|
79
|
+
create_table :callback_archivals, force: true do |t|
|
79
80
|
t.column :settable_field, :string
|
80
81
|
t.column :archive_number, :string
|
81
82
|
t.column :archived_at, :datetime
|
data/test/scope_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require_relative "test_helper"
|
2
3
|
|
3
4
|
class ScopeTest < ActiveSupport::TestCase
|
@@ -50,16 +51,12 @@ class ScopeTest < ActiveSupport::TestCase
|
|
50
51
|
end
|
51
52
|
|
52
53
|
test "table_name is set to 'legacy'" do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
archived_sql = "SELECT \"legacy\".* FROM \"legacy\"#{spaces}" \
|
60
|
-
'WHERE ("legacy"."archived_at" IS NOT NULL) AND ("legacy"."archive_number" IS NOT NULL)'
|
61
|
-
unarchived_sql = "SELECT \"legacy\".* FROM \"legacy\"#{spaces}" \
|
62
|
-
'WHERE "legacy"."archived_at" IS NULL AND "legacy"."archive_number" IS NULL'
|
54
|
+
archived_sql =
|
55
|
+
"SELECT \"legacy\".* FROM \"legacy\" " \
|
56
|
+
'WHERE "legacy"."archived_at" IS NOT NULL AND "legacy"."archive_number" IS NOT NULL'
|
57
|
+
|
58
|
+
unarchived_sql = "SELECT \"legacy\".* FROM \"legacy\" " \
|
59
|
+
'WHERE "legacy"."archived_at" IS NULL AND "legacy"."archive_number" IS NULL'
|
63
60
|
assert_equal archived_sql, ArchivalTableName.archived.to_sql
|
64
61
|
assert_equal unarchived_sql, ArchivalTableName.unarchived.to_sql
|
65
62
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__)
|
1
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
|
2
2
|
require "bundler/setup"
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "minitest/pride"
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
def setup_logging
|
24
24
|
require "logger"
|
25
|
-
logfile = File.dirname(__FILE__)
|
25
|
+
logfile = "#{File.dirname(__FILE__)}/debug.log"
|
26
26
|
ActiveRecord::Base.logger = Logger.new(logfile)
|
27
27
|
end
|
28
28
|
|
@@ -43,13 +43,14 @@ def sqlite_config
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def create_test_tables
|
46
|
-
schema_file = File.dirname(__FILE__)
|
46
|
+
schema_file = "#{File.dirname(__FILE__)}/schema.rb"
|
47
47
|
puts "** Loading schema for SQLite"
|
48
48
|
ActiveRecord::Base.establish_connection(sqlite_config)
|
49
49
|
load(schema_file) if File.exist?(schema_file)
|
50
50
|
end
|
51
51
|
|
52
52
|
BASE_FIXTURE_CLASSES = [
|
53
|
+
:another_polys_holder,
|
53
54
|
:archival,
|
54
55
|
:archival_kid,
|
55
56
|
:archival_grandkid,
|
@@ -60,17 +61,10 @@ BASE_FIXTURE_CLASSES = [
|
|
60
61
|
:missing_archive_number,
|
61
62
|
:plain,
|
62
63
|
:poly,
|
63
|
-
:readonly_when_archived
|
64
|
-
].freeze
|
65
|
-
|
66
|
-
RAILS_4_FIXTURE_CLASSES = [
|
67
|
-
:callback_archival_4
|
68
|
-
].freeze
|
69
|
-
|
70
|
-
RAILS_5_FIXTURE_CLASSES = [
|
64
|
+
:readonly_when_archived,
|
71
65
|
:application_record,
|
72
66
|
:application_record_row,
|
73
|
-
:
|
67
|
+
:callback_archival
|
74
68
|
].freeze
|
75
69
|
|
76
70
|
def require_test_classes
|
@@ -78,14 +72,9 @@ def require_test_classes
|
|
78
72
|
inflect.irregular "poly", "polys"
|
79
73
|
end
|
80
74
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
RAILS_4_FIXTURE_CLASSES + BASE_FIXTURE_CLASSES
|
85
|
-
end
|
86
|
-
|
87
|
-
fixtures += BASE_FIXTURE_CLASSES
|
88
|
-
fixtures.each { |test_class_file| require_relative "fixtures/#{test_class_file}" }
|
75
|
+
BASE_FIXTURE_CLASSES.each do |test_class_file|
|
76
|
+
require_relative "fixtures/#{test_class_file}"
|
77
|
+
end
|
89
78
|
end
|
90
79
|
|
91
80
|
prepare_for_tests
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_archival
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Meador
|
@@ -13,10 +13,15 @@ authors:
|
|
13
13
|
- Miles Sterrett
|
14
14
|
- James Hill
|
15
15
|
- Maarten Claes
|
16
|
-
|
16
|
+
- Anthony Panozzo
|
17
|
+
- Aaron Milam
|
18
|
+
- Anton Rieder
|
19
|
+
- Josh Menden
|
20
|
+
- Sergey Gnuskov
|
21
|
+
autorequire:
|
17
22
|
bindir: bin
|
18
23
|
cert_chain: []
|
19
|
-
date:
|
24
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
20
25
|
dependencies:
|
21
26
|
- !ruby/object:Gem::Dependency
|
22
27
|
name: activerecord
|
@@ -24,14 +29,14 @@ dependencies:
|
|
24
29
|
requirements:
|
25
30
|
- - ">="
|
26
31
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
32
|
+
version: '6.1'
|
28
33
|
type: :runtime
|
29
34
|
prerelease: false
|
30
35
|
version_requirements: !ruby/object:Gem::Requirement
|
31
36
|
requirements:
|
32
37
|
- - ">="
|
33
38
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
39
|
+
version: '6.1'
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: appraisal
|
37
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,33 +108,33 @@ dependencies:
|
|
103
108
|
- !ruby/object:Gem::Version
|
104
109
|
version: '0'
|
105
110
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
111
|
+
name: rubocop
|
107
112
|
requirement: !ruby/object:Gem::Requirement
|
108
113
|
requirements:
|
109
|
-
- - "
|
114
|
+
- - "~>"
|
110
115
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
116
|
+
version: 1.30.1
|
112
117
|
type: :development
|
113
118
|
prerelease: false
|
114
119
|
version_requirements: !ruby/object:Gem::Requirement
|
115
120
|
requirements:
|
116
|
-
- - "
|
121
|
+
- - "~>"
|
117
122
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
123
|
+
version: 1.30.1
|
119
124
|
- !ruby/object:Gem::Dependency
|
120
|
-
name:
|
125
|
+
name: sqlite3
|
121
126
|
requirement: !ruby/object:Gem::Requirement
|
122
127
|
requirements:
|
123
|
-
- - "
|
128
|
+
- - ">="
|
124
129
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0
|
130
|
+
version: '0'
|
126
131
|
type: :development
|
127
132
|
prerelease: false
|
128
133
|
version_requirements: !ruby/object:Gem::Requirement
|
129
134
|
requirements:
|
130
|
-
- - "
|
135
|
+
- - ">="
|
131
136
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0
|
137
|
+
version: '0'
|
133
138
|
description: |
|
134
139
|
*Atomic archiving/unarchiving for ActiveRecord-based apps*
|
135
140
|
|
@@ -142,7 +147,7 @@ description: |
|
|
142
147
|
easily restore or remove an entire set of records without having to worry about
|
143
148
|
partial deletion or restoration.
|
144
149
|
|
145
|
-
Additionally, other plugins generally screw with how destroy/delete work.
|
150
|
+
Additionally, other plugins generally screw with how destroy/delete work. We
|
146
151
|
don't because we actually want to be able to destroy records.
|
147
152
|
email:
|
148
153
|
- joel@expectedbehavior.com
|
@@ -160,14 +165,13 @@ files:
|
|
160
165
|
- Appraisals
|
161
166
|
- CHANGELOG.md
|
162
167
|
- Gemfile
|
168
|
+
- Gemfile.lock
|
163
169
|
- LICENSE
|
164
170
|
- README.md
|
165
171
|
- Rakefile
|
166
172
|
- acts_as_archival.gemspec
|
167
|
-
- gemfiles/
|
168
|
-
- gemfiles/
|
169
|
-
- gemfiles/rails_5.0.gemfile
|
170
|
-
- gemfiles/rails_5.1.gemfile
|
173
|
+
- gemfiles/rails_6.1.gemfile
|
174
|
+
- gemfiles/rails_7.0.gemfile
|
171
175
|
- init.rb
|
172
176
|
- lib/acts_as_archival.rb
|
173
177
|
- lib/acts_as_archival/version.rb
|
@@ -184,14 +188,14 @@ files:
|
|
184
188
|
- test/callbacks_test.rb
|
185
189
|
- test/column_test.rb
|
186
190
|
- test/deep_nesting_test.rb
|
191
|
+
- test/fixtures/another_polys_holder.rb
|
187
192
|
- test/fixtures/application_record.rb
|
188
193
|
- test/fixtures/application_record_row.rb
|
189
194
|
- test/fixtures/archival.rb
|
190
195
|
- test/fixtures/archival_grandkid.rb
|
191
196
|
- test/fixtures/archival_kid.rb
|
192
197
|
- test/fixtures/archival_table_name.rb
|
193
|
-
- test/fixtures/
|
194
|
-
- test/fixtures/callback_archival_5.rb
|
198
|
+
- test/fixtures/callback_archival.rb
|
195
199
|
- test/fixtures/exploder.rb
|
196
200
|
- test/fixtures/independent_archival.rb
|
197
201
|
- test/fixtures/missing_archive_number.rb
|
@@ -201,6 +205,7 @@ files:
|
|
201
205
|
- test/fixtures/readonly_when_archived.rb
|
202
206
|
- test/polymorphic_test.rb
|
203
207
|
- test/readonly_when_archived_test.rb
|
208
|
+
- test/relations_test.rb
|
204
209
|
- test/responds_test.rb
|
205
210
|
- test/schema.rb
|
206
211
|
- test/scope_test.rb
|
@@ -208,9 +213,11 @@ files:
|
|
208
213
|
- test/through_association_test.rb
|
209
214
|
- test/transaction_test.rb
|
210
215
|
homepage: http://github.com/expectedbehavior/acts_as_archival
|
211
|
-
licenses:
|
212
|
-
|
213
|
-
|
216
|
+
licenses:
|
217
|
+
- MIT
|
218
|
+
metadata:
|
219
|
+
rubygems_mfa_required: 'true'
|
220
|
+
post_install_message:
|
214
221
|
rdoc_options: []
|
215
222
|
require_paths:
|
216
223
|
- lib
|
@@ -218,46 +225,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
225
|
requirements:
|
219
226
|
- - ">="
|
220
227
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
228
|
+
version: 2.7.3
|
222
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
230
|
requirements:
|
224
231
|
- - ">="
|
225
232
|
- !ruby/object:Gem::Version
|
226
233
|
version: '0'
|
227
234
|
requirements: []
|
228
|
-
|
229
|
-
|
230
|
-
signing_key:
|
235
|
+
rubygems_version: 3.3.3
|
236
|
+
signing_key:
|
231
237
|
specification_version: 4
|
232
238
|
summary: Atomic archiving/unarchiving for ActiveRecord-based apps
|
233
|
-
test_files:
|
234
|
-
- test/ambiguous_table_test.rb
|
235
|
-
- test/application_record_test.rb
|
236
|
-
- test/associations_test.rb
|
237
|
-
- test/basic_test.rb
|
238
|
-
- test/callbacks_test.rb
|
239
|
-
- test/column_test.rb
|
240
|
-
- test/deep_nesting_test.rb
|
241
|
-
- test/fixtures/application_record.rb
|
242
|
-
- test/fixtures/application_record_row.rb
|
243
|
-
- test/fixtures/archival.rb
|
244
|
-
- test/fixtures/archival_grandkid.rb
|
245
|
-
- test/fixtures/archival_kid.rb
|
246
|
-
- test/fixtures/archival_table_name.rb
|
247
|
-
- test/fixtures/callback_archival_4.rb
|
248
|
-
- test/fixtures/callback_archival_5.rb
|
249
|
-
- test/fixtures/exploder.rb
|
250
|
-
- test/fixtures/independent_archival.rb
|
251
|
-
- test/fixtures/missing_archive_number.rb
|
252
|
-
- test/fixtures/missing_archived_at.rb
|
253
|
-
- test/fixtures/plain.rb
|
254
|
-
- test/fixtures/poly.rb
|
255
|
-
- test/fixtures/readonly_when_archived.rb
|
256
|
-
- test/polymorphic_test.rb
|
257
|
-
- test/readonly_when_archived_test.rb
|
258
|
-
- test/responds_test.rb
|
259
|
-
- test/schema.rb
|
260
|
-
- test/scope_test.rb
|
261
|
-
- test/test_helper.rb
|
262
|
-
- test/through_association_test.rb
|
263
|
-
- test/transaction_test.rb
|
239
|
+
test_files: []
|
data/gemfiles/rails_5.0.gemfile
DELETED
data/gemfiles/rails_5.1.gemfile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# necessary for ApplicationRecord
|
2
|
-
if defined?(ApplicationRecord)
|
3
|
-
class CallbackArchival5 < ApplicationRecord
|
4
|
-
|
5
|
-
acts_as_archival
|
6
|
-
|
7
|
-
attr_accessor :set_this_value,
|
8
|
-
:pass_callback
|
9
|
-
|
10
|
-
before_archive :set_value,
|
11
|
-
:conditional_callback_passer
|
12
|
-
|
13
|
-
private def set_value
|
14
|
-
self.settable_field = set_this_value
|
15
|
-
end
|
16
|
-
|
17
|
-
private def conditional_callback_passer
|
18
|
-
# we want to throw only for the value false
|
19
|
-
throw(:abort) unless pass_callback || pass_callback.nil?
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|