bp3-noticed 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1193948dca5bcda90b8e2c1451a75ee2c93e8573175e178214d3c56a1c91f9b
4
- data.tar.gz: 43df9cace6940523d31d82f2a45c75b3f705bbeb13f6580eca7655b2577c644e
3
+ metadata.gz: b4ca6fef467f83a78fa5398c7eb41d1c2b3597a9dd22918ced10e2feeb833220
4
+ data.tar.gz: 816d88d3dbd4531296f2942198500821a1c1b3c0085a5ea9afd4c838a7a56dbc
5
5
  SHA512:
6
- metadata.gz: d3c2ce7e7dd976b1a2a19f0a5989db81e8b76b9010a4e9bc54e52fc1d6c54e7d0e180f4c12f65774d4741534f947f84ef4d3d807ded7a77fa0fb40a51761b223
7
- data.tar.gz: '09e6152cf5f3b49bc89b8c403cdc395b695ce83f301f7d7c84407ba0452f6f0962dfee93362b1de6f5ae3dfe82dbd9b4ae4fe7bf1407d01dece3dab3bd918c9e'
6
+ metadata.gz: 940061280909e5b2173bce4df2aece7a59d95a89c4d0f77dbb9eaa8b713511693809b0ce0add7bb7d08421b821bbf16bce2220d937b289be3387c0b60e5f48ae
7
+ data.tar.gz: f083d2dd46f9cffe2499048d2b8cb231ab28513b503da5d5fe8b0046fb2e30334d357f6718475b470439cf28086ac1f9536ab14fc29bf32349783dc2748d7d66
data/.rubocop.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  require:
2
2
  - rubocop-rake
3
3
  - rubocop-rspec
4
- - rubocop-capybara
5
- - rubocop-factory_bot
6
4
 
7
5
  AllCops:
8
6
  TargetRubyVersion: 3.2.2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.2.2
1
+ ruby-3.3.5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2024-11-18
4
+
5
+ - Use ruby 3.3.5 and relax gem constraints
6
+
7
+ ## [0.2.0] - 2024-07-31
8
+
9
+ - Namespace include and prepend modules
10
+ - Tweaks
11
+
3
12
  ## [0.1.1] - 2024-06-03
4
13
 
5
14
  - Tweaks and documentation
data/Gemfile.lock CHANGED
@@ -1,119 +1,118 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bp3-noticed (0.1.1)
5
- activesupport (>= 7.1.2, < 8)
6
- bp3-action_dispatch (>= 0.1, < 1)
7
- bp3-core (>= 0.1, < 1)
8
- noticed (~> 2.2)
4
+ bp3-noticed (0.2.1)
5
+ activesupport (>= 7.1.2)
6
+ bp3-action_dispatch (>= 0.1)
7
+ bp3-core (>= 0.1)
8
+ noticed (>= 2.2)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (7.1.3.3)
14
- actionpack (= 7.1.3.3)
15
- activesupport (= 7.1.3.3)
13
+ actioncable (8.0.0)
14
+ actionpack (= 8.0.0)
15
+ activesupport (= 8.0.0)
16
16
  nio4r (~> 2.0)
17
17
  websocket-driver (>= 0.6.1)
18
18
  zeitwerk (~> 2.6)
19
- actionmailbox (7.1.3.3)
20
- actionpack (= 7.1.3.3)
21
- activejob (= 7.1.3.3)
22
- activerecord (= 7.1.3.3)
23
- activestorage (= 7.1.3.3)
24
- activesupport (= 7.1.3.3)
25
- mail (>= 2.7.1)
26
- net-imap
27
- net-pop
28
- net-smtp
29
- actionmailer (7.1.3.3)
30
- actionpack (= 7.1.3.3)
31
- actionview (= 7.1.3.3)
32
- activejob (= 7.1.3.3)
33
- activesupport (= 7.1.3.3)
34
- mail (~> 2.5, >= 2.5.4)
35
- net-imap
36
- net-pop
37
- net-smtp
19
+ actionmailbox (8.0.0)
20
+ actionpack (= 8.0.0)
21
+ activejob (= 8.0.0)
22
+ activerecord (= 8.0.0)
23
+ activestorage (= 8.0.0)
24
+ activesupport (= 8.0.0)
25
+ mail (>= 2.8.0)
26
+ actionmailer (8.0.0)
27
+ actionpack (= 8.0.0)
28
+ actionview (= 8.0.0)
29
+ activejob (= 8.0.0)
30
+ activesupport (= 8.0.0)
31
+ mail (>= 2.8.0)
38
32
  rails-dom-testing (~> 2.2)
39
- actionpack (7.1.3.3)
40
- actionview (= 7.1.3.3)
41
- activesupport (= 7.1.3.3)
33
+ actionpack (8.0.0)
34
+ actionview (= 8.0.0)
35
+ activesupport (= 8.0.0)
42
36
  nokogiri (>= 1.8.5)
43
- racc
44
37
  rack (>= 2.2.4)
45
38
  rack-session (>= 1.0.1)
46
39
  rack-test (>= 0.6.3)
47
40
  rails-dom-testing (~> 2.2)
48
41
  rails-html-sanitizer (~> 1.6)
49
- actiontext (7.1.3.3)
50
- actionpack (= 7.1.3.3)
51
- activerecord (= 7.1.3.3)
52
- activestorage (= 7.1.3.3)
53
- activesupport (= 7.1.3.3)
42
+ useragent (~> 0.16)
43
+ actiontext (8.0.0)
44
+ actionpack (= 8.0.0)
45
+ activerecord (= 8.0.0)
46
+ activestorage (= 8.0.0)
47
+ activesupport (= 8.0.0)
54
48
  globalid (>= 0.6.0)
