checker_jobs 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 407540f61ad36263f771cc0493b8675c23037ed6887227ebc73d2ef2d49fb25a
4
- data.tar.gz: e2151498b71791a6065bf1e951b18e6d000c0c05bd287c1e1cbe6862c09bf3d7
3
+ metadata.gz: e2702b00cc3f7fa8a5b68ff40faf5edffe09c7ddc15bfd4c08ab627ade6bc6d4
4
+ data.tar.gz: 2ecf0e6f78a41ae17532e0ed57c4bbca00af5222fb999fb4b71dda19085e88d0
5
5
  SHA512:
6
- metadata.gz: 8da268fd3e0e20148297bafeb4f6ffe2aca570d957520ba4d90f25b9b6cb3c228ef3dd2a0ac47307c5ff2f1e837ce7194ab12d6369b1d3b079374081c3e3ccec
7
- data.tar.gz: 4715cf8a236d1c19a6234a9b0234c53104a5a8ee9c238aadeed993fa709a8f4c4a5a1f7391a81d7562ac98925daa6a36fcb4b47653363f1d9abf59cbe9d574be
6
+ metadata.gz: d1968fd1504a6b4b4bc056a0a67ae4e501658a95defc4b874bd16e24acf7567edc7f57058d412afee865ab5af2e00590422c05c6a66852009757f86da41cdf58
7
+ data.tar.gz: 7b61bfb6e7ecdfd9095058fb6bc9d4bf26edd6bf8c1798bfad79d9df6ba82c798db45f4178e2c5020b6c79508c12a5b50e5fc61b7706d14df8526500197db321
data/.circleci/config.yml CHANGED
@@ -1,48 +1,62 @@
1
1
  version: 2
2
2
  jobs:
3
- build:
3
+ test-ruby:
4
4
  docker:
5
- - image: drivy/rails-ci:0.1.2
5
+ - image: cimg/ruby:2.6.6
6
6
  steps:
7
7
  - checkout
8
-
9
- - run: git fetch origin --depth=1000
10
-
11
- # Install CodeClimate test reporter binary, rebuild without cache to update the binary
12
- - restore_cache:
13
- key: cc_test_reporter
14
8
  - run:
15
- name: Install Code Climate test reporter
9
+ name: Install CMake, pkg-config and system dependencies
10
+ command: sudo apt update && sudo apt install cmake pkg-config libsqlite3-dev
11
+ - run:
12
+ name: Install Bundler
16
13
  command: |
17
- [ -f bin/cc-test-reporter ] || curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./bin/cc-test-reporter
18
- chmod +x bin/cc-test-reporter
19
- - restore_cache:
20
- key: cc_test_reporter
21
- paths:
22
- - bin/cc-test-reporter
23
-
14
+ sudo gem update --system
15
+ gem install bundler --no-document
24
16
  - run:
25
- name: "Creating a Gemfile.lock without bundler's version"
26
- command: "head -n -3 Gemfile.lock > Gemfile.lock.no-version"
27
-
28
- # Bundle install with cache, Ignore bundler version
29
- - restore_cache:
30
- key: checker_jobs-{{ checksum "Gemfile.lock.no-version"}}
31
- - run:
32
- name: Install Ruby dependencies
33
- command: bundle install --path vendor/bundle --jobs=`nproc`
34
- - save_cache:
35
- key: checker_jobs-{{ checksum "Gemfile.lock.no-version"}}
36
- paths:
37
- - vendor/bundle
38
-
17
+ name: Install dependencies (bundler)
18
+ command: |
19
+ bundle config set frozen 'true'
20
+ bundle config set path 'vendor/bundle'
21
+ bundle install --jobs=4
39
22
  - run:
40
- name: RSpec
23
+ name: Install linting dependencies (Bundler)
41
24
  command: |
42
- ./bin/cc-test-reporter before-build
43
- bundle exec rspec --format documentation
44
- ./bin/cc-test-reporter after-build --exit-code $?
25
+ bundle config set frozen 'true'
26
+ bundle config set path 'vendor/bundle'
27
+ bundle install --jobs=4
28
+ - run:
29
+ name: Lint Ruby sources (RSpec)
30
+ command: bundle exec rspec
45
31
 
32
+ lint-ruby:
33
+ docker:
34
+ - image: cimg/ruby:2.6.6
35
+ steps:
36
+ - checkout
37
+ - run:
38
+ name: Install CMake, pkg-config and system dependencies
39
+ command: sudo apt update && sudo apt install cmake pkg-config libsqlite3-dev
40
+ - run:
41
+ name: Install Bundler
42
+ command: |
43
+ sudo gem update --system
44
+ gem install bundler --no-document
45
+ - run:
46
+ name: Install dependencies (bundler)
47
+ command: |
48
+ bundle config set frozen 'true'
49
+ bundle config set path 'vendor/bundle'
50
+ bundle install --jobs=4
46
51
  - run:
47
- name: Pronto
48
- command: bin/pronto-ci
52
+ name: Lint Ruby sources (Rubocop)
53
+ command: bundle exec rubocop
54
+
55
+ workflows:
56
+ version: 2
57
+ test-and-deploy:
58
+ jobs:
59
+ - test-ruby:
60
+ context: default
61
+ - lint-ruby:
62
+ context: default
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /tmp/
8
8
  .*.swp
9
9
  *.gem
10
+ vendor/bundle
data/.rubocop.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
5
4
  Exclude:
6
5
  - "examples/*.rb"
6
+ - vendor/**/*
7
7
 
