acts_as_archive 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -2
- data/config/gemsets.yml +2 -2
- data/config/gemspec.yml +2 -7
- data/lib/acts_as_archive.rb +8 -5
- data/spec/Rakefile +1 -1
- data/spec/fixtures/frameworks/rails3/Gemfile +1 -0
- data/spec/spec_helper.rb +2 -0
- metadata +12 -81
data/README.md
CHANGED
@@ -57,6 +57,13 @@ Use <code>destroy</code>, <code>destroy\_all</code>, <code>delete</code>, and <c
|
|
57
57
|
|
58
58
|
Records move into the archive table instead of being destroyed.
|
59
59
|
|
60
|
+
Automatically archive relationships
|
61
|
+
-----------------------------------
|
62
|
+
|
63
|
+
If your <code>acts\_as\_archive</code> model's relationship has the <code>:dependent</code> option and also uses <code>acts\_as\_archive</code>, that relationship will archive automatically.
|
64
|
+
|
65
|
+
__To use this feature, you must declare your relationships before the <code>acts\_as\_archive</code> call within your model!__
|
66
|
+
|
60
67
|
What if my schema changes?
|
61
68
|
--------------------------
|
62
69
|
|
@@ -79,7 +86,7 @@ Delete records without archiving
|
|
79
86
|
Use any of the destroy methods, but add a bang (!):
|
80
87
|
|
81
88
|
<pre>
|
82
|
-
Article::Archive.
|
89
|
+
Article::Archive.first.destroy!
|
83
90
|
Article.delete_all!([ "id in (?)", [ 1, 2, 3 ] ])
|
84
91
|
</pre>
|
85
92
|
|
@@ -109,4 +116,9 @@ Add this line to a migration, or run it via <code>script/console</code>:
|
|
109
116
|
Article.migrate_from_acts_as_paranoid
|
110
117
|
</pre>
|
111
118
|
|
112
|
-
This copies all records with non-null <code>deleted_at</code> values to the archive.
|
119
|
+
This copies all records with non-null <code>deleted_at</code> values to the archive.
|
120
|
+
|
121
|
+
Running specs
|
122
|
+
-------------
|
123
|
+
|
124
|
+
There is a [wiki entry](https://github.com/winton/acts_as_archive/wiki/Running-Specs) that describes the development setup in-depth.
|
data/config/gemsets.yml
CHANGED
data/config/gemspec.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
name: acts_as_archive
|
2
|
-
version: 0.3.
|
2
|
+
version: 0.3.3
|
3
3
|
authors:
|
4
4
|
- Winton Welsh
|
5
5
|
email: mail@wintoni.us
|
@@ -9,9 +9,4 @@ description: Don't delete your records, move them to a different table. Like act
|
|
9
9
|
dependencies:
|
10
10
|
- also_migrate
|
11
11
|
- mover
|
12
|
-
development_dependencies:
|
13
|
-
- active_wrapper-solo
|
14
|
-
- externals
|
15
|
-
- framework_fixture
|
16
|
-
- rake
|
17
|
-
- rspec
|
12
|
+
development_dependencies: null
|
data/lib/acts_as_archive.rb
CHANGED
@@ -173,12 +173,15 @@ class ActsAsArchive
|
|
173
173
|
|
174
174
|
module InstanceMethods
|
175
175
|
def delete_sql_with_archive(sql, name = nil)
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
@mutex ||= Mutex.new
|
177
|
+
@mutex.synchronize do
|
178
|
+
unless ActsAsArchive.disabled
|
179
|
+
from, where = /DELETE FROM (.+)/i.match(sql)[1].split(/\s+WHERE\s+/i, 2)
|
180
|
+
from = from.strip.gsub(/`/, '').split(/\s*,\s*/)
|
179
181
|
|
180
|
-
|
181
|
-
|
182
|
+
ActsAsArchive.find(from).each do |config|
|
183
|
+
ActsAsArchive.move(config, where)
|
184
|
+
end
|
182
185
|
end
|
183
186
|
end
|
184
187
|
|
data/spec/Rakefile
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -45,6 +45,8 @@ else
|
|
45
45
|
ActiveSupport::Dependencies.autoload_paths << "#{$root}/spec/fixtures/models"
|
46
46
|
ActiveSupport::Dependencies.autoload_paths << "#{$root}/spec/fixtures/helpers"
|
47
47
|
|
48
|
+
Record # Load up an instance so first also_migrate works
|
49
|
+
|
48
50
|
include SpecHelper
|
49
51
|
end
|
50
52
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Winton Welsh
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-20 00:00:00 -08:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,11 +26,12 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - "="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
- 3
|
31
|
-
-
|
32
|
-
version: 0.3.
|
33
|
+
- 3
|
34
|
+
version: 0.3.3
|
33
35
|
type: :runtime
|
34
36
|
version_requirements: *id001
|
35
37
|
- !ruby/object:Gem::Dependency
|
@@ -40,6 +42,7 @@ dependencies:
|
|
40
42
|
requirements:
|
41
43
|
- - "="
|
42
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 31
|
43
46
|
segments:
|
44
47
|
- 0
|
45
48
|
- 3
|
@@ -47,80 +50,6 @@ dependencies:
|
|
47
50
|
version: 0.3.6
|
48
51
|
type: :runtime
|
49
52
|
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: active_wrapper-solo
|
52
|
-
prerelease: false
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - "="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
- 4
|
61
|
-
- 4
|
62
|
-
version: 0.4.4
|
63
|
-
type: :development
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: externals
|
67
|
-
prerelease: false
|
68
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
71
|
-
- - "="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
segments:
|
74
|
-
- 1
|
75
|
-
- 0
|
76
|
-
- 2
|
77
|
-
version: 1.0.2
|
78
|
-
type: :development
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: framework_fixture
|
82
|
-
prerelease: false
|
83
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
|
-
requirements:
|
86
|
-
- - "="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
- 1
|
91
|
-
- 3
|
92
|
-
version: 0.1.3
|
93
|
-
type: :development
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: rake
|
97
|
-
prerelease: false
|
98
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
- 8
|
106
|
-
- 7
|
107
|
-
version: 0.8.7
|
108
|
-
type: :development
|
109
|
-
version_requirements: *id006
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: rspec
|
112
|
-
prerelease: false
|
113
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
|
-
requirements:
|
116
|
-
- - ~>
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
segments:
|
119
|
-
- 1
|
120
|
-
- 0
|
121
|
-
version: "1.0"
|
122
|
-
type: :development
|
123
|
-
version_requirements: *id007
|
124
53
|
description: Don't delete your records, move them to a different table. Like acts_as_paranoid, but doesn't mess with your SQL queries.
|
125
54
|
email: mail@wintoni.us
|
126
55
|
executables: []
|
@@ -193,6 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
122
|
requirements:
|
194
123
|
- - ">="
|
195
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
196
126
|
segments:
|
197
127
|
- 0
|
198
128
|
version: "0"
|
@@ -201,13 +131,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
131
|
requirements:
|
202
132
|
- - ">="
|
203
133
|
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
204
135
|
segments:
|
205
136
|
- 0
|
206
137
|
version: "0"
|
207
138
|
requirements: []
|
208
139
|
|
209
140
|
rubyforge_project:
|
210
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.4.2
|
211
142
|
signing_key:
|
212
143
|
specification_version: 3
|
213
144
|
summary: Don't delete your records, move them to a different table
|