55
49
  nokogiri (>= 1.8.5)
56
- actionview (7.1.3.3)
57
- activesupport (= 7.1.3.3)
50
+ actionview (8.0.0)
51
+ activesupport (= 8.0.0)
58
52
  builder (~> 3.1)
59
53
  erubi (~> 1.11)
60
54
  rails-dom-testing (~> 2.2)
61
55
  rails-html-sanitizer (~> 1.6)
62
- activejob (7.1.3.3)
63
- activesupport (= 7.1.3.3)
56
+ activejob (8.0.0)
57
+ activesupport (= 8.0.0)
64
58
  globalid (>= 0.3.6)
65
- activemodel (7.1.3.3)
66
- activesupport (= 7.1.3.3)
67
- activerecord (7.1.3.3)
68
- activemodel (= 7.1.3.3)
69
- activesupport (= 7.1.3.3)
59
+ activemodel (8.0.0)
60
+ activesupport (= 8.0.0)
61
+ activerecord (8.0.0)
62
+ activemodel (= 8.0.0)
63
+ activesupport (= 8.0.0)
70
64
  timeout (>= 0.4.0)
71
- activestorage (7.1.3.3)
72
- actionpack (= 7.1.3.3)
73
- activejob (= 7.1.3.3)
74
- activerecord (= 7.1.3.3)
75
- activesupport (= 7.1.3.3)
65
+ activestorage (8.0.0)
66
+ actionpack (= 8.0.0)
67
+ activejob (= 8.0.0)
68
+ activerecord (= 8.0.0)
69
+ activesupport (= 8.0.0)
76
70
  marcel (~> 1.0)
77
- activesupport (7.1.3.3)
71
+ activesupport (8.0.0)
78
72
  base64
73
+ benchmark (>= 0.3)
79
74
  bigdecimal
80
- concurrent-ruby (~> 1.0, >= 1.0.2)
75
+ concurrent-ruby (~> 1.0, >= 1.3.1)
81
76
  connection_pool (>= 2.2.5)
82
77
  drb
83
78
  i18n (>= 1.6, < 2)
79
+ logger (>= 1.4.2)
84
80
  minitest (>= 5.1)
85
- mutex_m
86
- tzinfo (~> 2.0)
81
+ securerandom (>= 0.3)
82
+ tzinfo (~> 2.0, >= 2.0.5)
83
+ uri (>= 0.13.1)
87
84
  ast (2.4.2)
88
85
  base64 (0.2.0)
86
+ benchmark (0.4.0)
89
87
  bigdecimal (3.1.8)
90
- bp3-action_dispatch (0.1.1)
91
- actionpack (>= 7.1.2, < 8)
92
- activesupport (>= 7.1.2, < 8)
93
- i18n (>= 1.8.11, < 2)
94
- bp3-core (0.1.2)
95
- actionview (>= 7.1.2, < 8)
96
- activesupport (>= 7.1.2, < 8)
97
- builder (3.2.4)
88
+ bp3-action_dispatch (0.1.3)
89
+ actionpack (>= 7.1.2)
90
+ activesupport (>= 7.1.2)
91
+ i18n (>= 1.8.11)
92
+ bp3-core (0.1.5)
93
+ actionview (>= 7.1.2)
94
+ activesupport (>= 7.1.2)
95
+ builder (3.3.0)
98
96
  byebug (11.1.3)
99
- concurrent-ruby (1.3.1)
97
+ concurrent-ruby (1.3.4)
100
98
  connection_pool (2.4.1)
101
99
  crass (1.0.6)
102
- date (3.3.4)
100
+ date (3.4.0)
103
101
  diff-lcs (1.5.1)
104
102
  drb (2.2.1)
105
- erubi (1.12.0)
103
+ erubi (1.13.0)
106
104
  globalid (1.2.1)
107
105
  activesupport (>= 6.1)
108
- i18n (1.14.5)
106
+ i18n (1.14.6)
109
107
  concurrent-ruby (~> 1.0)
110
108
  io-console (0.7.2)
111
- irb (1.13.1)
109
+ irb (1.14.1)
112
110
  rdoc (>= 4.0.0)
113
111
  reline (>= 0.4.2)
114
- json (2.7.2)
112
+ json (2.8.2)
115
113
  language_server-protocol (3.17.0.3)
116
- loofah (2.22.0)
114
+ logger (1.6.1)
115
+ loofah (2.23.1)
117
116
  crass (~> 1.0.2)
118
117
  nokogiri (>= 1.12.0)
119
118
  mail (2.8.1)
@@ -123,9 +122,8 @@ GEM
123
122
  net-smtp
124
123
  marcel (1.0.4)
125
124
  mini_mime (1.1.5)
126
- minitest (5.23.1)
127
- mutex_m (0.2.0)
128
- net-imap (0.4.12)
125
+ minitest (5.25.1)
126
+ net-imap (0.5.1)
129
127
  date
130
128
  net-protocol
131
129
  net-pop (0.1.2)
@@ -134,40 +132,39 @@ GEM
134
132
  timeout
135
133
  net-smtp (0.5.0)
136
134
  net-protocol
137
- nio4r (2.7.3)
138
- nokogiri (1.16.5-x86_64-darwin)
135
+ nio4r (2.7.4)
136
+ nokogiri (1.16.7-x86_64-darwin)
139
137
  racc (~> 1.4)