8
8
  #
9
9
  # Opinionated cops
@@ -12,7 +12,7 @@ AllCops:
12
12
  Layout/DotPosition:
13
13
  EnforcedStyle: trailing
14
14
 
15
- Layout/IndentHash:
15
+ Layout/FirstHashElementIndentation:
16
16
  EnforcedStyle: consistent
17
17
 
18
18
  Metrics/AbcSize:
@@ -33,6 +33,9 @@ Style/TrailingCommaInArrayLiteral:
33
33
  Style/TrailingCommaInHashLiteral:
34
34
  EnforcedStyleForMultiline: comma
35
35
 
36
+ Style/TrailingCommaInArguments:
37
+ EnforcedStyleForMultiline: comma
38
+
36
39
  #
37
40
  # Disabled cops
38
41
  #
@@ -40,9 +43,6 @@ Style/TrailingCommaInHashLiteral:
40
43
  Style/FrozenStringLiteralComment:
41
44
  Enabled: false
42
45
 
43
- Style/BracesAroundHashParameters:
44
- Enabled: false
45
-
46
46
  Style/FormatString:
47
47
  Enabled: false
48
48
 
@@ -59,3 +59,6 @@ Metrics/BlockLength:
59
59
 
60
60
  Style/Proc:
61
61
  Enabled: false
