paper_trail 9.2.0 → 10.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/paper_trail/install/USAGE +3 -0
- data/lib/generators/paper_trail/install/install_generator.rb +72 -0
- data/lib/generators/paper_trail/{templates → install/templates}/add_object_changes_to_versions.rb.erb +0 -0
- data/lib/generators/paper_trail/{templates → install/templates}/create_versions.rb.erb +1 -1
- data/lib/generators/paper_trail/migration_generator.rb +37 -0
- data/lib/generators/paper_trail/update_item_subtype/USAGE +4 -0
- data/lib/generators/paper_trail/update_item_subtype/templates/update_versions_for_item_subtype.rb.erb +85 -0
- data/lib/generators/paper_trail/update_item_subtype/update_item_subtype_generator.rb +17 -0
- data/lib/paper_trail.rb +0 -91
- data/lib/paper_trail/config.rb +28 -2
- data/lib/paper_trail/events/base.rb +298 -0
- data/lib/paper_trail/events/create.rb +31 -0
- data/lib/paper_trail/events/destroy.rb +34 -0
- data/lib/paper_trail/events/update.rb +59 -0
- data/lib/paper_trail/has_paper_trail.rb +0 -2
- data/lib/paper_trail/model_config.rb +12 -42
- data/lib/paper_trail/queries/versions/where_object.rb +4 -1
- data/lib/paper_trail/queries/versions/where_object_changes.rb +1 -1
- data/lib/paper_trail/record_trail.rb +65 -412
- data/lib/paper_trail/version_concern.rb +59 -34
- data/lib/paper_trail/version_number.rb +2 -2
- metadata +38 -29
- data/lib/generators/paper_trail/USAGE +0 -2
@@ -45,39 +45,6 @@ module PaperTrail
|
|
45
45
|
where "event <> ?", "create"
|
46
46
|
end
|
47
47
|
|
48
|
-
# Returns versions after `obj`.
|
49
|
-
#
|
50
|
-
# @param obj - a `Version` or a timestamp
|
51
|
-
# @param timestamp_arg - boolean - When true, `obj` is a timestamp.
|
52
|
-
# Default: false.
|
53
|
-
# @return `ActiveRecord::Relation`
|
54
|
-
# @api public
|
55
|
-
def subsequent(obj, timestamp_arg = false)
|
56
|
-
if timestamp_arg != true && primary_key_is_int?
|
57
|
-
return where(arel_table[primary_key].gt(obj.id)).order(arel_table[primary_key].asc)
|
58
|
-
end
|
59
|
-
|
60
|
-
obj = obj.send(:created_at) if obj.is_a?(self)
|
61
|
-
where(arel_table[:created_at].gt(obj)).order(timestamp_sort_order)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Returns versions before `obj`.
|
65
|
-
#
|
66
|
-
# @param obj - a `Version` or a timestamp
|
67
|
-
# @param timestamp_arg - boolean - When true, `obj` is a timestamp.
|
68
|
-
# Default: false.
|
69
|
-
# @return `ActiveRecord::Relation`
|
70
|
-
# @api public
|
71
|
-
def preceding(obj, timestamp_arg = false)
|
72
|
-
if timestamp_arg != true && primary_key_is_int?
|
73
|
-
return where(arel_table[primary_key].lt(obj.id)).order(arel_table[primary_key].desc)
|
74
|
-
end
|
75
|
-
|
76
|
-
obj = obj.send(:created_at) if obj.is_a?(self)
|
77
|
-
where(arel_table[:created_at].lt(obj)).
|
78
|
-
order(timestamp_sort_order("desc"))
|
79
|
-
end
|
80
|
-
|
81
48
|
def between(start_time, end_time)
|
82
49
|
where(
|
83
50
|
arel_table[:created_at].gt(start_time).
|
@@ -166,6 +133,61 @@ module PaperTrail
|
|
166
133
|
def object_changes_col_is_json?
|
167
134
|
%i[json jsonb].include?(columns_hash["object_changes"].try(:type))
|
168
135
|
end
|
136
|
+
|
137
|
+
# Returns versions before `obj`.
|
138
|
+
#
|
139
|
+
# @param obj - a `Version` or a timestamp
|
140
|
+
# @param timestamp_arg - boolean - When true, `obj` is a timestamp.
|
141
|
+
# Default: false.
|
142
|
+
# @return `ActiveRecord::Relation`
|
143
|
+
# @api public
|
144
|
+
def preceding(obj, timestamp_arg = false)
|
145
|
+
if timestamp_arg != true && primary_key_is_int?
|
146
|
+
preceding_by_id(obj)
|
147
|
+
else
|
148
|
+
preceding_by_timestamp(obj)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns versions after `obj`.
|
153
|
+
#
|
154
|
+
# @param obj - a `Version` or a timestamp
|
155
|
+
# @param timestamp_arg - boolean - When true, `obj` is a timestamp.
|
156
|
+
# Default: false.
|
157
|
+
# @return `ActiveRecord::Relation`
|
158
|
+
# @api public
|
159
|
+
def subsequent(obj, timestamp_arg = false)
|
160
|
+
if timestamp_arg != true && primary_key_is_int?
|
161
|
+
subsequent_by_id(obj)
|
162
|
+
else
|
163
|
+
subsequent_by_timestamp(obj)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
private
|
168
|
+
|
169
|
+
# @api private
|
170
|
+
def preceding_by_id(obj)
|
171
|
+
where(arel_table[primary_key].lt(obj.id)).order(arel_table[primary_key].desc)
|
172
|
+
end
|
173
|
+
|
174
|
+
# @api private
|
175
|
+
def preceding_by_timestamp(obj)
|
176
|
+
obj = obj.send(:created_at) if obj.is_a?(self)
|
177
|
+
where(arel_table[:created_at].lt(obj)).
|
178
|
+
order(timestamp_sort_order("desc"))
|
179
|
+
end
|
180
|
+
|
181
|
+
# @api private
|
182
|
+
def subsequent_by_id(version)
|
183
|
+
where(arel_table[primary_key].gt(version.id)).order(arel_table[primary_key].asc)
|
184
|
+
end
|
185
|
+
|
186
|
+
# @api private
|
187
|
+
def subsequent_by_timestamp(obj)
|
188
|
+
obj = obj.send(:created_at) if obj.is_a?(self)
|
189
|
+
where(arel_table[:created_at].gt(obj)).order(timestamp_sort_order)
|
190
|
+
end
|
169
191
|
end
|
170
192
|
|
171
193
|
# @api private
|
@@ -205,6 +227,9 @@ module PaperTrail
|
|
205
227
|
# - `:preserve` - Attributes undefined in version record are not modified.
|
206
228
|
#
|
207
229
|
def reify(options = {})
|
230
|
+
unless self.class.column_names.include? "object"
|
231
|
+
raise "reify can't be called without an object column"
|
232
|
+
end
|
208
233
|
return nil if object.nil?
|
209
234
|
::PaperTrail::Reifier.reify(self, options)
|
210
235
|
end
|
@@ -256,7 +281,7 @@ module PaperTrail
|
|
256
281
|
|
257
282
|
# @api private
|
258
283
|
def load_changeset
|
259
|
-
if PaperTrail.config.object_changes_adapter
|
284
|
+
if PaperTrail.config.object_changes_adapter&.respond_to?(:load_changeset)
|
260
285
|
return PaperTrail.config.object_changes_adapter.load_changeset(self)
|
261
286
|
end
|
262
287
|
|
@@ -7,8 +7,8 @@ module PaperTrail
|
|
7
7
|
# because of this confusion, but it's not worth the breaking change.
|
8
8
|
# People are encouraged to use `PaperTrail.gem_version` instead.
|
9
9
|
module VERSION
|
10
|
-
MAJOR =
|
11
|
-
MINOR =
|
10
|
+
MAJOR = 10
|
11
|
+
MINOR = 0
|
12
12
|
TINY = 0
|
13
13
|
|
14
14
|
# Set PRE to nil unless it's a pre-release (beta, rc, etc.)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Stewart
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-09-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -32,20 +32,6 @@ dependencies:
|
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '5.3'
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: paper_trail-association_tracking
|
37
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "<"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '2'
|
42
|
-
type: :runtime
|
43
|
-
prerelease: false
|
44
|
-
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "<"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '2'
|
49
35
|
- !ruby/object:Gem::Dependency
|
50
36
|
name: request_store
|
51
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,28 +108,42 @@ dependencies:
|
|
122
108
|
requirements:
|
123
109
|
- - "~>"
|
124
110
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
111
|
+
version: 0.5.2
|
126
112
|
type: :development
|
127
113
|
prerelease: false
|
128
114
|
version_requirements: !ruby/object:Gem::Requirement
|
129
115
|
requirements:
|
130
116
|
- - "~>"
|
131
117
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.
|
118
|
+
version: 0.5.2
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: paper_trail-association_tracking
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "<"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "<"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '2'
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: pg
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: '1.0'
|
140
140
|
type: :development
|
141
141
|
prerelease: false
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: '1.0'
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: rake
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,42 +164,42 @@ dependencies:
|
|
164
164
|
requirements:
|
165
165
|
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
|
-
version: 3.
|
167
|
+
version: '3.8'
|
168
168
|
type: :development
|
169
169
|
prerelease: false
|
170
170
|
version_requirements: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
172
|
- - "~>"
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: 3.
|
174
|
+
version: '3.8'
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
176
|
name: rubocop
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
179
|
- - "~>"
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version: 0.
|
181
|
+
version: 0.58.2
|
182
182
|
type: :development
|
183
183
|
prerelease: false
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
186
|
- - "~>"
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version: 0.
|
188
|
+
version: 0.58.2
|
189
189
|
- !ruby/object:Gem::Dependency
|
190
190
|
name: rubocop-rspec
|
191
191
|
requirement: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
193
|
- - "~>"
|
194
194
|
- !ruby/object:Gem::Version
|
195
|
-
version: 1.
|
195
|
+
version: 1.28.0
|
196
196
|
type: :development
|
197
197
|
prerelease: false
|
198
198
|
version_requirements: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
200
|
- - "~>"
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: 1.
|
202
|
+
version: 1.28.0
|
203
203
|
- !ruby/object:Gem::Dependency
|
204
204
|
name: sqlite3
|
205
205
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,10 +223,15 @@ executables: []
|
|
223
223
|
extensions: []
|
224
224
|
extra_rdoc_files: []
|
225
225
|
files:
|
226
|
-
- lib/generators/paper_trail/USAGE
|
226
|
+
- lib/generators/paper_trail/install/USAGE
|
227
|
+
- lib/generators/paper_trail/install/install_generator.rb
|
228
|
+
- lib/generators/paper_trail/install/templates/add_object_changes_to_versions.rb.erb
|
229
|
+
- lib/generators/paper_trail/install/templates/create_versions.rb.erb
|
227
230
|
- lib/generators/paper_trail/install_generator.rb
|
228
|
-
- lib/generators/paper_trail/
|
229
|
-
- lib/generators/paper_trail/
|
231
|
+
- lib/generators/paper_trail/migration_generator.rb
|
232
|
+
- lib/generators/paper_trail/update_item_subtype/USAGE
|
233
|
+
- lib/generators/paper_trail/update_item_subtype/templates/update_versions_for_item_subtype.rb.erb
|
234
|
+
- lib/generators/paper_trail/update_item_subtype/update_item_subtype_generator.rb
|
230
235
|
- lib/paper_trail.rb
|
231
236
|
- lib/paper_trail/attribute_serializers/README.md
|
232
237
|
- lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb
|
@@ -235,6 +240,10 @@ files:
|
|
235
240
|
- lib/paper_trail/attribute_serializers/object_changes_attribute.rb
|
236
241
|
- lib/paper_trail/cleaner.rb
|
237
242
|
- lib/paper_trail/config.rb
|
243
|
+
- lib/paper_trail/events/base.rb
|
244
|
+
- lib/paper_trail/events/create.rb
|
245
|
+
- lib/paper_trail/events/destroy.rb
|
246
|
+
- lib/paper_trail/events/update.rb
|
238
247
|
- lib/paper_trail/frameworks/active_record.rb
|
239
248
|
- lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb
|
240
249
|
- lib/paper_trail/frameworks/cucumber.rb
|