140
- noticed (2.3.2)
138
+ noticed (2.4.3)
141
139
  rails (>= 6.1.0)
142
- parallel (1.24.0)
143
- parser (3.3.2.0)
140
+ parallel (1.26.3)
141
+ parser (3.3.6.0)
144
142
  ast (~> 2.4.1)
145
143
  racc
146
- psych (5.1.2)
144
+ psych (5.2.0)
147
145
  stringio
148
- racc (1.8.0)
149
- rack (3.0.11)
146
+ racc (1.8.1)
147
+ rack (3.1.8)
150
148
  rack-session (2.0.0)
151
149
  rack (>= 3.0.0)
152
150
  rack-test (2.1.0)
153
151
  rack (>= 1.3)
154
- rackup (2.1.0)
152
+ rackup (2.2.1)
155
153
  rack (>= 3)
156
- webrick (~> 1.8)
157
- rails (7.1.3.3)
158
- actioncable (= 7.1.3.3)
159
- actionmailbox (= 7.1.3.3)
160
- actionmailer (= 7.1.3.3)
161
- actionpack (= 7.1.3.3)
162
- actiontext (= 7.1.3.3)
163
- actionview (= 7.1.3.3)
164
- activejob (= 7.1.3.3)
165
- activemodel (= 7.1.3.3)
166
- activerecord (= 7.1.3.3)
167
- activestorage (= 7.1.3.3)
168
- activesupport (= 7.1.3.3)
154
+ rails (8.0.0)
155
+ actioncable (= 8.0.0)
156
+ actionmailbox (= 8.0.0)
157
+ actionmailer (= 8.0.0)
158
+ actionpack (= 8.0.0)
159
+ actiontext (= 8.0.0)
160
+ actionview (= 8.0.0)
161
+ activejob (= 8.0.0)
162
+ activemodel (= 8.0.0)
163
+ activerecord (= 8.0.0)
164
+ activestorage (= 8.0.0)
165
+ activesupport (= 8.0.0)
169
166
  bundler (>= 1.15.0)
170
- railties (= 7.1.3.3)
167
+ railties (= 8.0.0)
171
168
  rails-dom-testing (2.2.0)
172
169
  activesupport (>= 5.0.0)
173
170
  minitest
@@ -175,10 +172,10 @@ GEM
175
172
  rails-html-sanitizer (1.6.0)
176
173
  loofah (~> 2.21)
177
174
  nokogiri (~> 1.14)
178
- railties (7.1.3.3)
179
- actionpack (= 7.1.3.3)
180
- activesupport (= 7.1.3.3)
181
- irb
175
+ railties (8.0.0)
176
+ actionpack (= 8.0.0)
177
+ activesupport (= 8.0.0)
178
+ irb (~> 1.13)
182
179
  rackup (>= 1.0.0)
183
180
  rake (>= 12.2)
184
181
  thor (~> 1.0, >= 1.2.2)
@@ -188,74 +185,64 @@ GEM
188
185
  rdoc (6.7.0)
189
186
  psych (>= 4.0.0)
190
187
  regexp_parser (2.9.2)
191
- reline (0.5.8)
188
+ reline (0.5.11)
192
189
  io-console (~> 0.5)
193
- rexml (3.2.8)
194
- strscan (>= 3.0.9)
195
190
  rspec (3.13.0)
196
191
  rspec-core (~> 3.13.0)
197
192
  rspec-expectations (~> 3.13.0)
198
193
  rspec-mocks (~> 3.13.0)
199
- rspec-core (3.13.0)
194
+ rspec-core (3.13.2)
200
195
  rspec-support (~> 3.13.0)
201
- rspec-expectations (3.13.0)
196
+ rspec-expectations (3.13.3)
202
197
  diff-lcs (>= 1.2.0, < 2.0)
203
198
  rspec-support (~> 3.13.0)
204
- rspec-mocks (3.13.1)
199
+ rspec-mocks (3.13.2)
205
200
  diff-lcs (>= 1.2.0, < 2.0)
206
201
  rspec-support (~> 3.13.0)
207
202
  rspec-support (3.13.1)
208
- rubocop (1.64.1)
203
+ rubocop (1.68.0)
209
204
  json (~> 2.3)
210
205
  language_server-protocol (>= 3.17.0)
211
206
  parallel (~> 1.10)
212
207
  parser (>= 3.3.0.2)
213
208
  rainbow (>= 2.2.2, < 4.0)
214
- regexp_parser (>= 1.8, < 3.0)
215
- rexml (>= 3.2.5, < 4.0)
216
- rubocop-ast (>= 1.31.1, < 2.0)
209
+ regexp_parser (>= 2.4, < 3.0)
210
+ rubocop-ast (>= 1.32.2, < 2.0)
217
211
  ruby-progressbar (~> 1.7)
218
212
  unicode-display_width (>= 2.4.0, < 3.0)
219
- rubocop-ast (1.31.3)
213
+ rubocop-ast (1.36.1)
220
214
  parser (>= 3.3.1.0)
221
- rubocop-capybara (2.20.0)
222
- rubocop (~> 1.41)
223
- rubocop-factory_bot (2.25.1)
224
- rubocop (~> 1.41)
225
215
  rubocop-rake (0.6.0)
226
216
  rubocop (~> 1.0)
