dirty_history 0.3.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dirty_history.gemspec +11 -11
- data/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/lib/dirty_history/dirty_history_mixin.rb +4 -2
- data/lib/dirty_history/dirty_history_mixin.rb +2 -0
- data/lib/dirty_history/dirty_history_record.rb +7 -1
- data/lib/generators/dirty_history/migration/templates/active_record/migration.rb +2 -0
- metadata +16 -16
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.2
|
data/dirty_history.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
7
|
+
s.name = "dirty_history"
|
8
|
+
s.version = "0.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Gavin Todes"]
|
12
|
+
s.date = "2011-12-02"
|
13
|
+
s.description = "Dirty History is a simple gem that allows you to keep track of changes to specific fields in your Rails models using the ActiveRecord::Dirty module."
|
14
|
+
s.email = "gavin.todes@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.rdoc"
|
@@ -3690,11 +3690,11 @@ Gem::Specification.new do |s|
|
|
3690
3690
|
"test/helper.rb",
|
3691
3691
|
"test/test_dirty_history.rb"
|
3692
3692
|
]
|
3693
|
-
s.homepage =
|
3694
|
-
s.licenses = [
|
3695
|
-
s.require_paths = [
|
3696
|
-
s.rubygems_version =
|
3697
|
-
s.summary =
|
3693
|
+
s.homepage = "http://github.com/GAV1N/dirty_history"
|
3694
|
+
s.licenses = ["MIT"]
|
3695
|
+
s.require_paths = ["lib"]
|
3696
|
+
s.rubygems_version = "1.8.10"
|
3697
|
+
s.summary = "Easily keep track of changes to specific model fields."
|
3698
3698
|
|
3699
3699
|
if s.respond_to? :specification_version then
|
3700
3700
|
s.specification_version = 3
|
@@ -101,8 +101,10 @@ module DirtyHistory
|
|
101
101
|
:old_value => old_value,
|
102
102
|
:new_value => new_value,
|
103
103
|
:creator => creator
|
104
|
-
}
|
105
|
-
|
104
|
+
}
|
105
|
+
|
106
|
+
dhr_attributes[:revised_created_at] = options[:revised_created_at] if options[:revised_created_at]
|
107
|
+
|
106
108
|
self.dirty_history_records << DirtyHistoryRecord.new(dhr_attributes)
|
107
109
|
end
|
108
110
|
|
@@ -86,6 +86,8 @@ module DirtyHistory
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def save_dirty_history
|
89
|
+
return true unless self.dirty_history_changes.present?
|
90
|
+
|
89
91
|
self.dirty_history_changes.each do |column_name,vals|
|
90
92
|
add_dirty_history_record column_name, vals[0], vals[1], :creator => self.creator_for_dirty_history
|
91
93
|
end
|
@@ -7,6 +7,7 @@ class DirtyHistoryRecord < ActiveRecord::Base
|
|
7
7
|
|
8
8
|
scope :created_by, lambda { |creator| where(:creator_id => creator.id, :creator_type => creator.class.name) }
|
9
9
|
scope :for_object_type, lambda { |object_type| where(:object_type => object_type.to_s.classify) }
|
10
|
+
scope :for_attribute, lambda { |attribute| where(:column_name => attribute.to_s) }
|
10
11
|
|
11
12
|
acts_as_paranoid
|
12
13
|
|
@@ -19,7 +20,12 @@ class DirtyHistoryRecord < ActiveRecord::Base
|
|
19
20
|
instance_variable_set "@#{attribute}", val
|
20
21
|
end
|
21
22
|
end
|
22
|
-
|
23
|
+
|
24
|
+
def action_timestamp
|
25
|
+
# use revised_created_at field to update the timestamp for the dirty history action while retaining data integrity
|
26
|
+
self[:revised_created_at] || self[:created_at]
|
27
|
+
end
|
28
|
+
|
23
29
|
private
|
24
30
|
|
25
31
|
def val_to_col_type attribute
|
@@ -9,6 +9,8 @@ class CreateDirtyHistoryRecords < ActiveRecord::Migration
|
|
9
9
|
t.text :new_value
|
10
10
|
|
11
11
|
t.datetime :created_at
|
12
|
+
t.datetime :revised_created_at
|
13
|
+
t.datetime :updated_at
|
12
14
|
t.datetime :deleted_at
|
13
15
|
end
|
14
16
|
add_index :dirty_history_records, [:creator_id, :creator_type]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dirty_history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails3_acts_as_paranoid
|
16
|
-
requirement: &
|
16
|
+
requirement: &2163251840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2163251840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &2163251200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2163251200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2163250380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2163250380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2163249540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2163249540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &2163248720 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2163248720
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rails3_acts_as_paranoid
|
71
|
-
requirement: &
|
71
|
+
requirement: &2163247920 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2163247920
|
80
80
|
description: Dirty History is a simple gem that allows you to keep track of changes
|
81
81
|
to specific fields in your Rails models using the ActiveRecord::Dirty module.
|
82
82
|
email: gavin.todes@gmail.com
|
@@ -3773,7 +3773,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
3773
3773
|
version: '0'
|
3774
3774
|
segments:
|
3775
3775
|
- 0
|
3776
|
-
hash:
|
3776
|
+
hash: 1824357690013912411
|
3777
3777
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
3778
3778
|
none: false
|
3779
3779
|
requirements:
|
@@ -3782,7 +3782,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
3782
3782
|
version: '0'
|
3783
3783
|
requirements: []
|
3784
3784
|
rubyforge_project:
|
3785
|
-
rubygems_version: 1.8.
|
3785
|
+
rubygems_version: 1.8.10
|
3786
3786
|
signing_key:
|
3787
3787
|
specification_version: 3
|
3788
3788
|
summary: Easily keep track of changes to specific model fields.
|