62
+
63
+ RSpec/MultipleMemoizedHelpers:
64
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.6
data/Gemfile.lock CHANGED
@@ -1,72 +1,83 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- checker_jobs (1.1.1)
4
+ checker_jobs (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionmailer (5.1.4)
10
- actionpack (= 5.1.4)
11
- actionview (= 5.1.4)
12
- activejob (= 5.1.4)
9
+ actionmailer (6.1.3.1)
10
+ actionpack (= 6.1.3.1)
11
+ actionview (= 6.1.3.1)
12
+ activejob (= 6.1.3.1)
13
+ activesupport (= 6.1.3.1)
13
14
  mail (~> 2.5, >= 2.5.4)
14
15
  rails-dom-testing (~> 2.0)
15
- actionpack (5.1.4)
16
- actionview (= 5.1.4)
17
- activesupport (= 5.1.4)
18
- rack (~> 2.0)
16
+ actionpack (6.1.3.1)
17
+ actionview (= 6.1.3.1)
18
+ activesupport (= 6.1.3.1)
19
+ rack (~> 2.0, >= 2.0.9)
19
20
  rack-test (>= 0.6.3)
20
21
  rails-dom-testing (~> 2.0)
21
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
- actionview (5.1.4)
23
- activesupport (= 5.1.4)
22
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
23
+ actionview (6.1.3.1)
24
+ activesupport (= 6.1.3.1)
24
25
  builder (~> 3.1)
25
26
  erubi (~> 1.4)
26
27
  rails-dom-testing (~> 2.0)
27
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
28
- activejob (5.1.4)
29
- activesupport (= 5.1.4)
28
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
29
+ activejob (6.1.3.1)
30
+ activesupport (= 6.1.3.1)
30
31
  globalid (>= 0.3.6)
31
- activesupport (5.1.4)
32
+ activesupport (6.1.3.1)
32
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
- i18n (~> 0.7)
34
- minitest (~> 5.1)
35
- tzinfo (~> 1.1)
36
- addressable (2.5.2)
37
- public_suffix (>= 2.0.2, < 4.0)
38
- ast (2.4.0)
39
- bugsnag (5.4.1)
40
- builder (3.2.3)
41
- byebug (9.1.0)
42
- coderay (1.1.2)
43
- concurrent-ruby (1.0.5)
44
- connection_pool (2.2.1)
45
- crass (1.0.4)
46
- daemons (1.2.6)
47
- diff-lcs (1.3)
48
- docile (1.1.5)
49
- erubi (1.7.0)
50
- eventmachine (1.2.5)
51
- faraday (0.14.0)
34
+ i18n (>= 1.6, < 2)
35
+ minitest (>= 5.1)
36
+ tzinfo (~> 2.0)
37
+ zeitwerk (~> 2.3)
38
+ addressable (2.7.0)
39
+ public_suffix (>= 2.0.2, < 5.0)
40
+ ast (2.4.2)
41
+ bugsnag (6.20.0)
42
+ concurrent-ruby (~> 1.0)
43
+ builder (3.2.4)
44
+ byebug (11.1.3)
45
+ coderay (1.1.3)
46
+ concurrent-ruby (1.1.8)
47
+ connection_pool (2.2.5)
48
+ crass (1.0.6)
49
+ daemons (1.3.1)
50
+ diff-lcs (1.4.4)
51
+ docile (1.3.5)
52
+ erubi (1.10.0)
53
+ eventmachine (1.2.7)
54
+ faraday (1.4.1)
55
+ faraday-excon (~> 1.1)
56
+ faraday-net_http (~> 1.0)
57
+ faraday-net_http_persistent (~> 1.1)
52
58
  multipart-post (>= 1.2, < 3)
53
- gitlab (4.3.0)
54
- httparty
55
- terminal-table
56
- globalid (0.4.1)
59
+ ruby2_keywords (>= 0.0.4)
60
+ faraday-excon (1.1.0)
61
+ faraday-net_http (1.0.1)
62
+ faraday-net_http_persistent (1.1.0)
63
+ gitlab (4.17.0)
64
+ httparty (~> 0.18)
65
+ terminal-table (~> 1.5, >= 1.5.1)
66
+ globalid (0.4.2)
57
67
  activesupport (>= 4.2.0)
58
- haml (5.0.4)
68
+ haml (5.2.1)
59
69
  temple (>= 0.8.0)
60
70
  tilt
61
- httparty (0.15.6)
71
+ httparty (0.18.1)
72
+ mime-types (~> 3.0)
62
73
  multi_xml (>= 0.5.2)
63
- i18n (0.9.3)
74
+ i18n (1.8.10)
64
75
  concurrent-ruby (~> 1.0)
65
- json (2.1.0)
66
- loofah (2.2.2)
76
+ json (2.5.1)
77
+ loofah (2.9.1)
67
78
  crass (~> 1.0.2)
68
79
  nokogiri (>= 1.5.9)
69
- mail (2.7.0)
80
+ mail (2.7.1)
70
81
  mini_mime (>= 0.1.1)
71
82
  mailcatcher (0.2.4)
72
83
  eventmachine
@@ -78,132 +89,146 @@ GEM
78
89
  skinny (>= 0.1.2)
79
90
  sqlite3-ruby
80
91
  thin
81
- method_source (0.9.0)
82
- mini_mime (1.0.0)
83
- mini_portile2 (2.3.0)
84
- minitest (5.11.3)
92
+ method_source (1.0.0)
93
+ mime-types (3.3.1)
94
+ mime-types-data (~> 3.2015)
95
+ mime-types-data (3.2021.0225)
96
+ mini_mime (1.1.0)
97
+ mini_portile2 (2.5.1)
98
+ minitest (5.14.4)
85
99
  multi_xml (0.6.0)
86
- multipart-post (2.0.0)
87
- mustermann (1.0.2)
88
- nokogiri (1.8.2)
89
- mini_portile2 (~> 2.3.0)
90
- octokit (4.8.0)
100
+ multipart-post (2.1.1)
101
+ mustermann (1.1.1)
102
+ ruby2_keywords (~> 0.0.1)
103
+ nokogiri (1.11.3)
104
+ mini_portile2 (~> 2.5.0)
105
+ racc (~> 1.4)
106
+ octokit (4.21.0)
107
+ faraday (>= 0.9)
91
108
  sawyer (~> 0.8.0, >= 0.5.3)
92
- parallel (1.12.1)
93
- parser (2.5.0.5)
94
- ast (~> 2.4.0)
95
- powerpack (0.1.1)
96
- pronto (0.9.5)
97
- gitlab (~> 4.0, >= 4.0.0)
109
+ parallel (1.20.1)
110
+ parser (3.0.1.0)
111
+ ast (~> 2.4.1)
112
+ pronto (0.11.0)
113
+ gitlab (~> 4.4, >= 4.4.0)
98
114
  httparty (>= 0.13.7)
99
115
  octokit (~> 4.7, >= 4.7.0)
100
- rainbow (~> 2.1)
101
- rugged (~> 0.24, >= 0.23.0)
102
- thor (~> 0.19.0)
103
- pronto-rubocop (0.9.0)
104
- pronto (~> 0.9.0)
105
- rubocop (~> 0.38, >= 0.35.0)
106
- pry (0.11.3)
107
- coderay (~> 1.1.0)
108
- method_source (~> 0.9.0)
109
- pry-byebug (3.5.1)
110
- byebug (~> 9.1)
111
- pry (~> 0.10)
112
- public_suffix (3.0.1)
113
- rack (2.0.5)
114
- rack-protection (2.0.3)
116
+ rainbow (>= 2.2, < 4.0)
117
+ rexml (~> 3.2)
118
+ rugged (>= 0.23.0, < 1.1.0)
119
+ thor (>= 0.20.3, < 2.0)
120
+ pronto-rubocop (0.11.1)
121
+ pronto (~> 0.11.0)
122
+ rubocop (>= 0.63.1, < 2.0)
123
+ pry (0.13.1)
124
+ coderay (~> 1.1)
125
+ method_source (~> 1.0)
126
+ pry-byebug (3.9.0)
127
+ byebug (~> 11.0)
128
+ pry (~> 0.13.0)
129
+ public_suffix (4.0.6)
130
+ racc (1.5.2)
131
+ rack (2.2.3)
132
+ rack-protection (2.1.0)
115
133
  rack
116
- rack-test (0.8.2)
134
+ rack-test (1.1.0)
117
135
  rack (>= 1.0, < 3)
118
136
  rails-dom-testing (2.0.3)
119
137
  activesupport (>= 4.2.0)
120
138
  nokogiri (>= 1.6)
121
- rails-html-sanitizer (1.0.4)
122
- loofah (~> 2.2, >= 2.2.2)
123
- rainbow (2.2.2)
124
- rake
125
- rake (10.5.0)
126
- redis (4.0.1)
127
- rspec (3.7.0)
128
- rspec-core (~> 3.7.0)
129
- rspec-expectations (~> 3.7.0)
130
- rspec-mocks (~> 3.7.0)
131
- rspec-core (3.7.1)
132
- rspec-support (~> 3.7.0)
133
- rspec-expectations (3.7.0)
139
+ rails-html-sanitizer (1.3.0)
140
+ loofah (~> 2.3)
141
+ rainbow (3.0.0)
142
+ rake (13.0.3)
143
+ redis (4.2.5)
144
+ regexp_parser (2.1.1)
145
+ rexml (3.2.5)
146
+ rspec (3.10.0)
147
+ rspec-core (~> 3.10.0)
148
+ rspec-expectations (~> 3.10.0)
149
+ rspec-mocks (~> 3.10.0)
150
+ rspec-core (3.10.1)
151
+ rspec-support (~> 3.10.0)
152
+ rspec-expectations (3.10.1)
134
153
  diff-lcs (>= 1.2.0, < 2.0)
135
- rspec-support (~> 3.7.0)
136
- rspec-mocks (3.7.0)
154
+ rspec-support (~> 3.10.0)
155
+ rspec-mocks (3.10.2)
137
156
  diff-lcs (>= 1.2.0, < 2.0)
138
- rspec-support (~> 3.7.0)
139
- rspec-support (3.7.1)
140
- rubocop (0.53.0)
157
+ rspec-support (~> 3.10.0)
158
+ rspec-support (3.10.2)
159
+ rubocop (1.13.0)
141
160
  parallel (~> 1.10)
142
- parser (>= 2.5)
143
- powerpack (~> 0.1)
161
+ parser (>= 3.0.0.0)
144
162
  rainbow (>= 2.2.2, < 4.0)
163
+ regexp_parser (>= 1.8, < 3.0)
164
+ rexml
165
+ rubocop-ast (>= 1.2.0, < 2.0)
145
166
  ruby-progressbar (~> 1.7)
146
- unicode-display_width (~> 1.0, >= 1.0.1)
147
- rubocop-rspec (1.22.1)
148
- rubocop (>= 0.52.1)
149
- ruby-progressbar (1.9.0)
150
- rugged (0.26.0)
151
- sawyer (0.8.1)
152
- addressable (>= 2.3.5, < 2.6)
153
- faraday (~> 0.8, < 1.0)
154
- sidekiq (5.0.5)
155
- concurrent-ruby (~> 1.0)
156
- connection_pool (~> 2.2, >= 2.2.0)
157
- rack-protection (>= 1.5.0)
158
- redis (>= 3.3.4, < 5)
159
- simplecov (0.15.1)
160
- docile (~> 1.1.0)
161
- json (>= 1.8, < 3)
162
- simplecov-html (~> 0.10.0)
163
- simplecov-html (0.10.2)
164
- sinatra (2.0.3)
165
- mustermann (~> 1.0)
167
+ unicode-display_width (>= 1.4.0, < 3.0)
168
+ rubocop-ast (1.4.1)
169
+ parser (>= 2.7.1.5)
170
+ rubocop-rspec (2.3.0)
171
+ rubocop (~> 1.0)
172
+ rubocop-ast (>= 1.1.0)
173
+ ruby-progressbar (1.11.0)
174
+ ruby2_keywords (0.0.4)
175
+ rugged (1.0.1)
176
+ sawyer (0.8.2)
177
+ addressable (>= 2.3.5)
178
+ faraday (> 0.8, < 2.0)
179
+ sidekiq (6.2.1)
180
+ connection_pool (>= 2.2.2)
166
181
  rack (~> 2.0)
167
- rack-protection (= 2.0.3)
182
+ redis (>= 4.2.0)
183
+ simplecov (0.21.2)
184
+ docile (~> 1.1)
185
+ simplecov-html (~> 0.11)
186
+ simplecov_json_formatter (~> 0.1)
187
+ simplecov-html (0.12.3)
188
+ simplecov_json_formatter (0.1.2)
189
+ sinatra (2.1.0)
190
+ mustermann (~> 1.0)
191
+ rack (~> 2.2)
192
+ rack-protection (= 2.1.0)
168
193
  tilt (~> 2.0)
169
194
  skinny (0.2.2)
170
195
  eventmachine (~> 1.0)
171
196
  thin
172
- sqlite3 (1.3.13)
197
+ sqlite3 (1.4.2)
173
198
  sqlite3-ruby (1.3.3)
174
199
  sqlite3 (>= 1.3.3)
175
- temple (0.8.0)
200
+ temple (0.8.2)
176
201
  terminal-table (1.8.0)
177
202
  unicode-display_width (~> 1.1, >= 1.1.1)
178
- thin (1.7.2)
203
+ thin (1.8.0)
179
204
  daemons (~> 1.0, >= 1.0.9)
180
205
  eventmachine (~> 1.0, >= 1.0.4)
181
206
  rack (>= 1, < 3)
182
- thor (0.19.4)
183
- thread_safe (0.3.6)
184
- tilt (2.0.8)
185
- tzinfo (1.2.4)
186
- thread_safe (~> 0.1)
187
- unicode-display_width (1.3.0)
207
+ thor (1.1.0)
208
+ tilt (2.0.10)
209
+ tzinfo (2.0.4)
210
+ concurrent-ruby (~> 1.0)
211
+ unicode-display_width (1.7.0)
212
+ zeitwerk (2.4.2)
188
213
 
189
214
  PLATFORMS
190
215
  ruby
191
216
 
192
217
  DEPENDENCIES
193
- actionmailer (~> 5.0)
218
+ actionmailer (>= 5.0, < 7.0)
194
219
  bugsnag
195
- bundler (~> 1.13)
220
+ bundler
196
221
  checker_jobs!
197
222
  mailcatcher
198
223
  pronto
199
224
  pronto-rubocop
200
225
  pry-byebug
201
- rake (~> 10.0)
202
- rspec (~> 3.7)
226
+ rake (~> 13.0)
227
+ rspec (~> 3.10)
203
228
  rubocop
204
229
  rubocop-rspec
205
- sidekiq (~> 5.0)
230
+ sidekiq (>= 6.0, < 7.0)
206
231
  simplecov
207
232
 
208
233
  BUNDLED WITH
209
- 1.16.1
234
+ 2.1.4
data/README.md CHANGED
@@ -23,7 +23,7 @@ you like and then those checks are run by your application, in background jobs.
23
23
 
24
24
  A small DSL is provided to helps you express your predicates:
25
25
 
26
- - `ensure_no` will check that the result of a given block is `zero?` or `empty?`
26
+ - `ensure_no` will check that the result of a given block is `zero?`, `empty?` or `false`
27
27
  - `ensure_more` will check that the result of a given block is `>=` than a given number
28
28
  - `ensure_fewer` will check that the result of a given block is `<=` than a given number
29
29
 
@@ -84,6 +84,10 @@ require "checker_jobs"
84
84
  CheckerJobs.configure do |c|
85
85
  c.jobs_processor = :sidekiq
86
86
 
87
+ c.notifier :bugsnag do |options|
88
+ options[:formatter_class] = CheckerJobs::Notifiers::BugsnagDefaultFormatter
89
+ end
90
+
87
91
  c.notifier :email do |options|
88
92
  options[:formatter_class] = CheckerJobs::Notifiers::EmailDefaultFormatter
89
93
  options[:email_options] = {
@@ -119,7 +123,7 @@ PRs are appreciated 🙏
119
123
 
120
124
  We support different kind of notifiers, as of today we have the following:
121
125
 
122
- - `:bugsnag`: uses `Bugsnag` to send notifications. It takes the global configuration.
126
+ - `:bugsnag`: uses `Bugsnag` to send notifications. It takes the global Bugsnag configuration.
123
127
  - `:email`: uses `ActionMailer` to send emails. You can pass it any `ActionMailer` options.
124
128
  - `:logger`: Uses `Logger` to output inconsitencies in the log. Takes the following params:
125
129
  - `logdev`: The log device. This is a filename (String) or IO object (typically STDOUT, STDERR, or an open file).
@@ -155,7 +159,7 @@ fired through ActionMailer to `oss@drivy.com`.
155
159
  Once you have checker jobs, you'll need to run them. There are many task
156
160
  schedulers out there and it isn't really relevant what you'll be using.
157
161
 
158
- You have to enqueue you job as often as you like and that's it.
162
+ You have to enqueue your job as often as you like and that's it.
159
163
 
160
164
  ``` ruby
161
165
  UserChecker.perform_async
@@ -170,3 +174,7 @@ You'll find out that the CI is setup to run test coverage and linting.
170
174
  ## License
171
175
 
172
176
  The gem is available as open source under the terms of the [MIT License][licence].
177
+
178
+ [licence]: https://github.com/drivy/checker_jobs/blob/master/LICENSE.txt
179
+ [d-jobs]: https://drivy.engineering/jobs/
180
+ [gh-sidekiq]: https://github.com/mperham/sidekiq
data/checker_jobs.gemspec CHANGED
@@ -1,8 +1,8 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "checker_jobs/version"
4
4
 
5
- Gem::Specification.new do |spec|
5
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
6
6
  spec.name = "checker_jobs"
7
7
  spec.version = CheckerJobs::VERSION
8
8
  spec.authors = ["Drivy", "Nicolas Zermati"]
@@ -19,18 +19,19 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = "exe"
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
+ spec.required_ruby_version = ">= 2.6.0"
22
23
 
23
- spec.add_development_dependency "actionmailer", "~> 5.0"
24
+ spec.add_development_dependency "actionmailer", ">= 5.0", "< 7.0"
24
25
  spec.add_development_dependency "bugsnag"
25
- spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "bundler"
26
27
  spec.add_development_dependency "mailcatcher"
27
28
  spec.add_development_dependency "pronto"
28
29
  spec.add_development_dependency "pronto-rubocop"
29
30
  spec.add_development_dependency "pry-byebug"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.7"
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
+ spec.add_development_dependency "rspec", "~> 3.10"
32
33
  spec.add_development_dependency "rubocop"
33
34
  spec.add_development_dependency "rubocop-rspec"
34
- spec.add_development_dependency "sidekiq", "~> 5.0"
35
+ spec.add_development_dependency "sidekiq", ">= 6.0", "< 7.0"
35
36
  spec.add_development_dependency "simplecov"
36
37
  end
@@ -21,6 +21,10 @@ CheckerJobs.configure do |config|
21
21
 
22
22
  config.jobs_processor = :sidekiq
23
23
 
24
+ config.notifier :bugsnag do |options|
25
+ options[:formatter_class] = CheckerJobs::Notifiers::EmailDefaultFormatter
26
+ end
27
+
24
28
  config.notifier :email do |options|
25
29
  options[:formatter_class] = CheckerJobs::Notifiers::EmailDefaultFormatter
26
30
  options[:email_options] = {
@@ -7,6 +7,8 @@ class CheckerJobs::Checks::EnsureNo < CheckerJobs::Checks::Base
7
7
  notify(count: result) unless result.zero?
8
8
  when Enumerable
9
9
  notify(count: result.size, entries: result) unless result.empty?
10
+ when TrueClass, FalseClass
11
+ notify(count: 1) if result
10
12
  else
11
13
  raise ArgumentError, "Unsupported result: '#{result.class.name}' for 'ensure_no'"
12
14
  end
@@ -25,8 +25,8 @@ class CheckerJobs::Configuration
25
25
  end
26
26
 
27
27
  def notifier(notifier_symbol)
28
- options = {}
29
- yield(options)
28
+ options = default_options_for(notifier_symbol)
29
+ yield options
30
30
  @notifiers_options[notifier_symbol] = options
31
31
  end
32
32
 
@@ -45,4 +45,11 @@ class CheckerJobs::Configuration
45
45
  end
46
46
  Object.const_get(notifier_class_name)
47
47
  end
48
+
49
+ private
50
+
51
+ def default_options_for(notifier_symbol)
52
+ klass = notifier_class(notifier_symbol)
53
+ klass.respond_to?(:default_options) ? klass.default_options : {}
54
+ end
48
55
  end
@@ -43,11 +43,13 @@ module CheckerJobs::DSL
43
43
 
44
44
  def notifier
45
45
  raise CheckerJobs::MissingNotifier, self.class unless defined?(@notifier)
46
+
46
47
  @notifier
47
48
  end
48
49
 
49
50
  def notifier_options
50
51
  raise CheckerJobs::MissingNotifier, self.class unless defined?(@notifier)
52
+
51
53
  @notifier_options
52
54
  end
53
55
 
@@ -60,7 +62,7 @@ module CheckerJobs::DSL
60
62
  end
61
63
 
62
64
  def checks
63
- @check ||= {}
65
+ @checks ||= {}
64
66
  end
65
67
 
66
68
  def add_check(klass, name, options, block)
@@ -0,0 +1,22 @@
1
+ class CheckerJobs::Notifiers::Base
2
+ def initialize(check, _count, _entries)
3
+ @check = check
4
+ end
5
+
6
+ def notify
7
+ raise NotImplementedError
8
+ end
9
+
10
+ def self.default_options
11
+ raise NotImplementedError
12
+ end
13
+
14
+ private
15
+
16
+ def notifier_options
17
+ CheckerJobs.configuration.notifiers_options.fetch(
18
+ @check.klass.notifier,
19
+ self.class.default_options,
20
+ )
21
+ end
22
+ end
@@ -1,29 +1,30 @@
1
- require "action_mailer"
2
-
3
- class CheckerJobs::Notifiers::Bugsnag
4
- include CheckerJobs::Notifiers::FormatterHelpers
5
-
1
+ class CheckerJobs::Notifiers::Bugsnag < CheckerJobs::Notifiers::Base
6
2
  class Error < StandardError; end
7
3
 
8
4
  def initialize(check, count, entries)
9
- @check = check
10
- @metadata = {
11
- klass: @check.klass,
12
- name: @check.name,
13
- count: count,
14
- entries: entries&.map { |entry| format_entry(entry) },
15
- source_code_url: repository_url,
16
- }
5
+ super
6
+
7
+ @formatter = formatter_class.new(check, count, entries)
17
8
  end
18
9
 
19
10
  def notify
20
- raise Error, "(#{@check.klass}) #{human_check_name} was triggered!"
21
- rescue Error => error
22
- ::Bugsnag.notify(error, {
23
- severity: "warning",
24
- context: "checker_jobs",
25
- grouping_hash: error.message,
26
- triggered_check: @metadata,
27
- })
11
+ raise @formatter.base_error
12
+ rescue Error => e
13
+ ::Bugsnag.notify(e) do |notification|
14
+ notification.severity = @formatter.severity
15
+ notification.context = @formatter.context
16
+ notification.grouping_hash = @formatter.grouping_hash
17
+ notification.add_tab(*@formatter.tab_infos)
18
+ end
19
+ end
20
+
21
+ def self.default_options
22
+ { formatter_class: CheckerJobs::Notifiers::BugsnagDefaultFormatter }
23
+ end
24
+
25
+ private
26
+
27
+ def formatter_class
28
+ notifier_options.fetch(:formatter_class)
28
29
  end
29
30
  end
@@ -0,0 +1,45 @@
1
+ class CheckerJobs::Notifiers::BugsnagDefaultFormatter
2
+ include CheckerJobs::Notifiers::FormatterHelpers
3
+
4
+ def initialize(check, count, entries)
5
+ @check = check
6
+ @count = count
7
+ @entries = entries
8
+ end
9
+
10
+ def base_error
11
+ CheckerJobs::Notifiers::Bugsnag::Error.new(error_message)
12
+ end
13
+
14
+ def severity
15
+ "warning"
16
+ end
17
+
18
+ def context
19
+ "checker_jobs"
20
+ end
21
+
22
+ def grouping_hash
23
+ error_message
24
+ end
25
+
26
+ def tab_infos
27
+ ["triggered_check", triggered_check]
28
+ end
29
+
30
+ private
31
+
32
+ def triggered_check
33
+ {
34
+ klass: @check.klass,
35
+ name: @check.name,
36
+ count: @count,
37
+ entries: @entries&.map { |entry| format_entry(entry) },
38
+ source_code_url: repository_url,
39
+ }
40
+ end
41
+
42
+ def error_message
43
+ "(#{@check.klass}) #{human_check_name} was triggered!"
44
+ end
45
+ end
@@ -1,8 +1,9 @@
1
1
  require "action_mailer"
2
2
 
3
- class CheckerJobs::Notifiers::Email
3
+ class CheckerJobs::Notifiers::Email < CheckerJobs::Notifiers::Base
4
4
  def initialize(check, count, entries)
5
- @check = check
5
+ super
6
+
6
7
  @formatter = formatter_class.new(check, count, entries)
7
8
  @defaults = { subject: @formatter.subject }
8
9
 
@@ -10,27 +11,34 @@ class CheckerJobs::Notifiers::Email
10
11
  end
11
12
 
12
13
  def notify
13
- Mailer.notify(@formatter.body, options).deliver!
14
+ Mailer.notify(@formatter.body, mailer_options).deliver!
15
+ end
16
+
17
+ def self.default_options
18
+ {
19
+ formatter_class: CheckerJobs::Notifiers::EmailDefaultFormatter,
20
+ email_options: {},
21
+ }
14
22
  end
15
23
 
16
24
  private
17
25
 
18
26
  def valid?
19
- options[:to].is_a?(String)
27
+ mailer_options[:to].is_a?(String)
20
28
  end
21
29
 
22
- def options
23
- @options ||= @defaults.
24
- merge(notifier_options[:email_options]).
25
- merge(@check.klass.notifier_options)
30
+ def mailer_options
31
+ @mailer_options ||= @defaults.
32
+ merge(email_options).
33
+ merge(@check.klass.notifier_options)
26
34
  end
27
35
 
28
- def formatter_class
29
- notifier_options[:formatter_class] || CheckerJobs::Notifiers::EmailDefaultFormatter
36
+ def email_options
37
+ notifier_options[:email_options]
30
38
  end
31
39
 
32
- def notifier_options
33
- CheckerJobs.configuration.notifiers_options[@check.klass.notifier]
40
+ def formatter_class
41
+ notifier_options[:formatter_class]
34
42
  end
35
43
 
36
44
  # Simple mailer class based on ActionMailer to send HTML emails while reusing
@@ -24,7 +24,7 @@ class CheckerJobs::Notifiers::EmailDefaultFormatter
24
24
 
25
25
  private
26
26
 
27
- def format_entry(entry)
27
+ def format_entry(entry) # rubocop:disable Lint/UselessMethodDefinition
28
28
  # NOTE: inherit and override to support your custom objects
29
29
  super
30
30
  end
@@ -25,7 +25,7 @@ module CheckerJobs::Notifiers::FormatterHelpers
25
25
 
26
26
  def github_url
27
27
  filepath, line_number = @check.block.source_location
28
- filepath = filepath.sub(Dir.pwd + "/", "")
28
+ filepath = filepath.sub("#{Dir.pwd}/", "")
29
29
  GITHUB_URL_FORMAT % {
30
30
  repository: repository_configuration[:github],
31
31
  path: filepath,
@@ -1,13 +1,11 @@
1
1
  require "logger"
2
2
 
3
- class CheckerJobs::Notifiers::Logger
3
+ class CheckerJobs::Notifiers::Logger < CheckerJobs::Notifiers::Base
4
4
  include CheckerJobs::Notifiers::FormatterHelpers
5
5
 
6
- DEFAULT_LEVEL = Logger::INFO
7
- DEFAULT_LOGDEV = STDOUT
8
-
9
6
  def initialize(check, count, _entries)
10
- @check = check
7
+ super
8
+
11
9
  @count = count
12
10
  raise CheckerJobs::InvalidNotifierOptions unless valid?
13
11
 
@@ -19,13 +17,20 @@ class CheckerJobs::Notifiers::Logger
19
17
  @logger.add(level, format, human_check_name)
20
18
  end
21
19
 
20
+ def self.default_options
21
+ {
22
+ logdev: $stdout,
23
+ level: Logger::INFO,
24
+ }
25
+ end
26
+
27
+ private
28
+
22
29
  # override this
23
30
  def format
24
31
  "found #{@count} entries"
25
32
  end
26
33
 
27
- private
28
-
29
34
  def valid?
30
35
  (logdev.is_a?(String) || logdev.is_a?(IO)) &&
31
36
  [
@@ -35,18 +40,10 @@ class CheckerJobs::Notifiers::Logger
35
40
  end
36
41
 
37
42
  def level
38
- @level ||= @check.klass.notifier_options[:level] ||
39
- notifier_options[:level] ||
40
- DEFAULT_LEVEL
43
+ @level ||= @check.klass.notifier_options[:level] || notifier_options[:level]
41
44
  end
42
45
 
43
46
  def logdev
44
- @logdev ||= @check.klass.notifier_options[:logdev] ||
45
- notifier_options[:logdev] ||
46
- DEFAULT_LOGDEV
47
- end
48
-
49
- def notifier_options
50
- CheckerJobs.configuration.notifiers_options[@check.klass.notifier]
47
+ @logdev ||= @check.klass.notifier_options[:logdev] || notifier_options[:logdev]
51
48
  end
52
49
  end
@@ -1,7 +1,9 @@
1
1
  module CheckerJobs::Notifiers
2
- autoload :Bugsnag, "checker_jobs/notifiers/bugsnag"
3
- autoload :Email, "checker_jobs/notifiers/email"
4
- autoload :EmailDefaultFormatter, "checker_jobs/notifiers/email_default_formatter"
5
- autoload :FormatterHelpers, "checker_jobs/notifiers/formatter_helpers"
6
- autoload :Logger, "checker_jobs/notifiers/logger"
2
+ autoload :Base, "checker_jobs/notifiers/base"
3
+ autoload :Bugsnag, "checker_jobs/notifiers/bugsnag"
4
+ autoload :BugsnagDefaultFormatter, "checker_jobs/notifiers/bugsnag_default_formatter"
5
+ autoload :Email, "checker_jobs/notifiers/email"
6
+ autoload :EmailDefaultFormatter, "checker_jobs/notifiers/email_default_formatter"
7
+ autoload :FormatterHelpers, "checker_jobs/notifiers/formatter_helpers"
8
+ autoload :Logger, "checker_jobs/notifiers/logger"
7
9
  end
@@ -1,3 +1,3 @@
1
1
  module CheckerJobs
2
- VERSION = "1.1.1".freeze
2
+ VERSION = "1.2.1".freeze
3
3
  end
metadata CHANGED
@@ -1,30 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checker_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy
8
8
  - Nicolas Zermati
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-08-03 00:00:00.000000000 Z
12
+ date: 2024-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionmailer
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '5.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '7.0'
21
24
  type: :development
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '5.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: bugsnag
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -43,16 +49,16 @@ dependencies:
43
49
  name: bundler
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
- - - "~>"
52
+ - - ">="
47
53
  - !ruby/object:Gem::Version
48
- version: '1.13'
54
+ version: '0'
49
55
  type: :development
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
52
58
  requirements:
53
- - - "~>"
59
+ - - ">="
54
60
  - !ruby/object:Gem::Version
55
- version: '1.13'
61
+ version: '0'
56
62
  - !ruby/object:Gem::Dependency
57
63
  name: mailcatcher
58
64
  requirement: !ruby/object:Gem::Requirement
@@ -115,28 +121,28 @@ dependencies:
115
121
  requirements:
116
122
  - - "~>"
117
123
  - !ruby/object:Gem::Version
118
- version: '10.0'
124
+ version: '13.0'
119
125
  type: :development
120
126
  prerelease: false
121
127
  version_requirements: !ruby/object:Gem::Requirement
122
128
  requirements:
123
129
  - - "~>"
124
130
  - !ruby/object:Gem::Version
125
- version: '10.0'
131
+ version: '13.0'
126
132
  - !ruby/object:Gem::Dependency
127
133
  name: rspec
128
134
  requirement: !ruby/object:Gem::Requirement
129
135
  requirements:
130
136
  - - "~>"
131
137
  - !ruby/object:Gem::Version
132
- version: '3.7'
138
+ version: '3.10'
133
139
  type: :development
134
140
  prerelease: false
135
141
  version_requirements: !ruby/object:Gem::Requirement
136
142
  requirements:
137
143
  - - "~>"
138
144
  - !ruby/object:Gem::Version
139
- version: '3.7'
145
+ version: '3.10'
140
146
  - !ruby/object:Gem::Dependency
141
147
  name: rubocop
142
148
  requirement: !ruby/object:Gem::Requirement
@@ -169,16 +175,22 @@ dependencies:
169
175
  name: sidekiq
170
176
  requirement: !ruby/object:Gem::Requirement
171
177
  requirements:
172
- - - "~>"
178
+ - - ">="
173
179
  - !ruby/object:Gem::Version
174
- version: '5.0'
180
+ version: '6.0'
181
+ - - "<"
182
+ - !ruby/object:Gem::Version
183
+ version: '7.0'
175
184
  type: :development
176
185
  prerelease: false
177
186
  version_requirements: !ruby/object:Gem::Requirement
178
187
  requirements:
179
- - - "~>"
188
+ - - ">="
180
189
  - !ruby/object:Gem::Version
181
- version: '5.0'
190
+ version: '6.0'
191
+ - - "<"
192
+ - !ruby/object:Gem::Version
193
+ version: '7.0'
182
194
  - !ruby/object:Gem::Dependency
183
195
  name: simplecov
184
196
  requirement: !ruby/object:Gem::Requirement
@@ -204,6 +216,7 @@ files:
204
216
  - ".gitignore"
205
217
  - ".rspec"
206
218
  - ".rubocop.yml"
219
+ - ".ruby-version"
207
220
  - Gemfile
208
221
  - Gemfile.lock
209
222
  - LICENSE.txt
@@ -227,7 +240,9 @@ files:
227
240
  - lib/checker_jobs/jobs_processors.rb
228
241
  - lib/checker_jobs/jobs_processors/sidekiq.rb
229
242
  - lib/checker_jobs/notifiers.rb
243
+ - lib/checker_jobs/notifiers/base.rb
230
244
  - lib/checker_jobs/notifiers/bugsnag.rb
245
+ - lib/checker_jobs/notifiers/bugsnag_default_formatter.rb
231
246
  - lib/checker_jobs/notifiers/email.rb
232
247
  - lib/checker_jobs/notifiers/email_default_formatter.rb
233
248
  - lib/checker_jobs/notifiers/formatter_helpers.rb
@@ -237,7 +252,7 @@ homepage: https://github.com/drivy/checker_jobs
237
252
  licenses:
238
253
  - MIT
239
254
  metadata: {}
240
- post_install_message:
255
+ post_install_message:
241
256
  rdoc_options: []
242
257
  require_paths:
243
258
  - lib
@@ -245,16 +260,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
260
  requirements:
246
261
  - - ">="
247
262
  - !ruby/object:Gem::Version
248
- version: '0'
263
+ version: 2.6.0
249
264
  required_rubygems_version: !ruby/object:Gem::Requirement
250
265
  requirements:
251
266
  - - ">="
252
267
  - !ruby/object:Gem::Version
253
268
  version: '0'
254
269
  requirements: []
255
- rubyforge_project:
256
- rubygems_version: 2.7.6
257
- signing_key:
270
+ rubygems_version: 3.2.33
271
+ signing_key:
258
272
  specification_version: 4
259
273
  summary: Regression tests for data
260
274
  test_files: []