227
- rubocop-rspec (2.30.0)
228
- rubocop (~> 1.40)
229
- rubocop-capybara (~> 2.17)
230
- rubocop-factory_bot (~> 2.22)
231
- rubocop-rspec_rails (~> 2.28)
232
- rubocop-rspec_rails (2.28.3)
233
- rubocop (~> 1.40)
217
+ rubocop-rspec (3.2.0)
218
+ rubocop (~> 1.61)
234
219
  ruby-progressbar (1.13.0)
235
- stringio (3.1.0)
236
- strscan (3.1.0)
237
- thor (1.3.1)
238
- timeout (0.4.1)
220
+ securerandom (0.3.2)
221
+ stringio (3.1.2)
222
+ thor (1.3.2)
223
+ timeout (0.4.2)
239
224
  tzinfo (2.0.6)
240
225
  concurrent-ruby (~> 1.0)
241
- unicode-display_width (2.5.0)
242
- webrick (1.8.1)
226
+ unicode-display_width (2.6.0)
227
+ uri (1.0.2)
228
+ useragent (0.16.10)
243
229
  websocket-driver (0.7.6)
244
230
  websocket-extensions (>= 0.1.0)
245
231
  websocket-extensions (0.1.5)
246
- zeitwerk (2.6.15)
232
+ zeitwerk (2.7.1)
247
233
 
248
234
  PLATFORMS
249
235
  x86_64-darwin-22
236
+ x86_64-darwin-23
250
237
 
251
238
  DEPENDENCIES
252
239
  bp3-noticed!
253
240
  byebug
254
- rake (~> 13.0)
255
- rspec (~> 3.0)
256
- rubocop (~> 1.21)
257
- rubocop-rake (~> 0.6)
258
- rubocop-rspec (~> 2.25)
241
+ rake (>= 13.0)
242
+ rspec (>= 3.0)
243
+ rubocop (>= 1.21)
244
+ rubocop-rake (>= 0.6)
245
+ rubocop-rspec (>= 2.25)
259
246
 
260
247
  BUNDLED WITH
261
- 2.5.11
248
+ 2.5.23
data/Rakefile CHANGED
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bundler/setup'
3
4
  require 'bundler/gem_tasks'
4
5
  require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
6
  require 'rubocop/rake_task'
9
7
 
8
+ Dir.glob('lib/tasks/**/*.rake').each { |file| load file }
9
+
10
+ RSpec::Core::RakeTask.new(:spec)
10
11
  RuboCop::RakeTask.new
11
12
 
12
13
  task default: %i[spec rubocop]
data/bp3-noticed.gemspec CHANGED
@@ -31,17 +31,17 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
- spec.add_dependency 'activesupport', ['>= 7.1.2', '< 8']
35
- spec.add_dependency 'bp3-action_dispatch', ['>= 0.1', '< 1']
36
- spec.add_dependency 'bp3-core', ['>= 0.1', '< 1']
37
- spec.add_dependency 'noticed', '~> 2.2'
34
+ spec.add_dependency 'activesupport', '>= 7.1.2'
35
+ spec.add_dependency 'bp3-action_dispatch', '>= 0.1'
36
+ spec.add_dependency 'bp3-core', '>= 0.1'
37
+ spec.add_dependency 'noticed', '>= 2.2'
38
38
 
39
39
  spec.add_development_dependency 'byebug'
40
- spec.add_development_dependency 'rake', '~> 13.0'
41
- spec.add_development_dependency 'rspec', '~> 3.0'
42
- spec.add_development_dependency 'rubocop', '~> 1.21'
43
- spec.add_development_dependency 'rubocop-rake', '~> 0.6'
44
- spec.add_development_dependency 'rubocop-rspec', '~> 2.25'
40
+ spec.add_development_dependency 'rake', '>= 13.0'
41
+ spec.add_development_dependency 'rspec', '>= 3.0'
42
+ spec.add_development_dependency 'rubocop', '>= 1.21'
43
+ spec.add_development_dependency 'rubocop-rake', '>= 0.6'
44
+ spec.add_development_dependency 'rubocop-rspec', '>= 2.25'
45
45
 
46
46
  # For more information and examples about making a new gem, check out our
47
47
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,69 +1,81 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CommonIncludes
4
- extend ActiveSupport::Concern
3
+ module Bp3
4
+ module Noticed
5
+ module CommonIncludes
6
+ extend ActiveSupport::Concern
5
7
 
6
- included do
7
- attr_reader :args, :kwargs
8
- end
8
+ included do
9
+ attr_reader :args, :kwargs
10
+ end
9
11
 
10
- class_methods do
11
- def global_request_state_class
12
- Bp3::Core::Rqid.global_request_state_class
13
- end
14
- end
12
+ class_methods do
13
+ def global_request_state_class
14
+ Bp3::Core::Rqid.global_request_state_class
15
+ end
16
+ end
15
17
 
16
- def global_request_state_class
17
- Bp3::Core::Rqid.global_request_state_class
18
- end
18
+ def global_request_state_class
19
+ Bp3::Core::Rqid.global_request_state_class
20
+ end
19
21
 
20
- def run(...)
21
- perform(...)
22
- end
22
+ def run(...)
23
+ perform(...)
24
+ end
23
25
 
24
- private
26
+ private
25
27
 
26
- def set_global_request_state
27
- global_request_state_class.from_hash(state)
28
- global_request_state_class.current_site ||= ensure_site
29
- end
28
+ def set_global_request_state
29
+ global_request_state_class.from_hash(state)
30
+ global_request_state_class.current_site ||= ensure_site
31
+ end
30
32
 
