acts_as_archival 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changes!
2
2
 
3
+ ## 0.5.0
4
+ * Rails 4.0.0b1 support. Thanks, James Hill!
5
+
6
+ ## 0.4.5
7
+ * possibly allow rails 2&3 to work when dealing with associations
8
+ * add some logging when archive/unarchive doesn't work
9
+
10
+ ## 0.4.4
11
+ * **BUGFIX** Callbacks were being called twice because of how we were defining them
12
+
13
+ ## 0.4.3
14
+ * Fix spelling error
15
+
3
16
  ## 0.4.2
4
17
  * Change homepage to the github repo
5
18
 
data/README.md CHANGED
@@ -97,9 +97,9 @@ postgres and if not, submit a patch / let us know about it!
97
97
 
98
98
  ## Thanks
99
99
 
100
- ActsAsParanoid and PermanentRecords were both inspirations for this
100
+ ActsAsParanoid and PermanentRecords were both inspirations for this:
101
101
  http://github.com/technoweenie/acts_as_paranoid
102
- http://github.com/fastestforward/permanent_records
102
+ http://github.com/fastestforward/permanent_records
103
103
 
104
104
  ## Contributors
105
105
 
@@ -109,7 +109,9 @@ http://github.com/fastestforward/permanent_records
109
109
  * Vojtech Salbaba
110
110
  * David Jones
111
111
  * Dave Woodward
112
+ * Miles Sterrett
113
+ * James Hill
112
114
 
113
115
  Thanks!
114
116
 
115
- *Copyright (c) 2009-2012 Expected Behavior, LLC, released under the MIT license*
117
+ *Copyright (c) 2009-2013 Expected Behavior, LLC, released under the MIT license*
@@ -11,7 +11,9 @@ Gem::Specification.new do |gem|
11
11
  "Matthew Gordon",
12
12
  "Vojtech Salbaba",
13
13
  "David Jones",
14
- "Dave Woodward"]
14
+ "Dave Woodward",
15
+ "Miles Sterrett",
16
+ "James Hill"]
15
17
  gem.email = ["joel@expectedbehavior.com",
16
18
  "michael@expectedbehavior.com",
17
19
  "matt@expectedbehavior.com"]
@@ -1,3 +1,3 @@
1
1
  module ActsAsArchival
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -46,7 +46,7 @@ module ExpectedBehavior
46
46
 
47
47
  def readonly_when_archived
48
48
  if self.archived? && self.changed? && !self.archived_at_changed? && !self.archive_number_changed?
49
- self.errors.add(:base, "Cannot modifify an archived record.")
49
+ self.errors.add(:base, "Cannot modify an archived record.")
50
50
  end
51
51
  end
52
52
 
@@ -64,17 +64,19 @@ module ExpectedBehavior
64
64
  def archive(head_archive_number=nil)
65
65
  self.class.transaction do
66
66
  begin
67
- run_callbacks :archive, :before
68
- unless self.archived?
69
- head_archive_number ||= Digest::MD5.hexdigest("#{self.class.name}#{self.id}")
70
- self.archive_associations(head_archive_number)
71
- self.archived_at = DateTime.now
72
- self.archive_number = head_archive_number
73
- self.save!
67
+ run_callbacks :archive do
68
+ unless self.archived?
69
+ head_archive_number ||= Digest::MD5.hexdigest("#{self.class.name}#{self.id}")
70
+ self.archive_associations(head_archive_number)
71
+ self.archived_at = DateTime.now
72
+ self.archive_number = head_archive_number
73
+ self.save!
74
+ end
74
75
  end
75
- run_callbacks :archive, :after
76
76
  return true
77
- rescue
77
+ rescue => e
78
+ ActiveRecord::Base.logger.try(:debug, e.message)
79
+ ActiveRecord::Base.logger.try(:debug, e.backtrace)
78
80
  raise ActiveRecord::Rollback
79
81
  end
80
82
  end
@@ -94,7 +96,9 @@ module ExpectedBehavior
94
96
  end
95
97
  run_callbacks :unarchive, :after
96
98
  return true
97
- rescue
99
+ rescue => e
100
+ ActiveRecord::Base.logger.try(:debug, e.message)
101
+ ActiveRecord::Base.logger.try(:debug, e.backtrace)
98
102
  raise ActiveRecord::Rollback
99
103
  end
100
104
  end
@@ -114,8 +118,11 @@ module ExpectedBehavior
114
118
  return if options.length == 0
115
119
  options[:association_options] ||= Proc.new { true }
116
120
  self.class.reflect_on_all_associations.each do |association|
117
- if association.macro.to_s =~ /^has/ && association.klass.is_archival? && options[:association_options].call(association) && association.options[:through].nil?
118
- act_on_a_related_archival(association.klass, association.foreign_key, id, head_archive_number, options)
121
+ if (association.macro.to_s =~ /^has/ && association.klass.is_archival? &&
122
+ options[:association_options].call(association) &&
123
+ association.options[:through].nil?)
124
+ association_key = association.respond_to?(:foreign_key) ? association.foreign_key : association.primary_key_name
125
+ act_on_a_related_archival(association.klass, association_key, id, head_archive_number, options)
119
126
  end
120
127
  end
121
128
  end
@@ -16,7 +16,7 @@ class ReadonlyWhenArchivedTest < ActiveSupport::TestCase
16
16
  archival.name = "updated"
