audited_async 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +39 -0
- data/Gemfile.lock +50 -134
- data/README.md +30 -10
- data/audited_async.gemspec +1 -2
- data/lib/audited_async.rb +31 -12
- data/lib/audited_async/audit_async_job.rb +22 -5
- data/lib/audited_async/configurator.rb +8 -3
- data/lib/audited_async/version.rb +1 -1
- metadata +10 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c51c75ec3c4c198def1ef6c8ba7d097d3082c34c50e2d9f21c32c11eccd47dff
|
|
4
|
+
data.tar.gz: 5f07254004b8529bf89fc45135a969c4a908b5ead5e8fcb474101bfa9ad02340
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42fb8fa07014009ae4e1dbc60d9da873db89b0f6d11638ffd7af74c6dcd48a646be6cdac074652dba0f788d49e3599aa2e9bd20295d49ee60f646aa034622ee1
|
|
7
|
+
data.tar.gz: 2eeb65827e23e29d82b691501eaca6341d1aea260a9512e4e364bfdc3680bfd31c7fbd76b6aceff00034c7ea59d0c9dfb9eac92362cba88783d94576db253d13
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
jobs:
|
|
3
|
+
build:
|
|
4
|
+
docker:
|
|
5
|
+
- image: circleci/ruby:2.5.1-node-browsers
|
|
6
|
+
working_directory: ~/audited_async
|
|
7
|
+
parallelism: 4
|
|
8
|
+
branches:
|
|
9
|
+
only: master
|
|
10
|
+
steps:
|
|
11
|
+
- checkout
|
|
12
|
+
|
|
13
|
+
- restore_cache:
|
|
14
|
+
keys:
|
|
15
|
+
- audited_async-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
|
|
16
|
+
- audited_async-master-{{ checksum "Gemfile.lock" }}
|
|
17
|
+
|
|
18
|
+
- run:
|
|
19
|
+
name: Bundle Install
|
|
20
|
+
command: |
|
|
21
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
|
22
|
+
|
|
23
|
+
- save_cache:
|
|
24
|
+
paths:
|
|
25
|
+
- ./vendor/bundle
|
|
26
|
+
key: audited_async-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
|
|
27
|
+
|
|
28
|
+
- run:
|
|
29
|
+
name: Test Suite
|
|
30
|
+
command: |
|
|
31
|
+
mkdir /tmp/test-results
|
|
32
|
+
|
|
33
|
+
bundle exec rspec --format progress \
|
|
34
|
+
--out /tmp/test-results/rspec.xml \
|
|
35
|
+
--format progress
|
|
36
|
+
|
|
37
|
+
- run:
|
|
38
|
+
name: Test Coverage Report
|
|
39
|
+
command: bundle exec codeclimate-test-reporter
|
data/Gemfile.lock
CHANGED
|
@@ -1,164 +1,82 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
audited_async (0.2.
|
|
4
|
+
audited_async (0.2.1)
|
|
5
|
+
activejob
|
|
5
6
|
audited (>= 4.0)
|
|
6
7
|
|
|
7
8
|
GEM
|
|
8
9
|
remote: https://rubygems.org/
|
|
9
10
|
specs:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
nio4r (~> 2.0)
|
|
13
|
-
websocket-driver (>= 0.6.1)
|
|
14
|
-
actionmailer (5.2.0)
|
|
15
|
-
actionpack (= 5.2.0)
|
|
16
|
-
actionview (= 5.2.0)
|
|
17
|
-
activejob (= 5.2.0)
|
|
18
|
-
mail (~> 2.5, >= 2.5.4)
|
|
19
|
-
rails-dom-testing (~> 2.0)
|
|
20
|
-
actionpack (5.2.0)
|
|
21
|
-
actionview (= 5.2.0)
|
|
22
|
-
activesupport (= 5.2.0)
|
|
23
|
-
rack (~> 2.0)
|
|
24
|
-
rack-test (>= 0.6.3)
|
|
25
|
-
rails-dom-testing (~> 2.0)
|
|
26
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
27
|
-
actionview (5.2.0)
|
|
28
|
-
activesupport (= 5.2.0)
|
|
29
|
-
builder (~> 3.1)
|
|
30
|
-
erubi (~> 1.4)
|
|
31
|
-
rails-dom-testing (~> 2.0)
|
|
32
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
33
|
-
activejob (5.2.0)
|
|
34
|
-
activesupport (= 5.2.0)
|
|
11
|
+
activejob (5.2.3)
|
|
12
|
+
activesupport (= 5.2.3)
|
|
35
13
|
globalid (>= 0.3.6)
|
|
36
|
-
activemodel (5.2.
|
|
37
|
-
activesupport (= 5.2.
|
|
38
|
-
activerecord (5.2.
|
|
39
|
-
activemodel (= 5.2.
|
|
40
|
-
activesupport (= 5.2.
|
|
14
|
+
activemodel (5.2.3)
|
|
15
|
+
activesupport (= 5.2.3)
|
|
16
|
+
activerecord (5.2.3)
|
|
17
|
+
activemodel (= 5.2.3)
|
|
18
|
+
activesupport (= 5.2.3)
|
|
41
19
|
arel (>= 9.0)
|
|
42
|
-
|
|
43
|
-
actionpack (= 5.2.0)
|
|
44
|
-
activerecord (= 5.2.0)
|
|
45
|
-
marcel (~> 0.3.1)
|
|
46
|
-
activesupport (5.2.0)
|
|
20
|
+
activesupport (5.2.3)
|
|
47
21
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
48
22
|
i18n (>= 0.7, < 2)
|
|
49
23
|
minitest (~> 5.1)
|
|
50
24
|
tzinfo (~> 1.1)
|
|
51
25
|
arel (9.0.0)
|
|
52
26
|
ast (2.4.0)
|
|
53
|
-
audited (4.
|
|
54
|
-
activerecord (>= 4.
|
|
55
|
-
|
|
56
|
-
codeclimate-test-reporter (1.0.8)
|
|
57
|
-
simplecov (<= 0.13)
|
|
58
|
-
concurrent-ruby (1.0.5)
|
|
59
|
-
crass (1.0.4)
|
|
27
|
+
audited (4.9.0)
|
|
28
|
+
activerecord (>= 4.2, < 6.1)
|
|
29
|
+
concurrent-ruby (1.1.5)
|
|
60
30
|
diff-lcs (1.3)
|
|
61
|
-
|
|
62
|
-
erubi (1.7.1)
|
|
63
|
-
globalid (0.4.1)
|
|
31
|
+
globalid (0.4.2)
|
|
64
32
|
activesupport (>= 4.2.0)
|
|
65
|
-
i18n (1.0
|
|
33
|
+
i18n (1.6.0)
|
|
66
34
|
concurrent-ruby (~> 1.0)
|
|
67
|
-
|
|
68
|
-
loofah (2.2.2)
|
|
69
|
-
crass (~> 1.0.2)
|
|
70
|
-
nokogiri (>= 1.5.9)
|
|
71
|
-
mail (2.7.0)
|
|
72
|
-
mini_mime (>= 0.1.1)
|
|
73
|
-
marcel (0.3.2)
|
|
74
|
-
mimemagic (~> 0.3.2)
|
|
75
|
-
method_source (0.9.0)
|
|
76
|
-
mimemagic (0.3.2)
|
|
77
|
-
mini_mime (1.0.0)
|
|
78
|
-
mini_portile2 (2.3.0)
|
|
35
|
+
jaro_winkler (1.5.3)
|
|
79
36
|
minitest (5.11.3)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
mini_portile2 (~> 2.3.0)
|
|
83
|
-
parallel (1.12.1)
|
|
84
|
-
parser (2.5.1.0)
|
|
37
|
+
parallel (1.17.0)
|
|
38
|
+
parser (2.6.3.0)
|
|
85
39
|
ast (~> 2.4.0)
|
|
86
|
-
|
|
87
|
-
rack (2.0.5)
|
|
88
|
-
rack-test (1.0.0)
|
|
89
|
-
rack (>= 1.0, < 3)
|
|
90
|
-
rails (5.2.0)
|
|
91
|
-
actioncable (= 5.2.0)
|
|
92
|
-
actionmailer (= 5.2.0)
|
|
93
|
-
actionpack (= 5.2.0)
|
|
94
|
-
actionview (= 5.2.0)
|
|
95
|
-
activejob (= 5.2.0)
|
|
96
|
-
activemodel (= 5.2.0)
|
|
97
|
-
activerecord (= 5.2.0)
|
|
98
|
-
activestorage (= 5.2.0)
|
|
99
|
-
activesupport (= 5.2.0)
|
|
100
|
-
bundler (>= 1.3.0)
|
|
101
|
-
railties (= 5.2.0)
|
|
102
|
-
sprockets-rails (>= 2.0.0)
|
|
103
|
-
rails-dom-testing (2.0.3)
|
|
104
|
-
activesupport (>= 4.2.0)
|
|
105
|
-
nokogiri (>= 1.6)
|
|
106
|
-
rails-html-sanitizer (1.0.4)
|
|
107
|
-
loofah (~> 2.2, >= 2.2.2)
|
|
108
|
-
railties (5.2.0)
|
|
109
|
-
actionpack (= 5.2.0)
|
|
110
|
-
activesupport (= 5.2.0)
|
|
111
|
-
method_source
|
|
112
|
-
rake (>= 0.8.7)
|
|
113
|
-
thor (>= 0.18.1, < 2.0)
|
|
40
|
+
rack (2.0.7)
|
|
114
41
|
rainbow (3.0.0)
|
|
115
|
-
rake (12.3.
|
|
116
|
-
rspec (3.
|
|
117
|
-
rspec-core (~> 3.
|
|
118
|
-
rspec-expectations (~> 3.
|
|
119
|
-
rspec-mocks (~> 3.
|
|
120
|
-
rspec-core (3.
|
|
121
|
-
rspec-support (~> 3.
|
|
122
|
-
rspec-expectations (3.
|
|
42
|
+
rake (12.3.3)
|
|
43
|
+
rspec (3.8.0)
|
|
44
|
+
rspec-core (~> 3.8.0)
|
|
45
|
+
rspec-expectations (~> 3.8.0)
|
|
46
|
+
rspec-mocks (~> 3.8.0)
|
|
47
|
+
rspec-core (3.8.2)
|
|
48
|
+
rspec-support (~> 3.8.0)
|
|
49
|
+
rspec-expectations (3.8.4)
|
|
123
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
124
|
-
rspec-support (~> 3.
|
|
125
|
-
rspec-mocks (3.
|
|
51
|
+
rspec-support (~> 3.8.0)
|
|
52
|
+
rspec-mocks (3.8.1)
|
|
126
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
127
|
-
rspec-support (~> 3.
|
|
128
|
-
rspec-support (3.
|
|
129
|
-
rubocop (0.
|
|
54
|
+
rspec-support (~> 3.8.0)
|
|
55
|
+
rspec-support (3.8.2)
|
|
56
|
+
rubocop (0.71.0)
|
|
57
|
+
jaro_winkler (~> 1.5.1)
|
|
130
58
|
parallel (~> 1.10)
|
|
131
|
-
parser (>= 2.
|
|
132
|
-
powerpack (~> 0.1)
|
|
59
|
+
parser (>= 2.6)
|
|
133
60
|
rainbow (>= 2.2.2, < 4.0)
|
|
134
61
|
ruby-progressbar (~> 1.7)
|
|
135
|
-
unicode-display_width (
|
|
136
|
-
rubocop-
|
|
137
|
-
rubocop (>= 0.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
sprockets (3.7.1)
|
|
145
|
-
concurrent-ruby (~> 1.0)
|
|
146
|
-
rack (> 1, < 3)
|
|
147
|
-
sprockets-rails (3.2.1)
|
|
148
|
-
actionpack (>= 4.0)
|
|
149
|
-
activesupport (>= 4.0)
|
|
150
|
-
sprockets (>= 3.0.0)
|
|
151
|
-
thor (0.20.0)
|
|
62
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
63
|
+
rubocop-performance (1.4.1)
|
|
64
|
+
rubocop (>= 0.71.0)
|
|
65
|
+
rubocop-rails (2.0.1)
|
|
66
|
+
rack (>= 1.1)
|
|
67
|
+
rubocop (>= 0.70.0)
|
|
68
|
+
rubocop-rspec (1.35.0)
|
|
69
|
+
rubocop (>= 0.60.0)
|
|
70
|
+
ruby-progressbar (1.10.1)
|
|
152
71
|
thread_safe (0.3.6)
|
|
153
72
|
tzinfo (1.2.5)
|
|
154
73
|
thread_safe (~> 0.1)
|
|
155
|
-
unicode-display_width (1.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
rubocop
|
|
161
|
-
rubocop-rspec (~> 1.15)
|
|
74
|
+
unicode-display_width (1.6.0)
|
|
75
|
+
wonder-ruby-style (0.71.0)
|
|
76
|
+
rubocop (= 0.71.0)
|
|
77
|
+
rubocop-performance
|
|
78
|
+
rubocop-rails
|
|
79
|
+
rubocop-rspec
|
|
162
80
|
|
|
163
81
|
PLATFORMS
|
|
164
82
|
ruby
|
|
@@ -166,11 +84,9 @@ PLATFORMS
|
|
|
166
84
|
DEPENDENCIES
|
|
167
85
|
audited_async!
|
|
168
86
|
bundler
|
|
169
|
-
codeclimate-test-reporter
|
|
170
|
-
rails
|
|
171
87
|
rake
|
|
172
88
|
rspec
|
|
173
89
|
wonder-ruby-style
|
|
174
90
|
|
|
175
91
|
BUNDLED WITH
|
|
176
|
-
1.
|
|
92
|
+
1.17.3
|
data/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# AuditedAsync
|
|
2
2
|
|
|
3
3
|
[](https://codeclimate.com/github/leonardofalk/audited_async/maintainability) [](https://codeclimate.com/github/leonardofalk/audited_async/test_coverage)
|
|
4
|
+
[](https://circleci.com/gh/leonardofalk/audited_async)
|
|
4
5
|
|
|
5
|
-
AuditedAsync is an
|
|
6
|
+
AuditedAsync is an extension for the [audited](https://github.com/collectiveidea/audited) gem which allows to create audits asynchronously using ActiveJob.
|
|
6
7
|
|
|
7
|
-
It
|
|
8
|
+
It works by safely injecting the `async` option into audited model option using functional programming. If enabled, it'll move audit creation logic into an ActiveJob instance, then it's sent to the queue to be executed later.
|
|
8
9
|
|
|
9
10
|
## Installation
|
|
10
11
|
|
|
@@ -27,7 +28,18 @@ class Post < ApplicationRecord
|
|
|
27
28
|
end
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
Depending on your active job adapter, you may need to make the queue name visible to the adapter.
|
|
32
|
+
|
|
33
|
+
### Sidekiq
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
# config/sidekiq.yml
|
|
37
|
+
...
|
|
38
|
+
:queues:
|
|
39
|
+
- [audits, 1] # add this line
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
All done! Although you can optionally configure some more stuff, check below.
|
|
31
43
|
|
|
32
44
|
#### Enabling it programmatically
|
|
33
45
|
|
|
@@ -35,7 +47,7 @@ All done! Although you can configure some stuff, check below.
|
|
|
35
47
|
# config/initializers/audited_async.rb
|
|
36
48
|
|
|
37
49
|
AuditedAsync.configure do |config|
|
|
38
|
-
config.enabled
|
|
50
|
+
config.enabled = Rails.env.production?
|
|
39
51
|
end
|
|
40
52
|
```
|
|
41
53
|
|
|
@@ -46,6 +58,7 @@ end
|
|
|
46
58
|
|
|
47
59
|
AuditedAsync.configure do |config|
|
|
48
60
|
config.job_name = 'JobityJob'
|
|
61
|
+
config.job_options = { wait: 1.second }
|
|
49
62
|
end
|
|
50
63
|
```
|
|
51
64
|
|
|
@@ -79,17 +92,24 @@ class JobityJob < ApplicationJob
|
|
|
79
92
|
end
|
|
80
93
|
```
|
|
81
94
|
|
|
82
|
-
|
|
95
|
+
### Limitations
|
|
83
96
|
|
|
84
|
-
|
|
97
|
+
- Audits for destroying an object are subject to soft delete, hard deleted records are ignored, so if you are using some library like [paranoia](https://github.com/rubysherpas/paranoia) or [discard](https://github.com/jhawthorn/discard), destroying an object will still create audits, regardless model scoping.
|
|
98
|
+
- Attributes passed down to job are limited to serializable attributes, you can find a [list here](https://edgeguides.rubyonrails.org/active_job_basics.html#supported-types-for-arguments), other than that would throw an error.
|
|
85
99
|
|
|
86
|
-
|
|
100
|
+
To see how the default job performs, [look here](./lib/audited_async/audit_async_job.rb).
|
|
101
|
+
|
|
102
|
+
## Sample App
|
|
103
|
+
|
|
104
|
+
https://github.com/leonardofalk/audited_async_sample.git
|
|
87
105
|
|
|
88
106
|
## Development
|
|
89
107
|
|
|
90
|
-
|
|
108
|
+
Check out the repository, execute `bundle install` and you're good to go.
|
|
109
|
+
|
|
110
|
+
## Testing
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
There are some unit tests now but integration tests are missing. You can ran the suite by executing `rspec`.
|
|
93
113
|
|
|
94
114
|
## Contributing
|
|
95
115
|
|
|
@@ -97,7 +117,7 @@ Bug reports and pull requests are welcome on GitHub at <https://github.com/leona
|
|
|
97
117
|
|
|
98
118
|
## To Do
|
|
99
119
|
|
|
100
|
-
- [ ] Elaborate
|
|
120
|
+
- [ ] Elaborate integration test cases.
|
|
101
121
|
|
|
102
122
|
## License
|
|
103
123
|
|
data/audited_async.gemspec
CHANGED
|
@@ -23,11 +23,10 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.require_paths = %w[lib]
|
|
24
24
|
|
|
25
25
|
spec.add_dependency 'audited', '>= 4.0'
|
|
26
|
+
spec.add_dependency 'activejob'
|
|
26
27
|
|
|
27
28
|
spec.add_development_dependency 'bundler'
|
|
28
29
|
spec.add_development_dependency 'rake'
|
|
29
30
|
spec.add_development_dependency 'rspec'
|
|
30
31
|
spec.add_development_dependency 'wonder-ruby-style'
|
|
31
|
-
spec.add_development_dependency 'rails'
|
|
32
|
-
spec.add_development_dependency 'codeclimate-test-reporter'
|
|
33
32
|
end
|
data/lib/audited_async.rb
CHANGED
|
@@ -5,14 +5,30 @@ require 'audited_async/audit_async_job'
|
|
|
5
5
|
|
|
6
6
|
module AuditedAsync
|
|
7
7
|
class << self
|
|
8
|
-
def
|
|
9
|
-
@
|
|
8
|
+
def logger
|
|
9
|
+
@logger ||= begin
|
|
10
|
+
if defined?(::Rails)
|
|
11
|
+
::Rails.logger
|
|
12
|
+
else
|
|
13
|
+
require 'logger'
|
|
14
|
+
|
|
15
|
+
Logger.new
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
def configure
|
|
21
|
+
yield configurator
|
|
12
22
|
end
|
|
13
23
|
|
|
14
24
|
def config
|
|
15
|
-
|
|
25
|
+
configurator
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def configurator
|
|
31
|
+
@configurator ||= AuditedAsync::Configurator.new
|
|
16
32
|
end
|
|
17
33
|
end
|
|
18
34
|
end
|
|
@@ -49,8 +65,8 @@ module Audited::Auditor::AuditedInstanceMethods
|
|
|
49
65
|
define_method :audit_update do
|
|
50
66
|
return _audit_update.bind(self).() unless audited_async_enabled?
|
|
51
67
|
|
|
52
|
-
unless (changes = audited_changes).empty? && audit_comment.blank?
|
|
53
|
-
perform_async_audit
|
|
68
|
+
unless (changes = audited_changes).empty? && (audit_comment.blank? || audited_options[:update_with_comment_only] == false)
|
|
69
|
+
perform_async_audit('update', changes)
|
|
54
70
|
end
|
|
55
71
|
end
|
|
56
72
|
|
|
@@ -60,11 +76,14 @@ module Audited::Auditor::AuditedInstanceMethods
|
|
|
60
76
|
perform_async_audit 'destroy' unless new_record?
|
|
61
77
|
end
|
|
62
78
|
|
|
63
|
-
def perform_async_audit(method)
|
|
64
|
-
AuditedAsync.config
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
def perform_async_audit(method, changes = nil)
|
|
80
|
+
AuditedAsync.config
|
|
81
|
+
.job
|
|
82
|
+
.set(AuditedAsync.config.job_options)
|
|
83
|
+
.perform_later class_name: self.class.name,
|
|
84
|
+
record_id: send(self.class.primary_key.to_sym),
|
|
85
|
+
action: method,
|
|
86
|
+
audited_changes: (changes || audited_attributes).to_json,
|
|
87
|
+
comment: audit_comment
|
|
69
88
|
end
|
|
70
89
|
end
|
|
@@ -3,10 +3,27 @@ require 'active_job'
|
|
|
3
3
|
class AuditedAsync::AuditAsyncJob < ActiveJob::Base
|
|
4
4
|
queue_as :audits
|
|
5
5
|
|
|
6
|
-
def perform(
|
|
7
|
-
klass =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
def perform(args)
|
|
7
|
+
klass, id, changes = extract_auditing_elements(args)
|
|
8
|
+
|
|
9
|
+
record = klass.unscoped.find_by(klass.primary_key.to_sym => id)
|
|
10
|
+
|
|
11
|
+
return alert_record_not_found(klass, id) unless record
|
|
12
|
+
|
|
13
|
+
record.send(:write_audit, changes)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def extract_auditing_elements(args)
|
|
19
|
+
return [args[:class_name].safe_constantize, args[:record_id], extract_audit_changes(args)]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def extract_audit_changes(args)
|
|
23
|
+
args.except(:class_name, :record_id).merge(audited_changes: JSON.parse(args[:audited_changes]))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def alert_record_not_found(klass, id)
|
|
27
|
+
AuditedAsync.logger.error "AuditedAsync: #{klass} record with id '#{id}' not found, ignoring audit write."
|
|
11
28
|
end
|
|
12
29
|
end
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
module AuditedAsync
|
|
2
2
|
class Configurator
|
|
3
|
-
attr_accessor :enabled, :job_name
|
|
3
|
+
attr_accessor :enabled, :job_name, :job_options
|
|
4
4
|
|
|
5
5
|
def initialize
|
|
6
|
-
@enabled
|
|
7
|
-
@job_name
|
|
6
|
+
@enabled = true
|
|
7
|
+
@job_name = 'AuditedAsync::AuditAsyncJob'
|
|
8
|
+
@job_options = { wait: 1.second }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def job_options
|
|
12
|
+
@job_options || {}
|
|
8
13
|
end
|
|
9
14
|
|
|
10
15
|
alias enabled? enabled
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: audited_async
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leonardo Falk
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: audited
|
|
@@ -25,27 +25,13 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '4.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: activejob
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
|
-
type: :
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
34
|
+
type: :runtime
|
|
49
35
|
prerelease: false
|
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
37
|
requirements:
|
|
@@ -53,7 +39,7 @@ dependencies:
|
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
40
|
version: '0'
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
42
|
+
name: bundler
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
45
|
- - ">="
|
|
@@ -67,7 +53,7 @@ dependencies:
|
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
54
|
version: '0'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
56
|
+
name: rake
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - ">="
|
|
@@ -81,7 +67,7 @@ dependencies:
|
|
|
81
67
|
- !ruby/object:Gem::Version
|
|
82
68
|
version: '0'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
70
|
+
name: rspec
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
86
72
|
requirements:
|
|
87
73
|
- - ">="
|
|
@@ -95,7 +81,7 @@ dependencies:
|
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
82
|
version: '0'
|
|
97
83
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
84
|
+
name: wonder-ruby-style
|
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
|
100
86
|
requirements:
|
|
101
87
|
- - ">="
|
|
@@ -115,6 +101,7 @@ executables: []
|
|
|
115
101
|
extensions: []
|
|
116
102
|
extra_rdoc_files: []
|
|
117
103
|
files:
|
|
104
|
+
- ".circleci/config.yml"
|
|
118
105
|
- ".gitignore"
|
|
119
106
|
- ".rspec"
|
|
120
107
|
- ".rubocop.yml"
|
|
@@ -150,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
150
137
|
- !ruby/object:Gem::Version
|
|
151
138
|
version: '0'
|
|
152
139
|
requirements: []
|
|
153
|
-
|
|
154
|
-
rubygems_version: 2.7.6
|
|
140
|
+
rubygems_version: 3.0.4
|
|
155
141
|
signing_key:
|
|
156
142
|
specification_version: 4
|
|
157
143
|
summary: Execute audited asynchronously with ActiveJob.
|