31
- def state
32
- run_attrs :state
33
- end
33
+ def state
34
+ run_attrs :state
35
+ end
34
36
 
35
- def ensure_site
36
- id = run_attrs(:sites_site_id) || run_attrs(:site_id)
37
- if id.present?
38
- site = site_class.find_by(id:)
39
- return site if site.present?
37
+ def ensure_site
38
+ id = run_attrs(:sites_site_id) || run_attrs(:site_id)
39
+ if id.present?
40
+ site = site_class.find_by(id:)
41
+ return site if site.present?
40
42
 
41
- message = "Unable to find site #{id}"
42
- include_log_error(key: 'prepend_state.ensure_site', message:)
43
- end
43
+ message = "Unable to find site #{id}"
44
+ include_log_error(key: 'prepend_state.ensure_site', message:)
45
+ end
44
46
 
45
- site_class.root_site || site_class.first
46
- end
47
+ site_class.root_site || site_class.first
48
+ end
47
49
 
48
- def site_class
49
- Bp3::ActionDispatch.site_class
50
- end
50
+ def include_log_error(key:, message:, details: {})
51
+ return log_error(key:, message:, details:) if respond_to?(:log_error, true)
51
52
 
52
- def check(hash_or_array, key)
53
- return nil if hash_or_array.blank?
53
+ message = "Warning: #{self.class.name}#log_info: unable to log error #{key}/#{message}/#{details}"
54
+ Rails.logger.warn { message }
55
+ nil
56
+ end
54
57
 
55
- if hash_or_array.is_a?(Array)
56
- hash_or_array.each do |obj|
57
- value = check(obj, key)
58
- return value if value
58
+ def site_class
59
+ Bp3::ActionDispatch.site_class
60
+ end
61
+
62
+ def check(hash_or_array, key)
63
+ return nil if hash_or_array.blank?
64
+
65
+ if hash_or_array.is_a?(Array)
66
+ hash_or_array.each do |obj|
67
+ value = check(obj, key)
68
+ return value if value
69
+ end
70
+ nil
71
+ elsif hash_or_array.is_a?(Hash)
72
+ hash_or_array[key.to_s] || hash_or_array[key.to_sym]
73
+ end
59
74
  end
60
- nil
61
- elsif hash_or_array.is_a?(Hash)
62
- hash_or_array[key.to_s] || hash_or_array[key.to_sym]
63
- end
64
- end
65
75
 
66
- def job_key
67
- self.class.name.underscore
76
+ def job_key
77
+ self.class.name.underscore
78
+ end
79
+ end
68
80
  end
69
81
  end
@@ -1,70 +1,66 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module JobIncludes
4
- extend ActiveSupport::Concern
3
+ module Bp3
4
+ module Noticed
5
+ module JobIncludes
6
+ extend ActiveSupport::Concern
5
7
 
6
- class_methods do
7
- def enqueue(...)
8
- new.enqueue(...)
9
- end
8
+ class_methods do
9
+ def enqueue(...)
10
+ new.enqueue(...)
11
+ end
10
12
 
11
- def run_now(...)
12
- perform_later(...) # don't use perform_now, as it won't run in the background
13
- end
13
+ def run_now(...)
14
+ perform_later(...) # don't use perform_now, as it won't run in the background
15
+ end
14
16
 
15
- def run_soon(...)
16
- set(wait: 1.minute).perform_later(...)
17
- end
17
+ def run_soon(...)
18
+ set(wait: 1.minute).perform_later(...)
19
+ end
18
20
 
19
- def run_later(...)
20
- set(wait: 1.hour).perform_later(...)
21
- end
22
- end
21
+ def run_later(...)
22
+ set(wait: 1.hour).perform_later(...)
23
+ end
24
+ end
23
25
 
24
- def enqueue(*, **)
25
- # Add state to arguments, not kwargs
26
- # kwargs['state'] = GlobalRequestState.to_hash
27
- arguments << { 'state' => global_request_state_class.to_hash }
28
- super
29
- end
26
+ def enqueue(*, **)
27
+ # Add state to arguments, not kwargs
28
+ # kwargs['state'] = GlobalRequestState.to_hash
29
+ arguments << { 'state' => global_request_state_class.to_hash }
30
+ super
31
+ end
30
32
 
31
- private
33
+ private
32
34
 
33
- def job_type
34
- 'job'
35
- end
35
+ def job_type
36
+ 'job'
37
+ end
36
38
 
37
- def include_log_error(key:, message:, details: {})
38
- return log_error(key:, message:, details:) if respond_to?(:log_error, true)
39
+ def run_attrs(key)
40
+ check(arguments, key)
41
+ end
39
42
 
40
- message = "Warning: #{self.class.name}#log_info: unable to log error #{key}/#{message}/#{details}"
41
- Rails.logger.warn { message }
42
- nil
43
- end
43
+ def check(hash_or_array, key)
44
+ return nil if hash_or_array.blank?
44
45
 
45
- def run_attrs(key)
46
- check(arguments, key)
47
- end
46
+ if hash_or_array.is_a?(Array)
47
+ hash_or_array.each do |obj|
48
+ value = check(obj, key)
49
+ return value if value
50
+ end
51
+ nil
52
+ elsif hash_or_array.is_a?(Hash)
53
+ hash_or_array[key.to_s] || hash_or_array[key.to_sym]
54
+ end
55
+ end
48
56
 
49
- def check(hash_or_array, key)
50
- return nil if hash_or_array.blank?
57
+ def site
58
+ global_request_state_class.current_site
59
+ end
51
60
 
