freerange_acts_as_versioned 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,15 +10,12 @@ Install
10
10
 
11
11
  <3 GitHub
12
12
 
13
- * http://github.com/technoweenie/acts_as_versioned
13
+ * http://github.com/abdulrauf/acts_as_versioned
14
14
 
15
15
  Gemcutter FTW
16
16
 
17
- * http://gemcutter.org/gems/acts_as_versioned
17
+ * http://gemcutter.org/gems/freerange_acts_as_versioned
18
18
 
19
- Subversion
20
19
 
21
- * http://svn.github.com/technoweenie/acts_as_versioned.git
22
20
 
23
- Special thanks to Dreamer on ##rubyonrails for help in early testing. His ServerSideWiki (http://serversidewiki.com)
24
- was the first project to use acts_as_versioned <em>in the wild</em>.
21
+ Add simple versioning to ActiveRecord models. This version supports rails ~>3.1.1. Also it have support for autosave. It introduces new method auto_save_version which keeps 1 autosave version for an object.
@@ -13,13 +13,13 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'freerange_acts_as_versioned'
16
- s.version = '0.8.0'
17
- s.date = '2012-04-23'
16
+ s.version = '0.8.1'
17
+ s.date = '2012-04-24'
18
18
  s.rubyforge_project = 'freerange_acts_as_versioned'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
21
21
  ## as you like.
22
- s.summary = "Add simple versioning to ActiveRecord models. This version supports rails 3.1.1"
22
+ s.summary = "Add simple versioning to ActiveRecord models. This version supports rails 3.1.1. Also it have support for autosave. It introduces new method auto_save_version which keeps 1 autosave version for an object."
23
23
  s.description = "Add simple versioning to ActiveRecord models. rails 3.1.1"
24
24
 
25
25
  ## List the primary authors. If there are a bunch of authors, it's probably
@@ -67,7 +67,7 @@ module ActiveRecord #:nodoc:
67
67
  #
68
68
  # See ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned for configuration options
69
69
  module Versioned
70
- VERSION = "0.6.0"
70
+ VERSION = "0.8.1"
71
71
  CALLBACKS = [:set_new_version, :save_version, :save_version?]
72
72
 
73
73
  # == Configuration options
@@ -290,7 +290,9 @@ module ActiveRecord #:nodoc:
290
290
  rev.send("#{self.class.version_column}=", send(self.class.version_column))
291
291
  rev.send("#{self.class.versioned_foreign_key}=", id)
292
292
  rev.send("autosave=", true)
293
- rev.save
293
+ saving_status = rev.save
294
+ clear_old_auto_save_versions
295
+ saving_status
294
296
  end
295
297
  end
296
298
 
@@ -303,6 +305,15 @@ module ActiveRecord #:nodoc:
303
305
  self.class.versioned_class.delete_all ["#{self.class.version_column} <= ? and #{self.class.versioned_foreign_key} = ?", excess_baggage, id]
304
306
  end
305
307
  end
308
+
309
+ # Clears old revisions if a limit is set with the :limit option in <tt>acts_as_versioned</tt>.
310
+ # Override this method to set your own criteria for clearing old versions.
311
+ def clear_old_auto_save_versions
312
+ excess_baggage = self.class.versioned_class.where(["autosave = ? and #{self.class.versioned_foreign_key} = ?", true,id]).order("updated_at desc").all
313
+ if excess_baggage.length > 1
314
+ excess_baggage.last.destroy
315
+ end
316
+ end
306
317
 
307
318
  # Reverts a model to a given version. Takes either a version number or an instance of the versioned model
308
319
  def revert_to(version)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freerange_acts_as_versioned
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Abdul Rauf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-23 00:00:00 +09:30
18
+ date: 2012-04-24 00:00:00 +09:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,6 @@ rubyforge_project: freerange_acts_as_versioned
119
119
  rubygems_version: 1.3.7
120
120
  signing_key:
121
121
  specification_version: 2
122
- summary: Add simple versioning to ActiveRecord models. This version supports rails 3.1.1
122
+ summary: Add simple versioning to ActiveRecord models. This version supports rails 3.1.1. Also it have support for autosave. It introduces new method auto_save_version which keeps 1 autosave version for an object.
123
123
  test_files: []
124
124