historiographer 1.4.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +113 -103
- data/VERSION +1 -1
- data/historiographer.gemspec +22 -37
- data/lib/historiographer/history_migration_mysql.rb +6 -5
- data/lib/historiographer/safe.rb +1 -2
- data/lib/historiographer.rb +8 -4
- data/spec/db/database.yml +3 -4
- data/spec/db/schema.rb +5 -5
- data/spec/examples.txt +29 -21
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3693419549c943f0720d9e2282a6c5b62103dfa51fd206e799f83565fe287a2e
|
4
|
+
data.tar.gz: a534c87ea02111361362f28fc767177c2df0435cec1efcca3adbdbce3c2a127f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2266edb10a93aa6a924a418aba82e59cb198d44ff480ae240e5d88f90b3385d597d0ecbe95e6ce348345a4ba2ca3b903075fdd07807d796dc6619cad4cdfd375
|
7
|
+
data.tar.gz: cc5541d5e4fe6184977cf8564d6deda4d605280d6550c803e99e3b2c3ea99bbd342b72ed129319526e30994ed036e151d7575d712c284d3558a9100baad7ac19
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
ruby "2.6.3"
|
3
3
|
|
4
|
-
gem "activerecord", "~>
|
4
|
+
gem "activerecord", "~> 6"
|
5
5
|
gem "activesupport"
|
6
6
|
gem "rollbar"
|
7
7
|
gem "activerecord-import"
|
@@ -9,7 +9,7 @@ gem "activerecord-import"
|
|
9
9
|
group :development, :test do
|
10
10
|
gem "pg"
|
11
11
|
gem "pry"
|
12
|
-
gem "mysql2", "0.
|
12
|
+
gem "mysql2", "0.5"
|
13
13
|
gem "standalone_migrations"
|
14
14
|
gem "timecop"
|
15
15
|
gem "paranoia"
|
data/Gemfile.lock
CHANGED
@@ -18,54 +18,59 @@ GIT
|
|
18
18
|
GEM
|
19
19
|
remote: https://rubygems.org/
|
20
20
|
specs:
|
21
|
-
actionpack (
|
22
|
-
actionview (=
|
23
|
-
activesupport (=
|
24
|
-
rack (~> 2.0)
|
21
|
+
actionpack (6.1.4.4)
|
22
|
+
actionview (= 6.1.4.4)
|
23
|
+
activesupport (= 6.1.4.4)
|
24
|
+
rack (~> 2.0, >= 2.0.9)
|
25
25
|
rack-test (>= 0.6.3)
|
26
26
|
rails-dom-testing (~> 2.0)
|
27
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
28
|
-
actionview (
|
29
|
-
activesupport (=
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
28
|
+
actionview (6.1.4.4)
|
29
|
+
activesupport (= 6.1.4.4)
|
30
30
|
builder (~> 3.1)
|
31
31
|
erubi (~> 1.4)
|
32
32
|
rails-dom-testing (~> 2.0)
|
33
|
-
rails-html-sanitizer (~> 1.
|
34
|
-
activemodel (
|
35
|
-
activesupport (=
|
36
|
-
activerecord (
|
37
|
-
activemodel (=
|
38
|
-
activesupport (=
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
activesupport (5.2.3)
|
33
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
34
|
+
activemodel (6.1.4.4)
|
35
|
+
activesupport (= 6.1.4.4)
|
36
|
+
activerecord (6.1.4.4)
|
37
|
+
activemodel (= 6.1.4.4)
|
38
|
+
activesupport (= 6.1.4.4)
|
39
|
+
activerecord-import (1.3.0)
|
40
|
+
activerecord (>= 4.2)
|
41
|
+
activesupport (6.1.4.4)
|
43
42
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
|
-
i18n (>=
|
45
|
-
minitest (
|
46
|
-
tzinfo (~>
|
43
|
+
i18n (>= 1.6, < 2)
|
44
|
+
minitest (>= 5.1)
|
45
|
+
tzinfo (~> 2.0)
|
46
|
+
zeitwerk (~> 2.3)
|
47
47
|
addressable (2.4.0)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
builder (3.2.4)
|
49
|
+
coderay (1.1.3)
|
50
|
+
concurrent-ruby (1.1.9)
|
51
|
+
crass (1.0.6)
|
52
|
+
database_cleaner (2.0.1)
|
53
|
+
database_cleaner-active_record (~> 2.0.0)
|
54
|
+
database_cleaner-active_record (2.0.1)
|
55
|
+
activerecord (>= 5.a)
|
56
|
+
database_cleaner-core (~> 2.0.0)
|
57
|
+
database_cleaner-core (2.0.1)
|
54
58
|
descendants_tracker (0.0.4)
|
55
59
|
thread_safe (~> 0.3, >= 0.3.1)
|
56
|
-
diff-lcs (1.
|
57
|
-
docile (1.
|
58
|
-
erubi (1.
|
59
|
-
factory_bot (
|
60
|
-
activesupport (>=
|
61
|
-
factory_bot_rails (
|
62
|
-
factory_bot (~>
|
63
|
-
railties (>=
|
60
|
+
diff-lcs (1.5.0)
|
61
|
+
docile (1.4.0)
|
62
|
+
erubi (1.10.0)
|
63
|
+
factory_bot (6.2.0)
|
64
|
+
activesupport (>= 5.0.0)
|
65
|
+
factory_bot_rails (6.2.0)
|
66
|
+
factory_bot (~> 6.2.0)
|
67
|
+
railties (>= 5.0.0)
|
64
68
|
faraday (0.9.2)
|
65
69
|
multipart-post (>= 1.2, < 3)
|
66
|
-
ffi (1.
|
67
|
-
formatador (
|
68
|
-
git (1.
|
70
|
+
ffi (1.15.5)
|
71
|
+
formatador (1.1.0)
|
72
|
+
git (1.10.2)
|
73
|
+
rchardet (~> 1.8)
|
69
74
|
github_api (0.16.0)
|
70
75
|
addressable (~> 2.4.0)
|
71
76
|
descendants_tracker (~> 0.0.4)
|
@@ -73,13 +78,13 @@ GEM
|
|
73
78
|
hashie (>= 3.4)
|
74
79
|
mime-types (>= 1.16, < 3.0)
|
75
80
|
oauth2 (~> 1.0)
|
76
|
-
guard (2.
|
81
|
+
guard (2.18.0)
|
77
82
|
formatador (>= 0.2.4)
|
78
83
|
listen (>= 2.7, < 4.0)
|
79
84
|
lumberjack (>= 1.0.12, < 2.0)
|
80
85
|
nenv (~> 0.1)
|
81
86
|
notiffany (~> 0.0)
|
82
|
-
pry (>= 0.
|
87
|
+
pry (>= 0.13.0)
|
83
88
|
shellany (~> 0.0)
|
84
89
|
thor (>= 0.18.1)
|
85
90
|
guard-compat (1.2.1)
|
@@ -87,104 +92,109 @@ GEM
|
|
87
92
|
guard (~> 2.1)
|
88
93
|
guard-compat (~> 1.1)
|
89
94
|
rspec (>= 2.99.0, < 4.0)
|
90
|
-
hashie (
|
91
|
-
highline (2.0.
|
92
|
-
i18n (1.
|
95
|
+
hashie (5.0.0)
|
96
|
+
highline (2.0.3)
|
97
|
+
i18n (1.9.1)
|
93
98
|
concurrent-ruby (~> 1.0)
|
94
99
|
json (1.8.6)
|
95
|
-
jwt (2.
|
96
|
-
listen (3.1
|
97
|
-
rb-fsevent (~> 0.
|
98
|
-
rb-inotify (~> 0.9, >= 0.9.
|
99
|
-
|
100
|
-
loofah (2.2.3)
|
100
|
+
jwt (2.3.0)
|
101
|
+
listen (3.7.1)
|
102
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
103
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
104
|
+
loofah (2.13.0)
|
101
105
|
crass (~> 1.0.2)
|
102
106
|
nokogiri (>= 1.5.9)
|
103
|
-
lumberjack (1.
|
104
|
-
method_source (0.
|
107
|
+
lumberjack (1.2.8)
|
108
|
+
method_source (1.0.0)
|
105
109
|
mime-types (2.99.3)
|
106
|
-
mini_portile2 (2.
|
107
|
-
minitest (5.
|
108
|
-
multi_json (1.
|
110
|
+
mini_portile2 (2.7.1)
|
111
|
+
minitest (5.15.0)
|
112
|
+
multi_json (1.15.0)
|
109
113
|
multi_xml (0.6.0)
|
110
114
|
multipart-post (2.1.1)
|
111
|
-
mysql2 (0.
|
115
|
+
mysql2 (0.5.0)
|
112
116
|
nenv (0.3.0)
|
113
|
-
nokogiri (1.
|
114
|
-
mini_portile2 (~> 2.
|
117
|
+
nokogiri (1.13.1)
|
118
|
+
mini_portile2 (~> 2.7.0)
|
119
|
+
racc (~> 1.4)
|
115
120
|
notiffany (0.1.3)
|
116
121
|
nenv (~> 0.1)
|
117
122
|
shellany (~> 0.0)
|
118
|
-
oauth2 (1.4.
|
119
|
-
faraday (>= 0.8, <
|
123
|
+
oauth2 (1.4.7)
|
124
|
+
faraday (>= 0.8, < 2.0)
|
120
125
|
jwt (>= 1.0, < 3.0)
|
121
126
|
multi_json (~> 1.3)
|
122
127
|
multi_xml (~> 0.5)
|
123
128
|
rack (>= 1.2, < 3)
|
124
|
-
paranoia (2.
|
125
|
-
activerecord (>=
|
126
|
-
pg (1.1
|
127
|
-
pry (0.
|
128
|
-
coderay (~> 1.1
|
129
|
-
method_source (~>
|
130
|
-
psych (
|
131
|
-
|
129
|
+
paranoia (2.5.2)
|
130
|
+
activerecord (>= 5.1, < 7.1)
|
131
|
+
pg (1.3.1)
|
132
|
+
pry (0.14.1)
|
133
|
+
coderay (~> 1.1)
|
134
|
+
method_source (~> 1.0)
|
135
|
+
psych (4.0.3)
|
136
|
+
stringio
|
137
|
+
racc (1.6.0)
|
138
|
+
rack (2.2.3)
|
132
139
|
rack-test (1.1.0)
|
133
140
|
rack (>= 1.0, < 3)
|
134
141
|
rails-dom-testing (2.0.3)
|
135
142
|
activesupport (>= 4.2.0)
|
136
143
|
nokogiri (>= 1.6)
|
137
|
-
rails-html-sanitizer (1.2
|
138
|
-
loofah (~> 2.
|
139
|
-
railties (
|
140
|
-
actionpack (=
|
141
|
-
activesupport (=
|
144
|
+
rails-html-sanitizer (1.4.2)
|
145
|
+
loofah (~> 2.3)
|
146
|
+
railties (6.1.4.4)
|
147
|
+
actionpack (= 6.1.4.4)
|
148
|
+
activesupport (= 6.1.4.4)
|
142
149
|
method_source
|
143
|
-
rake (>= 0.
|
144
|
-
thor (
|
145
|
-
rake (
|
146
|
-
rb-fsevent (0.
|
147
|
-
rb-inotify (0.10.
|
150
|
+
rake (>= 0.13)
|
151
|
+
thor (~> 1.0)
|
152
|
+
rake (13.0.6)
|
153
|
+
rb-fsevent (0.11.0)
|
154
|
+
rb-inotify (0.10.1)
|
148
155
|
ffi (~> 1.0)
|
156
|
+
rchardet (1.8.0)
|
149
157
|
rdoc (3.12.2)
|
150
158
|
json (~> 1.4)
|
151
|
-
rollbar (
|
152
|
-
rspec (3.
|
153
|
-
rspec-core (~> 3.
|
154
|
-
rspec-expectations (~> 3.
|
155
|
-
rspec-mocks (~> 3.
|
156
|
-
rspec-core (3.
|
157
|
-
rspec-support (~> 3.
|
158
|
-
rspec-expectations (3.
|
159
|
+
rollbar (3.3.0)
|
160
|
+
rspec (3.10.0)
|
161
|
+
rspec-core (~> 3.10.0)
|
162
|
+
rspec-expectations (~> 3.10.0)
|
163
|
+
rspec-mocks (~> 3.10.0)
|
164
|
+
rspec-core (3.10.2)
|
165
|
+
rspec-support (~> 3.10.0)
|
166
|
+
rspec-expectations (3.10.2)
|
159
167
|
diff-lcs (>= 1.2.0, < 2.0)
|
160
|
-
rspec-support (~> 3.
|
161
|
-
rspec-mocks (3.
|
168
|
+
rspec-support (~> 3.10.0)
|
169
|
+
rspec-mocks (3.10.3)
|
162
170
|
diff-lcs (>= 1.2.0, < 2.0)
|
163
|
-
rspec-support (~> 3.
|
164
|
-
rspec-support (3.
|
165
|
-
ruby_dep (1.5.0)
|
171
|
+
rspec-support (~> 3.10.0)
|
172
|
+
rspec-support (3.10.3)
|
166
173
|
semver2 (3.4.2)
|
167
174
|
shellany (0.0.1)
|
168
|
-
simplecov (0.
|
175
|
+
simplecov (0.21.2)
|
169
176
|
docile (~> 1.1)
|
170
|
-
|
171
|
-
|
172
|
-
simplecov-html (0.
|
173
|
-
|
174
|
-
|
175
|
-
|
177
|
+
simplecov-html (~> 0.11)
|
178
|
+
simplecov_json_formatter (~> 0.1)
|
179
|
+
simplecov-html (0.12.3)
|
180
|
+
simplecov_json_formatter (0.1.3)
|
181
|
+
standalone_migrations (6.1.0)
|
182
|
+
activerecord (>= 4.2.7, < 6.2.0, != 5.2.3.rc1, != 5.2.3)
|
183
|
+
railties (>= 4.2.7, < 6.2.0, != 5.2.3.rc1, != 5.2.3)
|
176
184
|
rake (>= 10.0)
|
177
|
-
|
185
|
+
stringio (3.0.1)
|
186
|
+
thor (1.2.1)
|
178
187
|
thread_safe (0.3.6)
|
179
|
-
timecop (0.9.
|
180
|
-
tzinfo (
|
181
|
-
|
188
|
+
timecop (0.9.4)
|
189
|
+
tzinfo (2.0.4)
|
190
|
+
concurrent-ruby (~> 1.0)
|
191
|
+
zeitwerk (2.5.4)
|
182
192
|
|
183
193
|
PLATFORMS
|
184
194
|
ruby
|
185
195
|
|
186
196
|
DEPENDENCIES
|
187
|
-
activerecord (~>
|
197
|
+
activerecord (~> 6)
|
188
198
|
activerecord-import
|
189
199
|
activesupport
|
190
200
|
bundler (~> 1.0)
|
@@ -193,7 +203,7 @@ DEPENDENCIES
|
|
193
203
|
guard
|
194
204
|
guard-rspec
|
195
205
|
jeweler!
|
196
|
-
mysql2 (= 0.
|
206
|
+
mysql2 (= 0.5)
|
197
207
|
paranoia
|
198
208
|
pg
|
199
209
|
pry
|
@@ -208,4 +218,4 @@ RUBY VERSION
|
|
208
218
|
ruby 2.6.3p62
|
209
219
|
|
210
220
|
BUNDLED WITH
|
211
|
-
1.17.
|
221
|
+
1.17.3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/historiographer.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: historiographer
|
5
|
+
# stub: historiographer 2.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "historiographer".freeze
|
9
|
-
s.version = "
|
9
|
+
s.version = "2.0.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["brettshollenberger".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2022-02-04"
|
15
15
|
s.description = "Creates separate tables for each history table".freeze
|
16
16
|
s.email = "brett.shollenberger@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -59,51 +59,36 @@ Gem::Specification.new do |s|
|
|
59
59
|
]
|
60
60
|
s.homepage = "http://github.com/brettshollenberger/historiographer".freeze
|
61
61
|
s.licenses = ["MIT".freeze]
|
62
|
-
s.rubygems_version = "3.
|
62
|
+
s.rubygems_version = "3.2.23".freeze
|
63
63
|
s.summary = "Create histories of your ActiveRecord tables".freeze
|
64
64
|
|
65
65
|
if s.respond_to? :specification_version then
|
66
66
|
s.specification_version = 4
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
else
|
84
|
-
s.add_dependency(%q<activerecord>.freeze, ["~> 5.1"])
|
85
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
86
|
-
s.add_dependency(%q<rollbar>.freeze, [">= 0"])
|
87
|
-
s.add_dependency(%q<activerecord-import>.freeze, [">= 0"])
|
88
|
-
s.add_dependency(%q<pg>.freeze, [">= 0"])
|
89
|
-
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
90
|
-
s.add_dependency(%q<mysql2>.freeze, ["= 0.4.10"])
|
91
|
-
s.add_dependency(%q<standalone_migrations>.freeze, [">= 0"])
|
92
|
-
s.add_dependency(%q<timecop>.freeze, [">= 0"])
|
93
|
-
s.add_dependency(%q<paranoia>.freeze, [">= 0"])
|
94
|
-
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
95
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
96
|
-
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
97
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
98
|
-
end
|
69
|
+
if s.respond_to? :add_runtime_dependency then
|
70
|
+
s.add_runtime_dependency(%q<activerecord>.freeze, ["~> 6"])
|
71
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
|
72
|
+
s.add_runtime_dependency(%q<rollbar>.freeze, [">= 0"])
|
73
|
+
s.add_runtime_dependency(%q<activerecord-import>.freeze, [">= 0"])
|
74
|
+
s.add_development_dependency(%q<pg>.freeze, [">= 0"])
|
75
|
+
s.add_development_dependency(%q<pry>.freeze, [">= 0"])
|
76
|
+
s.add_development_dependency(%q<mysql2>.freeze, ["= 0.5"])
|
77
|
+
s.add_development_dependency(%q<standalone_migrations>.freeze, [">= 0"])
|
78
|
+
s.add_development_dependency(%q<timecop>.freeze, [">= 0"])
|
79
|
+
s.add_development_dependency(%q<paranoia>.freeze, [">= 0"])
|
80
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
81
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
82
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
83
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
99
84
|
else
|
100
|
-
s.add_dependency(%q<activerecord>.freeze, ["~>
|
85
|
+
s.add_dependency(%q<activerecord>.freeze, ["~> 6"])
|
101
86
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
102
87
|
s.add_dependency(%q<rollbar>.freeze, [">= 0"])
|
103
88
|
s.add_dependency(%q<activerecord-import>.freeze, [">= 0"])
|
104
89
|
s.add_dependency(%q<pg>.freeze, [">= 0"])
|
105
90
|
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
106
|
-
s.add_dependency(%q<mysql2>.freeze, ["= 0.
|
91
|
+
s.add_dependency(%q<mysql2>.freeze, ["= 0.5"])
|
107
92
|
s.add_dependency(%q<standalone_migrations>.freeze, [">= 0"])
|
108
93
|
s.add_dependency(%q<timecop>.freeze, [">= 0"])
|
109
94
|
s.add_dependency(%q<paranoia>.freeze, [">= 0"])
|
@@ -16,15 +16,17 @@ module Historiographer
|
|
16
16
|
# Will automatically add user_id, history_started_at,
|
17
17
|
# and history_ended_at columns
|
18
18
|
#
|
19
|
-
def histories(except: [], only: [], no_business_columns: false)
|
20
|
-
|
21
|
-
|
19
|
+
def histories(except: [], only: [], no_business_columns: false, index_names: {})
|
20
|
+
index_names.symbolize_keys!
|
21
|
+
|
22
|
+
original_table_name = self.name.gsub(/_histories$/) { }.pluralize
|
23
|
+
foreign_key = original_table_name.singularize.foreign_key
|
22
24
|
|
23
25
|
class_definer = Class.new(ActiveRecord::Base) do
|
24
26
|
end
|
25
27
|
|
26
28
|
class_name = original_table_name.classify
|
27
|
-
klass
|
29
|
+
klass = Object.const_set(class_name, class_definer)
|
28
30
|
original_columns = klass.columns.reject { |c| c.name == "id" || except.include?(c.name) || (only.any? && only.exclude?(c.name)) || no_business_columns }
|
29
31
|
|
30
32
|
integer foreign_key.to_sym, null: false
|
@@ -48,7 +50,6 @@ module Historiographer
|
|
48
50
|
ActiveRecord::Base.connection.indexes(original_table_name).each do |index|
|
49
51
|
index index.columns
|
50
52
|
end
|
51
|
-
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
data/lib/historiographer/safe.rb
CHANGED
@@ -25,9 +25,8 @@ module Historiographer
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def history_user_absent_action
|
28
|
-
|
28
|
+
Rollbar.error("history_user_id must be passed in order to save record with histories! If you are in a context with no history_user_id, explicitly call #save_without_history")
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
31
|
end
|
33
32
|
end
|
data/lib/historiographer.rb
CHANGED
@@ -91,6 +91,7 @@ module Historiographer
|
|
91
91
|
end
|
92
92
|
|
93
93
|
alias_method :destroy_without_history, :destroy
|
94
|
+
|
94
95
|
def destroy_with_history(history_user_id: nil)
|
95
96
|
history_user_absent_action if history_user_id.nil?
|
96
97
|
|
@@ -106,6 +107,7 @@ module Historiographer
|
|
106
107
|
@no_history = false
|
107
108
|
end
|
108
109
|
end
|
110
|
+
|
109
111
|
alias_method :destroy, :destroy_with_history
|
110
112
|
|
111
113
|
def assign_attributes(new_attributes)
|
@@ -113,7 +115,7 @@ module Historiographer
|
|
113
115
|
|
114
116
|
if huid.present?
|
115
117
|
self.class.nested_attributes_options.each do |association, _|
|
116
|
-
reflection
|
118
|
+
reflection = self.class.reflect_on_association(association)
|
117
119
|
assoc_attrs = new_attributes["#{association}_attributes"]
|
118
120
|
|
119
121
|
if assoc_attrs.present?
|
@@ -134,11 +136,12 @@ module Historiographer
|
|
134
136
|
def historiographer_changes?
|
135
137
|
case Rails.version.to_f
|
136
138
|
when 0..5 then changed? && valid?
|
137
|
-
when 5.1..
|
139
|
+
when 5.1..7 then saved_changes?
|
138
140
|
else
|
139
141
|
raise "Unsupported Rails version"
|
140
142
|
end
|
141
143
|
end
|
144
|
+
|
142
145
|
#
|
143
146
|
# If there are any changes, and the model is valid,
|
144
147
|
# and we're not force-overriding history recording,
|
@@ -195,6 +198,7 @@ module Historiographer
|
|
195
198
|
end
|
196
199
|
end
|
197
200
|
end
|
201
|
+
|
198
202
|
base.send(:prepend, UpdateColumnsWithHistory)
|
199
203
|
|
200
204
|
def save_without_history(*args, &block)
|
@@ -224,9 +228,9 @@ module Historiographer
|
|
224
228
|
def record_history
|
225
229
|
history_user_absent_action if history_user_id.nil?
|
226
230
|
|
227
|
-
attrs
|
231
|
+
attrs = attributes.clone
|
228
232
|
history_class = self.class.history_class
|
229
|
-
foreign_key
|
233
|
+
foreign_key = history_class.history_foreign_key
|
230
234
|
|
231
235
|
now = UTC.now
|
232
236
|
attrs.merge!(foreign_key => attrs["id"], history_started_at: now, history_user_id: history_user_id)
|
data/spec/db/database.yml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
|
1
|
+
development:
|
2
2
|
adapter: postgresql
|
3
3
|
prepared_statements: false
|
4
4
|
url: "postgres://localhost/historiographer_development"
|
5
5
|
|
6
|
-
development:
|
7
|
-
<<: *default
|
8
|
-
|
9
6
|
test:
|
10
7
|
adapter: postgresql
|
11
8
|
database: historiographer_test
|
9
|
+
url: "postgres://localhost/historiographer_test"
|
10
|
+
|
12
11
|
# mysql_default: &mysql_default
|
13
12
|
# adapter: mysql2
|
14
13
|
# encoding: utf8
|
data/spec/db/schema.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# of editing this file, please use the migrations feature of Active Record to
|
3
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# from scratch.
|
9
|
-
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
data/spec/examples.txt
CHANGED
@@ -1,21 +1,29 @@
|
|
1
|
-
example_id
|
2
|
-
|
3
|
-
./spec/historiographer_spec.rb[1:1:1]
|
4
|
-
./spec/historiographer_spec.rb[1:1:2]
|
5
|
-
./spec/historiographer_spec.rb[1:1:3]
|
6
|
-
./spec/historiographer_spec.rb[1:2:1]
|
7
|
-
./spec/historiographer_spec.rb[1:2:2]
|
8
|
-
./spec/historiographer_spec.rb[1:2:3:1] | passed | 0.
|
9
|
-
./spec/historiographer_spec.rb[1:2:3:2] | passed | 0.
|
10
|
-
./spec/historiographer_spec.rb[1:2:3:
|
11
|
-
./spec/historiographer_spec.rb[1:2:
|
12
|
-
./spec/historiographer_spec.rb[1:2:
|
13
|
-
./spec/historiographer_spec.rb[1:2:
|
14
|
-
./spec/historiographer_spec.rb[1:3:
|
15
|
-
./spec/historiographer_spec.rb[1:4:1] | passed | 0.
|
16
|
-
./spec/historiographer_spec.rb[1:
|
17
|
-
./spec/historiographer_spec.rb[1:
|
18
|
-
./spec/historiographer_spec.rb[1:
|
19
|
-
./spec/historiographer_spec.rb[1:
|
20
|
-
./spec/historiographer_spec.rb[1:7
|
21
|
-
./spec/historiographer_spec.rb[1:
|
1
|
+
example_id | status | run_time |
|
2
|
+
----------------------------------------- | ------ | --------------- |
|
3
|
+
./spec/historiographer_spec.rb[1:1:1] | passed | 0.00973 seconds |
|
4
|
+
./spec/historiographer_spec.rb[1:1:2] | passed | 0.01848 seconds |
|
5
|
+
./spec/historiographer_spec.rb[1:1:3] | passed | 0.0092 seconds |
|
6
|
+
./spec/historiographer_spec.rb[1:2:1] | passed | 0.02492 seconds |
|
7
|
+
./spec/historiographer_spec.rb[1:2:2] | passed | 0.00099 seconds |
|
8
|
+
./spec/historiographer_spec.rb[1:2:3:1:1] | passed | 0.13892 seconds |
|
9
|
+
./spec/historiographer_spec.rb[1:2:3:1:2] | passed | 0.1202 seconds |
|
10
|
+
./spec/historiographer_spec.rb[1:2:3:2:1] | passed | 0.02734 seconds |
|
11
|
+
./spec/historiographer_spec.rb[1:2:3:2:2] | passed | 0.04699 seconds |
|
12
|
+
./spec/historiographer_spec.rb[1:2:3:2:3] | passed | 0.02185 seconds |
|
13
|
+
./spec/historiographer_spec.rb[1:2:3:3:1] | passed | 0.08042 seconds |
|
14
|
+
./spec/historiographer_spec.rb[1:2:3:3:2] | passed | 0.02825 seconds |
|
15
|
+
./spec/historiographer_spec.rb[1:2:4:1] | passed | 0.02411 seconds |
|
16
|
+
./spec/historiographer_spec.rb[1:2:4:2] | passed | 0.01286 seconds |
|
17
|
+
./spec/historiographer_spec.rb[1:2:4:3] | passed | 0.00469 seconds |
|
18
|
+
./spec/historiographer_spec.rb[1:2:5] | passed | 0.00478 seconds |
|
19
|
+
./spec/historiographer_spec.rb[1:2:6] | passed | 0.0035 seconds |
|
20
|
+
./spec/historiographer_spec.rb[1:2:7] | passed | 0.01157 seconds |
|
21
|
+
./spec/historiographer_spec.rb[1:3:1] | passed | 0.09042 seconds |
|
22
|
+
./spec/historiographer_spec.rb[1:4:1] | passed | 0.05553 seconds |
|
23
|
+
./spec/historiographer_spec.rb[1:5:1] | passed | 0.0104 seconds |
|
24
|
+
./spec/historiographer_spec.rb[1:5:2] | passed | 0.00905 seconds |
|
25
|
+
./spec/historiographer_spec.rb[1:6:1] | passed | 0.02652 seconds |
|
26
|
+
./spec/historiographer_spec.rb[1:6:2] | passed | 0.04419 seconds |
|
27
|
+
./spec/historiographer_spec.rb[1:7:1] | passed | 0.02102 seconds |
|
28
|
+
./spec/historiographer_spec.rb[1:8:1] | passed | 0.02556 seconds |
|
29
|
+
./spec/historiographer_spec.rb[1:9:1] | passed | 0.01444 seconds |
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: historiographer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brettshollenberger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: '0.5'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: '0.5'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: standalone_migrations
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,7 +255,7 @@ homepage: http://github.com/brettshollenberger/historiographer
|
|
255
255
|
licenses:
|
256
256
|
- MIT
|
257
257
|
metadata: {}
|
258
|
-
post_install_message:
|
258
|
+
post_install_message:
|
259
259
|
rdoc_options: []
|
260
260
|
require_paths:
|
261
261
|
- lib
|
@@ -270,8 +270,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: '0'
|
272
272
|
requirements: []
|
273
|
-
rubygems_version: 3.
|
274
|
-
signing_key:
|
273
|
+
rubygems_version: 3.2.23
|
274
|
+
signing_key:
|
275
275
|
specification_version: 4
|
276
276
|
summary: Create histories of your ActiveRecord tables
|
277
277
|
test_files: []
|