52
- if hash_or_array.is_a?(Array)
53
- hash_or_array.each do |obj|
54
- value = check(obj, key)
55
- return value if value
61
+ def job_key
62
+ self.class.name.underscore
56
63
  end
57
- nil
58
- elsif hash_or_array.is_a?(Hash)
59
- hash_or_array[key.to_s] || hash_or_array[key.to_sym]
60
64
  end
61
65
  end
62
-
63
- def site
64
- global_request_state_class.current_site
65
- end
66
-
67
- def job_key
68
- self.class.name.underscore
69
- end
70
66
  end
@@ -1,74 +1,79 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module PrependPerform
4
- include CommonIncludes
3
+ module Bp3
4
+ module Noticed
5
+ module PrependPerform
6
+ include CommonIncludes
5
7
 
6
- # rubocop:disable Metrics/MethodLength
7
- def perform(*args, **kwargs)
8
- @args = args
9
- @kwargs = kwargs
10
- set_global_request_state
11
- details = { args:, kwargs: }
12
- log = nil
13
- args = remove_state(args)
14
- kwargs = remove_state(kwargs)
15
- begin
16
- super
17
- rescue ArgumentError
18
- super() # in case super is relying on run_attrs
19
- end
20
- disposition = 'finished'
21
- log = prepend_log_info(key: "#{job_type}.#{disposition}.#{job_key}", message: "#{disposition} job_type", details:)
22
- rescue StandardError => e
23
- disposition = 'failed'
24
- log = prepend_log_exception(e, key: "#{job_type}.#{disposition}.#{job_key}", details:)
25
- raise e # to continue the normal job flow
26
- ensure
27
- prepend_add_event(eventable: log, disposition:)
28
- global_request_state_class.clear!
29
- end
30
- # rubocop:enable Metrics/MethodLength
8
+ # rubocop:disable Metrics/MethodLength
9
+ def perform(*args, **kwargs)
10
+ @args = args
11
+ @kwargs = kwargs
12
+ set_global_request_state
13
+ details = { args:, kwargs: }
14
+ log = nil
15
+ args = remove_state(args)
16
+ kwargs = remove_state(kwargs)
17
+ begin
18
+ super
19
+ rescue ArgumentError
20
+ super() # in case super is relying on run_attrs
21
+ end
22
+ disposition = 'finished'
23
+ log = prepend_log_info(key: "#{job_type}.#{disposition}.#{job_key}", message: "#{disposition} job_type",
24
+ details:)
25
+ rescue StandardError => e
26
+ disposition = 'failed'
27
+ log = prepend_log_exception(e, key: "#{job_type}.#{disposition}.#{job_key}", details:)
28
+ raise e # to continue the normal job flow
29
+ ensure
30
+ prepend_add_event(eventable: log, disposition:)
31
+ global_request_state_class.clear!
32
+ end
33
+ # rubocop:enable Metrics/MethodLength
31
34
 
32
- private
35
+ private
33
36
 
34
- def remove_state(obj)
35
- if obj.is_a?(Hash)
36
- obj.except(:state, 'state')
37
- elsif obj.is_a?(Array)
38
- obj.reject { |e| e.is_a?(Hash) && (e.key?(:state) || e.key?('state')) }
39
- else
40
- obj
41
- end
42
- end
37
+ def remove_state(obj)
38
+ if obj.is_a?(Hash)
39
+ obj.except(:state, 'state')
40
+ elsif obj.is_a?(Array)
41
+ obj.reject { |e| e.is_a?(Hash) && (e.key?(:state) || e.key?('state')) }
42
+ else
43
+ obj
44
+ end
45
+ end
43
46
 
44
- # override in subclasses if needed
45
- def prepend_add_event(eventable:, disposition:)
46
- return add_event(eventable:, disposition:) if respond_to?(:add_event, true)
47
+ # override in subclasses if needed
48
+ def prepend_add_event(eventable:, disposition:)
49
+ return add_event(eventable:, disposition:) if respond_to?(:add_event, true)
47
50
 
48
- creator = global_request_state_class.current_login || global_request_state_class.current_visitor
49
- who = creator.nil? ? 'nil' : "#{creator.class.name}/#{creator.id}"
50
- did = disposition
51
- what = eventable.nil? ? 'nil' : "#{eventable.class.name}/#{eventable.id}"
52
- message = "Warning: #{self.class.name}#add_event: unable to add event #{who}/#{did}/#{what}"
53
- Rails.logger.warn { message }
54
- nil
55
- end
51
+ creator = global_request_state_class.current_login || global_request_state_class.current_visitor
52
+ who = creator.nil? ? 'nil' : "#{creator.class.name}/#{creator.id}"
53
+ did = disposition
54
+ what = eventable.nil? ? 'nil' : "#{eventable.class.name}/#{eventable.id}"
55
+ message = "Warning: #{self.class.name}#add_event: unable to add event #{who}/#{did}/#{what}"
56
+ Rails.logger.warn { message }
57
+ nil
58
+ end
56
59
 
57
- # override in subclasses if needed
58
- def prepend_log_info(key:, message:, details: {})
59
- return log_info(key:, message:, details:) if respond_to?(:log_info, true)
60
+ # override in subclasses if needed
61
+ def prepend_log_info(key:, message:, details: {})
62
+ return log_info(key:, message:, details:) if respond_to?(:log_info, true)
60
63
 
