laserlemon-vestal_versions 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -3,6 +3,7 @@ generators/vestal_versions_migration/vestal_versions_migration_generator.rb
3
3
  init.rb
4
4
  lib/version.rb
5
5
  lib/vestal_versions.rb
6
+ Manifest
6
7
  MIT-LICENSE
7
8
  Rakefile
8
9
  README.rdoc
@@ -10,4 +11,4 @@ tasks/vestal_versions_tasks.rake
10
11
  test/test_helper.rb
11
12
  test/vestal_versions_test.rb
12
13
  VERSION.yml
13
- Manifest
14
+ vestal_versions.gemspec
data/README.rdoc CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Finally, DRY ActiveRecord versioning!
4
4
 
5
- technoweenie[http://github.com/technoweenie]'s <tt>acts_as_versioned</tt>[http://github.com/technoweenie/acts_as_versioned] was a great start, but it failed to keep up with ActiveRecord's introduction of dirty objects in version 2.1. Additionally, each versioned model needs its own versions table that duplicates most of the original table's columns. The versions table is then populated with records that often duplicate most of the original record's attributes. All in all, not very DRY at all.
5
+ <tt>acts_as_versioned</tt>[http://github.com/technoweenie/acts_as_versioned] by technoweenie[http://github.com/technoweenie] was a great start, but it failed to keep up with ActiveRecord's introduction of dirty objects in version 2.1. Additionally, each versioned model needs its own versions table that duplicates most of the original table's columns. The versions table is then populated with records that often duplicate most of the original record's attributes. All in all, not very DRY.
6
6
 
7
7
  <tt>simply_versioned</tt>[http://github.com/mmower/simply_versioned] by mmower[http://github.com/mmower] started to move in the right direction by removing a great deal of the duplication of acts_as_versioned. It requires only one versions table and no changes whatsoever to existing models. Its versions table stores all of the model attributes as a YAML hash in a single text column. But we could be DRYer!
8
8
 
9
9
  <tt>vestal_versions</tt> keeps in the spirit of consolidating to one versions table, polymorphically associated with its parent models. But it goes one step further by storing a serialized hash of only the models' changes. Think modern version control systems. By traversing the record of changes, the models can be reverted to any point in time.
10
10
 
11
- And that's just what <tt>vestal_versions</tt> does. Not only can a model be reverted to a previous version number but it can be reverted to a date or time!
11
+ And that's just what <tt>vestal_versions</tt> does. Not only can a model be reverted to a previous version number but also to a date or time!
12
12
 
13
13
  == Installation
14
14
 
@@ -29,7 +29,7 @@ Next, generate and run the first and last versioning migration you'll ever need:
29
29
 
30
30
  == Example
31
31
 
32
- To version an ActiveRecord model, simply add <tt>versioned</tt> to you class like so:
32
+ To version an ActiveRecord model, simply add <tt>versioned</tt> to your class like so:
33
33
 
34
34
  class User < ActiveRecord::Base
35
35
  versioned
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('vestal_versions', '0.2.1') do |g|
5
+ Echoe.new('vestal_versions', '0.2.2') do |g|
6
6
  g.description = %(Keep a DRY history of your ActiveRecord models' changes)
7
7
  g.url = 'http://github.com/laserlemon/vestal_versions'
8
8
  g.author = 'Steve Richert'
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 1
4
+ :patch: 2
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
- class Version < ActiveRecord::Base
1
+ class VestalVersion < ActiveRecord::Base
2
2
 
3
3
  belongs_to :versioned, :polymorphic => true
4
4
 
@@ -10,6 +10,10 @@ class Version < ActiveRecord::Base
10
10
 
11
11
  before_create :set_number
12
12
 
13
+ def version
14
+ number
15
+ end
16
+
13
17
  def <=>(other)
14
18
  number <=> other.number
15
19
  end
@@ -6,7 +6,7 @@ module LaserLemon
6
6
 
7
7
  module ClassMethods
8
8
  def versioned
9
- has_many :versions, :as => :versioned, :order => 'versions.number', :dependent => :destroy, :autosave => true do
9
+ has_many :versions, :as => :versioned, :class_name => 'VestalVersion', :order => 'versions.number', :dependent => :destroy, :autosave => true do
10
10
  def current
11
11
  first(:conditions => {:number => versioned.version})
12
12
  end
@@ -22,7 +22,7 @@ module LaserLemon
22
22
 
23
23
  def between(from_value, to_value)
24
24
  from, to = at(from_value), at(to_value)
25
- return [] unless [from, to].all?{|v| v.is_a?(Version) }
25
+ return [] unless [from, to].all?{|v| v.is_a?(VestalVersion) }
26
26
  all(
27
27
  :conditions => {:number => ([from, to].min.number..[from, to].max.number)},
28
28
  :order => "versions.number #{(from > to) ? 'DESC' : 'ASC'}"
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{vestal_versions}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Steve Richert"]
9
- s.date = %q{2009-06-02}
9
+ s.date = %q{2009-06-10}
10
10
  s.description = %q{Keep a DRY history of your ActiveRecord models' changes}
11
11
  s.email = %q{steve@laserlemon.com}
12
12
  s.extra_rdoc_files = ["lib/version.rb", "lib/vestal_versions.rb", "README.rdoc", "tasks/vestal_versions_tasks.rake"]
13
- s.files = ["generators/vestal_versions_migration/templates/migration.rb", "generators/vestal_versions_migration/vestal_versions_migration_generator.rb", "init.rb", "lib/version.rb", "lib/vestal_versions.rb", "MIT-LICENSE", "Rakefile", "README.rdoc", "tasks/vestal_versions_tasks.rake", "test/test_helper.rb", "test/vestal_versions_test.rb", "VERSION.yml", "Manifest", "vestal_versions.gemspec"]
13
+ s.files = ["generators/vestal_versions_migration/templates/migration.rb", "generators/vestal_versions_migration/vestal_versions_migration_generator.rb", "init.rb", "lib/version.rb", "lib/vestal_versions.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "tasks/vestal_versions_tasks.rake", "test/test_helper.rb", "test/vestal_versions_test.rb", "VERSION.yml", "vestal_versions.gemspec"]
14
14
  s.homepage = %q{http://github.com/laserlemon/vestal_versions}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Vestal_versions", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laserlemon-vestal_versions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Richert
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-02 00:00:00 -07:00
12
+ date: 2009-06-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,6 +30,7 @@ files:
30
30
  - init.rb
31
31
  - lib/version.rb
32
32
  - lib/vestal_versions.rb
33
+ - Manifest
33
34
  - MIT-LICENSE
34
35
  - Rakefile
35
36
  - README.rdoc
@@ -37,7 +38,6 @@ files:
37
38
  - test/test_helper.rb
38
39
  - test/vestal_versions_test.rb
39
40
  - VERSION.yml
40
- - Manifest
41
41
  - vestal_versions.gemspec
42
42
  has_rdoc: false
43
43
  homepage: http://github.com/laserlemon/vestal_versions