paper_trail-association_tracking 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/LICENSE +20 -0
- data/README.md +252 -0
- data/Rakefile +61 -0
- data/lib/generators/paper_trail_association_tracking/install_generator.rb +64 -0
- data/lib/generators/paper_trail_association_tracking/templates/add_transaction_id_column_to_versions.rb.erb +13 -0
- data/lib/generators/paper_trail_association_tracking/templates/create_version_associations.rb.erb +22 -0
- data/lib/paper_trail-association_tracking.rb +68 -0
- data/lib/paper_trail_association_tracking/config.rb +26 -0
- data/lib/paper_trail_association_tracking/frameworks/active_record.rb +5 -0
- data/lib/paper_trail_association_tracking/frameworks/active_record/models/paper_trail/version_association.rb +13 -0
- data/lib/paper_trail_association_tracking/frameworks/rails.rb +3 -0
- data/lib/paper_trail_association_tracking/frameworks/rails/engine.rb +10 -0
- data/lib/paper_trail_association_tracking/frameworks/rspec.rb +20 -0
- data/lib/paper_trail_association_tracking/model_config.rb +76 -0
- data/lib/paper_trail_association_tracking/paper_trail.rb +38 -0
- data/lib/paper_trail_association_tracking/record_trail.rb +200 -0
- data/lib/paper_trail_association_tracking/reifier.rb +125 -0
- data/lib/paper_trail_association_tracking/reifiers/belongs_to.rb +50 -0
- data/lib/paper_trail_association_tracking/reifiers/has_and_belongs_to_many.rb +52 -0
- data/lib/paper_trail_association_tracking/reifiers/has_many.rb +112 -0
- data/lib/paper_trail_association_tracking/reifiers/has_many_through.rb +92 -0
- data/lib/paper_trail_association_tracking/reifiers/has_one.rb +135 -0
- data/lib/paper_trail_association_tracking/request.rb +32 -0
- data/lib/paper_trail_association_tracking/version.rb +5 -0
- data/lib/paper_trail_association_tracking/version_association_concern.rb +13 -0
- data/lib/paper_trail_association_tracking/version_concern.rb +37 -0
- metadata +260 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaperTrailAssociationTracking
|
4
|
+
module Request
|
5
|
+
module ClassMethods
|
6
|
+
# @api private
|
7
|
+
def clear_transaction_id
|
8
|
+
self.transaction_id = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
# @api private
|
12
|
+
def transaction_id
|
13
|
+
store[:transaction_id]
|
14
|
+
end
|
15
|
+
|
16
|
+
# @api private
|
17
|
+
def transaction_id=(id)
|
18
|
+
store[:transaction_id] = id
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def validate_public_options(options)
|
24
|
+
if options.keys.include?(:transaction_id)
|
25
|
+
raise ::PaperTrail::Request::InvalidOption, "Cannot set private option: transaction_id"
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaperTrailAssociationTracking
|
4
|
+
# Functionality for `PaperTrail::VersionAssociation`. Exists in a module
|
5
|
+
# for the same reasons outlined in version_concern.rb.
|
6
|
+
module VersionAssociationConcern
|
7
|
+
extend ::ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
belongs_to :version
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaperTrailAssociationTracking
|
4
|
+
# Originally, PaperTrail did not provide this module, and all of this
|
5
|
+
# functionality was in `PaperTrail::Version`. That model still exists (and is
|
6
|
+
# used by most apps) but by moving the functionality to this module, people
|
7
|
+
# can include this concern instead of sub-classing the `Version` model.
|
8
|
+
module VersionConcern
|
9
|
+
extend ::ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
# Since the test suite has test coverage for this, we want to declare the association when the test suite is running.
|
13
|
+
# This makes it pass when DB is not initialized prior to test runs such as when we run on Travis CI
|
14
|
+
# Ex. (there won't be a db in `spec/dummy_app/db/`).
|
15
|
+
if ::PaperTrail.config.track_associations?
|
16
|
+
has_many :version_associations, dependent: :destroy
|
17
|
+
end
|
18
|
+
|
19
|
+
scope(:within_transaction, ->(id) { where transaction_id: id })
|
20
|
+
end
|
21
|
+
|
22
|
+
# Restore the item from this version.
|
23
|
+
#
|
24
|
+
# In addition to the options provided by PaperTrail core. This Plugin provides the following Options:
|
25
|
+
#
|
26
|
+
# - :has_one
|
27
|
+
# - `true` - Also reify has_one associations.
|
28
|
+
# - `false - Default.
|
29
|
+
# - :has_many
|
30
|
+
# - `true` - Also reify has_many and has_many :through associations.
|
31
|
+
# - `false` - Default.
|
32
|
+
#
|
33
|
+
#def reify(options = {})
|
34
|
+
# super
|
35
|
+
#end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paper_trail-association_tracking
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Weston Ganger
|
8
|
+
- Jared Beck
|
9
|
+
- Ben Atkins
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2018-06-03 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: appraisal
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.2'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '2.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: byebug
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '9.1'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '9.1'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: ffaker
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.7'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.7'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: generator_spec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.9.4
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.9.4
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: mysql2
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.4.10
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.4.10
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: pg
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.21.0
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.21.0
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rack-test
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 0.6.3
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0.9'
|
109
|
+
type: :development
|
110
|
+
prerelease: false
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.6.3
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.9'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rake
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '12.3'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '12.3'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: rspec-rails
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 3.7.2
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 3.7.2
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: rubocop
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 0.51.0
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.51.0
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: rubocop-rspec
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 1.19.0
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: 1.19.0
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: sqlite3
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '1.3'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '1.3'
|
189
|
+
- !ruby/object:Gem::Dependency
|
190
|
+
name: timecop
|
191
|
+
requirement: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: 0.9.1
|
196
|
+
type: :development
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - "~>"
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 0.9.1
|
203
|
+
description: Plugin for the PaperTrail gem to track and reify associations
|
204
|
+
email: weston@westonganger.com
|
205
|
+
executables: []
|
206
|
+
extensions: []
|
207
|
+
extra_rdoc_files: []
|
208
|
+
files:
|
209
|
+
- CHANGELOG.md
|
210
|
+
- LICENSE
|
211
|
+
- README.md
|
212
|
+
- Rakefile
|
213
|
+
- lib/generators/paper_trail_association_tracking/install_generator.rb
|
214
|
+
- lib/generators/paper_trail_association_tracking/templates/add_transaction_id_column_to_versions.rb.erb
|
215
|
+
- lib/generators/paper_trail_association_tracking/templates/create_version_associations.rb.erb
|
216
|
+
- lib/paper_trail-association_tracking.rb
|
217
|
+
- lib/paper_trail_association_tracking/config.rb
|
218
|
+
- lib/paper_trail_association_tracking/frameworks/active_record.rb
|
219
|
+
- lib/paper_trail_association_tracking/frameworks/active_record/models/paper_trail/version_association.rb
|
220
|
+
- lib/paper_trail_association_tracking/frameworks/rails.rb
|
221
|
+
- lib/paper_trail_association_tracking/frameworks/rails/engine.rb
|
222
|
+
- lib/paper_trail_association_tracking/frameworks/rspec.rb
|
223
|
+
- lib/paper_trail_association_tracking/model_config.rb
|
224
|
+
- lib/paper_trail_association_tracking/paper_trail.rb
|
225
|
+
- lib/paper_trail_association_tracking/record_trail.rb
|
226
|
+
- lib/paper_trail_association_tracking/reifier.rb
|
227
|
+
- lib/paper_trail_association_tracking/reifiers/belongs_to.rb
|
228
|
+
- lib/paper_trail_association_tracking/reifiers/has_and_belongs_to_many.rb
|
229
|
+
- lib/paper_trail_association_tracking/reifiers/has_many.rb
|
230
|
+
- lib/paper_trail_association_tracking/reifiers/has_many_through.rb
|
231
|
+
- lib/paper_trail_association_tracking/reifiers/has_one.rb
|
232
|
+
- lib/paper_trail_association_tracking/request.rb
|
233
|
+
- lib/paper_trail_association_tracking/version.rb
|
234
|
+
- lib/paper_trail_association_tracking/version_association_concern.rb
|
235
|
+
- lib/paper_trail_association_tracking/version_concern.rb
|
236
|
+
homepage: https://github.com/westonganger/paper_trail-association_tracking
|
237
|
+
licenses:
|
238
|
+
- MIT
|
239
|
+
metadata: {}
|
240
|
+
post_install_message:
|
241
|
+
rdoc_options: []
|
242
|
+
require_paths:
|
243
|
+
- lib
|
244
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
245
|
+
requirements:
|
246
|
+
- - ">="
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: 2.3.0
|
249
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: 1.3.6
|
254
|
+
requirements: []
|
255
|
+
rubyforge_project:
|
256
|
+
rubygems_version: 2.7.6
|
257
|
+
signing_key:
|
258
|
+
specification_version: 4
|
259
|
+
summary: Plugin for the PaperTrail gem to track and reify associations
|
260
|
+
test_files: []
|