61
- message = "Warning: #{self.class.name}#log_info: unable to log info #{key}/#{message}/#{details}"
62
- Rails.logger.warn { message }
63
- nil
64
- end
64
+ message = "Warning: #{self.class.name}#log_info: unable to log info #{key}/#{message}/#{details}"
65
+ Rails.logger.warn { message }
66
+ nil
67
+ end
65
68
 
66
- # override in subclasses if needed
67
- def prepend_log_exception(exception, key:, details: {})
68
- return log_exception(exception, key:, details:) if respond_to?(:log_exception, true)
69
+ # override in subclasses if needed
70
+ def prepend_log_exception(exception, key:, details: {})
71
+ return log_exception(exception, key:, details:) if respond_to?(:log_exception, true)
69
72
 
70
- message = "Warning: #{self.class.name}#log_exception: unable to log exception #{exception}/#{key}/#{details}"
71
- Rails.logger.warn { message }
72
- nil
73
+ message = "Warning: #{self.class.name}#log_exception: unable to log exception #{exception}/#{key}/#{details}"
74
+ Rails.logger.warn { message }
75
+ nil
76
+ end
77
+ end
73
78
  end
74
79
  end
@@ -1,61 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module QueIncludes
4
- extend ActiveSupport::Concern
5
-
6
- class_methods do
7
- def enqueue(*args, **kwargs)
8
- if ENV.fetch('BP_DEBUG', nil) =~ /quejobs/
9
- Rails.logger.warn { "enqueue with #{args} and #{kwargs}" }
10
- Rails.logger.warn { global_request_state_class.to_hash }
11
- end
12
- kwargs['state'] = global_request_state_class.to_hash
13
- super
14
- end
3
+ module Bp3
4
+ module Noticed
5
+ module QueIncludes
6
+ extend ActiveSupport::Concern
15
7
 
16
- def perform_now(...)
17
- run(...)
18
- end
8
+ class_methods do
9
+ def enqueue(*args, **kwargs)
10
+ if ENV.fetch('BP_DEBUG', nil) =~ /quejobs/
11
+ Rails.logger.warn { "enqueue with #{args} and #{kwargs}" }
12
+ Rails.logger.warn { global_request_state_class.to_hash }
13
+ end
14
+ kwargs['state'] = global_request_state_class.to_hash
15
+ super
16
+ end
19
17
 
20
- def run_now(...)
21
- enqueue(...) # don't use perform_now, as it won't run in the background
22
- end
18
+ def perform_now(...)
19
+ run(...)
20
+ end
23
21
 
24
- def run_soon(*, **kwargs)
25
- kwargs[:job_options] ||= {}
26
- kwargs[:job_options][:run_at] ||= 1.minute.from_now
27
- enqueue(*, **kwargs)
28
- end
22
+ def run_now(...)
23
+ enqueue(...) # don't use perform_now, as it won't run in the background
24
+ end
29
25
 
30
- def run_later(*, **kwargs)
31
- kwargs[:job_options] ||= {}
32
- kwargs[:job_options][:run_at] ||= 1.hour.from_now
33
- enqueue(*, **kwargs)
34
- end
35
- end
26
+ def run_soon(*, **kwargs)
27
+ kwargs[:job_options] ||= {}
28
+ kwargs[:job_options][:run_at] ||= 1.minute.from_now
29
+ enqueue(*, **kwargs)
30
+ end
36
31
 
37
- # set the log level based on the job duration. elapsed is in seconds
38
- def log_level(elapsed)
39
- if elapsed > 5
40
- :warn
41
- elsif elapsed > 1
42
- :info
43
- else
44
- false # no need to log
45
- end
46
- end
32
+ def run_later(*, **kwargs)
33
+ kwargs[:job_options] ||= {}
34
+ kwargs[:job_options][:run_at] ||= 1.hour.from_now
35
+ enqueue(*, **kwargs)
36
+ end
37
+ end
47
38
 
48
- private
39
+ # set the log level based on the job duration. elapsed is in seconds
40
+ def log_level(elapsed)
41
+ if elapsed > 5
42
+ :warn
43
+ elsif elapsed > 1
44
+ :info
45
+ else
46
+ false # no need to log
47
+ end
48
+ end
49
49
 
50
- def job_type
51
- 'que'
52
- end
50
+ private
53
51
 
54
- def run_attrs(key)
55
- check(que_attrs, key) ||
56
- check(que_attrs[:args], key) ||
57
- check(que_attrs[:kwargs], key) ||
58
- check(args, key) ||
59
- check(kwargs, key)
52
+ def job_type
53
+ 'que'
54
+ end
55
+
56
+ def run_attrs(key)
57
+ check(que_attrs, key) ||
58
+ check(que_attrs[:args], key) ||
59
+ check(que_attrs[:kwargs], key) ||
60
+ check(args, key) ||
61
+ check(kwargs, key)
62
+ end
63
+ end
60
64
  end
61
65
  end
@@ -31,9 +31,9 @@ module Bp3
31
31
  private
32
32
 
33
33
  def global_scope