17
17
 
18
18
  assert_not archival.save
19
- assert_equal "Cannot modifify an archived record.",
19
+ assert_equal "Cannot modify an archived record.",
20
20
  archival.errors.full_messages.first
21
21
  end
22
22
  end
data/test/script/db_setup CHANGED
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  def get_root_password
12
12
  $ROOT_PW = ask("Provide root mySQL password to setup '#{$DB_CONFIG["database"]}': ") { |q| q.echo = false}
13
- if !$ROOT_PW || $ROOT_PW.empty?
13
+ if !$ROOT_PW || $ROOT_PW.nil?
14
14
  puts "error reading password"
15
15
  exit 4
16
16
  end
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: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,14 +11,16 @@ authors:
11
11
  - Vojtech Salbaba
12
12
  - David Jones
13
13
  - Dave Woodward
14
+ - Miles Sterrett
15
+ - James Hill
14
16
  autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
- date: 2012-03-04 00:00:00.000000000 Z
19
+ date: 2013-03-16 00:00:00.000000000 Z
18
20
  dependencies:
19
21
  - !ruby/object:Gem::Dependency
20
22
  name: activerecord
21
- requirement: &70328286962440 !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
22
24
  none: false
23
25
  requirements:
24
26
  - - ! '>='
@@ -26,10 +28,15 @@ dependencies:
26
28
  version: '0'
27
29
  type: :runtime
28
30
  prerelease: false
29
- version_requirements: *70328286962440
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
30
37
  - !ruby/object:Gem::Dependency
31
38
  name: assertions-eb
32
- requirement: &70328286961960 !ruby/object:Gem::Requirement
39
+ requirement: !ruby/object:Gem::Requirement
33
40
  none: false
34
41
  requirements:
35
42
  - - ! '>='
@@ -37,10 +44,15 @@ dependencies:
37
44
  version: '0'
38
45
  type: :development
39
46
  prerelease: false
40
- version_requirements: *70328286961960
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: rake
43
- requirement: &70328286961480 !ruby/object:Gem::Requirement
55
+ requirement: !ruby/object:Gem::Requirement
44
56
  none: false
45
57
  requirements:
46
58
  - - ! '>='
@@ -48,10 +60,15 @@ dependencies:
48
60
  version: '0'
49
61
  type: :development
50
62
  prerelease: false
51
- version_requirements: *70328286961480
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
52
69
  - !ruby/object:Gem::Dependency
53
70
  name: mysql2
54
- requirement: &70328286961020 !ruby/object:Gem::Requirement
71
+ requirement: !ruby/object:Gem::Requirement
55
72
  none: false
56
73
  requirements:
57
74
  - - ! '>='
@@ -59,10 +76,15 @@ dependencies:
59
76
  version: '0'
60
77
  type: :development
61
78
  prerelease: false
62
- version_requirements: *70328286961020
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
63
85
  - !ruby/object:Gem::Dependency
64
86
  name: highline
65
- requirement: &70328286960580 !ruby/object:Gem::Requirement
87
+ requirement: !ruby/object:Gem::Requirement
66
88
  none: false
67
89
  requirements:
68
90
  - - ! '>='
@@ -70,10 +92,15 @@ dependencies:
70
92
  version: '0'
71
93
  type: :development
72
94
  prerelease: false
73
- version_requirements: *70328286960580
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
74
101
  - !ruby/object:Gem::Dependency
75
102
  name: rr
76
- requirement: &70328286960080 !ruby/object:Gem::Requirement
103
+ requirement: !ruby/object:Gem::Requirement
77
104
  none: false
78
105
  requirements:
79
106
  - - ! '>='
@@ -81,10 +108,15 @@ dependencies:
81
108
  version: '0'
82
109
  type: :development
83
110
  prerelease: false
84
- version_requirements: *70328286960080
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
85
117
  - !ruby/object:Gem::Dependency
86
118
  name: database_cleaner
87
- requirement: &70328286959640 !ruby/object:Gem::Requirement
119
+ requirement: !ruby/object:Gem::Requirement
88
120
  none: false
89
121
  requirements:
90
122
  - - ! '>='
@@ -92,7 +124,12 @@ dependencies:
92
124
  version: '0'
93
125
  type: :development
94
126
  prerelease: false
95
- version_requirements: *70328286959640
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
96
133
  description: ! '*Atomic archiving/unarchiving for ActiveRecord-based apps*
97
134
 
98
135
 
@@ -178,21 +215,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
215
  - - ! '>='
179
216
  - !ruby/object:Gem::Version
180
217
  version: '0'
181
- segments:
182
- - 0
183
- hash: -3492758248112477933
184
218
  required_rubygems_version: !ruby/object:Gem::Requirement
185
219
  none: false
186
220
  requirements:
187
221
  - - ! '>='
188
222
  - !ruby/object:Gem::Version
189
223
  version: '0'
190
- segments:
191
- - 0
192
- hash: -3492758248112477933
193
224
  requirements: []
194
225
  rubyforge_project:
195
- rubygems_version: 1.8.16
226
+ rubygems_version: 1.8.23
196
227
  signing_key:
197
228
  specification_version: 3
198
229
  summary: Atomic archiving/unarchiving for ActiveRecord-based apps