34
- { # TODO: determine why only workspace needs to be provided to make it work
35
- # sites_site_id: global_site_id,
36
- # tenant_id: global_tenant_id,
34
+ {
35
+ sites_site_id: global_site_id,
36
+ tenant_id: global_tenant_id,
37
37
  workspaces_workspace_id: global_workspace_id
38
38
  }
39
39
  end
@@ -67,19 +67,19 @@ module Bp3
67
67
 
68
68
  class ApplicationJob
69
69
  # include Que::ActiveJob::JobExtensions
70
- include CommonIncludes
71
- include JobIncludes
70
+ include Bp3::Noticed::CommonIncludes
71
+ include Bp3::Noticed::JobIncludes
72
72
 
73
73
  # Automatically retry jobs that encountered a deadlock
74
74
  retry_on ActiveRecord::Deadlocked
75
75
  end
76
76
 
77
77
  class EventJob
78
- prepend PrependPerform
78
+ prepend Bp3::Noticed::PrependPerform
79
79
  end
80
80
 
81
81
  class DeliveryMethod
82
- prepend PrependPerform
82
+ prepend Bp3::Noticed::PrependPerform
83
83
  end
84
84
  end
85
85
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bp3
4
4
  module Noticed
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bp3-noticed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wim den Braven
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-04 00:00:00.000000000 Z
11
+ date: 2024-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 7.1.2
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '8'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 7.1.2
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '8'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: bp3-action_dispatch
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -37,9 +31,6 @@ dependencies:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
33
  version: '0.1'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '1'
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +38,6 @@ dependencies:
47
38
  - - ">="
48
39
  - !ruby/object:Gem::Version
49
40
  version: '0.1'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '1'
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: bp3-core
55
43
  requirement: !ruby/object:Gem::Requirement
@@ -57,9 +45,6 @@ dependencies:
57
45
  - - ">="
58
46
  - !ruby/object:Gem::Version
59
47
  version: '0.1'
60
- - - "<"
61
- - !ruby/object:Gem::Version
62
- version: '1'
63
48
  type: :runtime
64
49
  prerelease: false
65
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,21 +52,18 @@ dependencies:
67
52
  - - ">="
68
53
  - !ruby/object:Gem::Version
69
54
  version: '0.1'
70
- - - "<"
71
- - !ruby/object:Gem::Version
72
- version: '1'
73
55
  - !ruby/object:Gem::Dependency
74
56
  name: noticed
75
57
  requirement: !ruby/object:Gem::Requirement
76
58
  requirements:
77
- - - "~>"
59
+ - - ">="
78
60
  - !ruby/object:Gem::Version
79
61
  version: '2.2'
80
62
  type: :runtime
81
63
  prerelease: false
82
64
  version_requirements: !ruby/object:Gem::Requirement
83
65
  requirements:
84
- - - "~>"
66
+ - - ">="
85
67
  - !ruby/object:Gem::Version
86
68
  version: '2.2'
87
69
  - !ruby/object:Gem::Dependency
@@ -102,70 +84,70 @@ dependencies:
102
84
  name: rake
103
85
  requirement: !ruby/object:Gem::Requirement
104
86
  requirements:
105
- - - "~>"
87
+ - - ">="
106
88
  - !ruby/object:Gem::Version
107
89
  version: '13.0'
108
90
  type: :development
109
91
  prerelease: false
110
92
  version_requirements: !ruby/object:Gem::Requirement
111
93
  requirements:
112
- - - "~>"
94
+ - - ">="
113
95
  - !ruby/object:Gem::Version
114
96
  version: '13.0'
115
97
  - !ruby/object:Gem::Dependency
116
98
  name: rspec
117
99
  requirement: !ruby/object:Gem::Requirement
118
100
  requirements:
119
- - - "~>"
101
+ - - ">="
120
102
  - !ruby/object:Gem::Version
121
103
  version: '3.0'
122
104
  type: :development
123
105
  prerelease: false
124
106
  version_requirements: !ruby/object:Gem::Requirement
125
107
  requirements:
126
- - - "~>"
108
+ - - ">="
127
109
  - !ruby/object:Gem::Version
128
110
  version: '3.0'
129
111
  - !ruby/object:Gem::Dependency
130
112
  name: rubocop
131
113
  requirement: !ruby/object:Gem::Requirement
132
114
  requirements:
133
- - - "~>"
115
+ - - ">="
134
116
  - !ruby/object:Gem::Version
135
117
  version: '1.21'
136
118
  type: :development
137
119
  prerelease: false
138
120
  version_requirements: !ruby/object:Gem::Requirement
139
121
  requirements:
140
- - - "~>"
122
+ - - ">="
141
123
  - !ruby/object:Gem::Version
142
124
  version: '1.21'
143
125
  - !ruby/object:Gem::Dependency
144
126
  name: rubocop-rake
145
127
  requirement: !ruby/object:Gem::Requirement
146
128
  requirements:
147
- - - "~>"
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0.6'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
135
  requirements:
154
- - - "~>"
136
+ - - ">="
155
137
  - !ruby/object:Gem::Version
156
138
  version: '0.6'
157
139
  - !ruby/object:Gem::Dependency
158
140
  name: rubocop-rspec
159
141
  requirement: !ruby/object:Gem::Requirement
160
142
  requirements:
161
- - - "~>"
143
+ - - ">="
162
144
  - !ruby/object:Gem::Version
163
145
  version: '2.25'
164
146
  type: :development
165
147
  prerelease: false
166
148
  version_requirements: !ruby/object:Gem::Requirement
167
149
  requirements:
168
- - - "~>"
150
+ - - ">="
169
151
  - !ruby/object:Gem::Version
170
152
  version: '2.25'
171
153
  description:
@@ -219,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
201
  - !ruby/object:Gem::Version
220
202
  version: '0'
221
203
  requirements: []
222
- rubygems_version: 3.5.11
204
+ rubygems_version: 3.5.23
223
205
  signing_key:
224
206
  specification_version: 4
225
207
  summary: bp3-noticed adapts noticed for BP3 (persuavis/black_phoebe_3).