getaround_utils 0.2.36 → 0.2.38

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: 064e3085ba98ef6504ab873ed64d0a1b2be6a36a263cddcaf1f1691e2b56c2f8
4
- data.tar.gz: fe266e01cf07f15d17a637d8727fbc5d567de8abcb32e0af003c7b4cc1af57f2
3
+ metadata.gz: 916e4ff4d5a7e304388761fa589ed6d5cf6607415323db868832e098176898da
4
+ data.tar.gz: 909e21f9dc77e1da802084938478197acf05f4020922873cfe4867d2bcc727e4
5
5
  SHA512:
6
- metadata.gz: bcb6d3d48b4a88cf192e8b5c24f3f5835a6e9a80ee2d8aa2525a2be8f460d3ba2b300a3baba71d677987474c528cc717217265fca2da92d60e59fb4319a4ffba
7
- data.tar.gz: 489717d5799d010200fc7eb9dfbf03d36b69c911e3238c61b39c20b7332ada832257c1e1e7e7ea5e4ce10743b91afefc958e6cac89e806dfc0eb92354b4e9374
6
+ metadata.gz: 9172dc32867f096bebd47bcad9cefaf38a02085917d91af8254d942496ab159a1b9f12aa60692f8e0c84dd370e9f2633a85f3314589d8ef60abc751137a7da9e
7
+ data.tar.gz: a0c67681e628904bf1b36b4f1fe726bd8a33951b595e301d5da55de4a187d02714721d2952775688f4cf94082fa2118b2ac49302b0f63985debfb04fa3a54f53
data/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ ## [0.2.38] 2025-11-19
2
+
3
+ ### Added
4
+
5
+ - `GetaroundUtils::Utils::HandleError` ([#433](https://github.com/drivy/backend-configs/pull/433))
6
+ ```ruby
7
+ module MyApp::Errors
8
+ def self.handle(error, **)
9
+ GetaroundUtils::Utils::HandleError.notify_of(error, **) do |report|
10
+ report.grouping_hash = 'hello-world' # Bugsnag example
11
+ end
12
+ end
13
+ end
14
+ ```
15
+ - `GetaroundUtils::Utils::ConfigUrl` ([#432](https://github.com/drivy/backend-configs/pull/432))
16
+ ```ruby
17
+ # FOO_URL="redis://foo@localhost:666/10"
18
+ # FOO_PASSWORD="added-pwd"
19
+ # BAR_URL="whatever://bar:used-pwd@localhost:666/42"
20
+ # BAR_PASSWORD="not-used-pwd"
21
+ # ENV_TEST_NUMBER=1
22
+
23
+ GetaroundUtils::Utils::ConfigUrl
24
+ .from_env('FOO')
25
+ .tap { |uri| uri.path += ENV['ENV_TEST_NUMBER'] }
26
+ # => <URI::Generic redis://foo:added-pwd@localhost:666/101>
27
+ GetaroundUtils::Utils::ConfigUrl.from_env('BAR').to_s
28
+ # => "whatever://bar:used-pwd@localhost:666/42"
29
+ GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN')
30
+ # => KeyError: key not found "UNKNOWN_URL"
31
+ GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN', 'mysql://localhost/test')
32
+ # => <URI::Generic mysql://localhost/test>
33
+ GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN') { GetaroundUtils::Utils::ConfigUrl.from_env('BAZ') }
34
+ # => KeyError: key not found "BAZ_URL"
35
+ ```
data/Gemfile.lock CHANGED
@@ -1,84 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getaround_utils (0.2.36)
4
+ getaround_utils (0.2.38)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (7.0.8.7)
10
- actionpack (= 7.0.8.7)
11
- activesupport (= 7.0.8.7)
9
+ actioncable (7.2.2.1)
10
+ actionpack (= 7.2.2.1)
11
+ activesupport (= 7.2.2.1)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (7.0.8.7)
15
- actionpack (= 7.0.8.7)
16
- activejob (= 7.0.8.7)
17
- activerecord (= 7.0.8.7)
18
- activestorage (= 7.0.8.7)
19
- activesupport (= 7.0.8.7)
20
- mail (>= 2.7.1)
21
- net-imap
22
- net-pop
23
- net-smtp
24
- actionmailer (7.0.8.7)
25
- actionpack (= 7.0.8.7)
26
- actionview (= 7.0.8.7)
27
- activejob (= 7.0.8.7)
28
- activesupport (= 7.0.8.7)
29
- mail (~> 2.5, >= 2.5.4)
30
- net-imap
31
- net-pop
32
- net-smtp
33
- rails-dom-testing (~> 2.0)
34
- actionpack (7.0.8.7)
35
- actionview (= 7.0.8.7)
36
- activesupport (= 7.0.8.7)
37
- rack (~> 2.0, >= 2.2.4)
14
+ zeitwerk (~> 2.6)
15
+ actionmailbox (7.2.2.1)
16
+ actionpack (= 7.2.2.1)
17
+ activejob (= 7.2.2.1)
18
+ activerecord (= 7.2.2.1)
19
+ activestorage (= 7.2.2.1)
20
+ activesupport (= 7.2.2.1)
21
+ mail (>= 2.8.0)
22
+ actionmailer (7.2.2.1)
23
+ actionpack (= 7.2.2.1)
24
+ actionview (= 7.2.2.1)
25
+ activejob (= 7.2.2.1)
26
+ activesupport (= 7.2.2.1)
27
+ mail (>= 2.8.0)
28
+ rails-dom-testing (~> 2.2)
29
+ actionpack (7.2.2.1)
30
+ actionview (= 7.2.2.1)
31
+ activesupport (= 7.2.2.1)
32
+ nokogiri (>= 1.8.5)
33
+ racc
34
+ rack (>= 2.2.4, < 3.2)
35
+ rack-session (>= 1.0.1)
38
36
  rack-test (>= 0.6.3)
39
- rails-dom-testing (~> 2.0)
40
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
- actiontext (7.0.8.7)
42
- actionpack (= 7.0.8.7)
43
- activerecord (= 7.0.8.7)
44
- activestorage (= 7.0.8.7)
45
- activesupport (= 7.0.8.7)
37
+ rails-dom-testing (~> 2.2)
38
+ rails-html-sanitizer (~> 1.6)
39
+ useragent (~> 0.16)
40
+ actiontext (7.2.2.1)
41
+ actionpack (= 7.2.2.1)
42
+ activerecord (= 7.2.2.1)
43
+ activestorage (= 7.2.2.1)
44
+ activesupport (= 7.2.2.1)
46
45
  globalid (>= 0.6.0)
47
46
  nokogiri (>= 1.8.5)
48
- actionview (7.0.8.7)
49
- activesupport (= 7.0.8.7)
47
+ actionview (7.2.2.1)
48
+ activesupport (= 7.2.2.1)
50
49
  builder (~> 3.1)
51
- erubi (~> 1.4)
52
- rails-dom-testing (~> 2.0)
53
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
- activejob (7.0.8.7)
55
- activesupport (= 7.0.8.7)
50
+ erubi (~> 1.11)
51
+ rails-dom-testing (~> 2.2)
52
+ rails-html-sanitizer (~> 1.6)
53
+ activejob (7.2.2.1)
54
+ activesupport (= 7.2.2.1)
56
55
  globalid (>= 0.3.6)
57
- activemodel (7.0.8.7)
58
- activesupport (= 7.0.8.7)
59
- activerecord (7.0.8.7)
60
- activemodel (= 7.0.8.7)
61
- activesupport (= 7.0.8.7)
62
- activestorage (7.0.8.7)
63
- actionpack (= 7.0.8.7)
64
- activejob (= 7.0.8.7)
65
- activerecord (= 7.0.8.7)
66
- activesupport (= 7.0.8.7)
56
+ activemodel (7.2.2.1)
57
+ activesupport (= 7.2.2.1)
58
+ activerecord (7.2.2.1)
59
+ activemodel (= 7.2.2.1)
60
+ activesupport (= 7.2.2.1)
61
+ timeout (>= 0.4.0)
62
+ activestorage (7.2.2.1)
63
+ actionpack (= 7.2.2.1)
64
+ activejob (= 7.2.2.1)
65
+ activerecord (= 7.2.2.1)
66
+ activesupport (= 7.2.2.1)
67
67
  marcel (~> 1.0)
68
- mini_mime (>= 1.1.0)
69
- activesupport (7.0.8.7)
70
- concurrent-ruby (~> 1.0, >= 1.0.2)
68
+ activesupport (7.2.2.1)
69
+ base64
70
+ benchmark (>= 0.3)
71
+ bigdecimal
72
+ concurrent-ruby (~> 1.0, >= 1.3.1)
73
+ connection_pool (>= 2.2.5)
74
+ drb
71
75
  i18n (>= 1.6, < 2)
76
+ logger (>= 1.4.2)
72
77
  minitest (>= 5.1)
73
- tzinfo (~> 2.0)
78
+ securerandom (>= 0.3)
79
+ tzinfo (~> 2.0, >= 2.0.5)
74
80
  addressable (2.8.7)
75
81
  public_suffix (>= 2.0.2, < 7.0)
76
82
  ast (2.4.3)
77
- base64 (0.2.0)
78
- bigdecimal (3.1.9)
79
- builder (3.2.4)
80
- concurrent-ruby (1.2.2)
81
- connection_pool (2.4.0)
83
+ base64 (0.3.0)
84
+ benchmark (0.4.1)
85
+ bigdecimal (3.2.2)
86
+ builder (3.3.0)
87
+ concurrent-ruby (1.3.5)
88
+ connection_pool (2.5.3)
82
89
  crack (1.0.0)
83
90
  bigdecimal
84
91
  rexml
@@ -86,8 +93,9 @@ GEM
86
93
  date (3.4.1)
87
94
  diff-lcs (1.6.2)
88
95
  dotenv (3.1.8)
89
- erb (5.0.1)
90
- erubi (1.12.0)
96
+ drb (2.2.3)
97
+ erb (5.0.2)
98
+ erubi (1.13.1)
91
99
  getaround-rubocop (0.2.11)
92
100
  relaxed-rubocop (~> 2.5)
93
101
  rubocop (~> 1.0)
@@ -97,22 +105,23 @@ GEM
97
105
  globalid (1.2.1)
98
106
  activesupport (>= 6.1)
99
107
  hashdiff (1.2.0)
100
- i18n (1.14.1)
108
+ i18n (1.14.7)
101
109
  concurrent-ruby (~> 1.0)
102
- io-console (0.8.0)
110
+ io-console (0.8.1)
103
111
  irb (1.15.2)
104
112
  pp (>= 0.6.0)
105
113
  rdoc (>= 4.0.0)
106
114
  reline (>= 0.4.2)
107
- json (2.12.2)
115
+ json (2.13.1)
108
116
  language_server-protocol (3.17.0.5)
109
117
  lint_roller (1.1.0)
118
+ logger (1.7.0)
110
119
  lograge (0.14.0)
111
120
  actionpack (>= 4)
112
121
  activesupport (>= 4)
113
122
  railties (>= 4)
114
123
  request_store (~> 1.0)
115
- loofah (2.21.3)
124
+ loofah (2.24.1)
116
125
  crass (~> 1.0.2)
117
126
  nokogiri (>= 1.12.0)
118
127
  mail (2.8.1)
@@ -121,10 +130,9 @@ GEM
121
130
  net-pop
122
131
  net-smtp
123
132
  marcel (1.0.4)
124
- method_source (1.0.0)
125
133
  mini_mime (1.1.5)
126
- mini_portile2 (2.8.4)
127
- minitest (5.19.0)
134
+ mini_portile2 (2.8.9)
135
+ minitest (5.25.5)
128
136
  net-imap (0.5.8)
129
137
  date
130
138
  net-protocol
@@ -135,14 +143,14 @@ GEM
135
143
  net-smtp (0.5.1)
136
144
  net-protocol
137
145
  nio4r (2.7.4)
138
- nokogiri (1.15.3)
146
+ nokogiri (1.18.9)
139
147
  mini_portile2 (~> 2.8.2)
140
148
  racc (~> 1.4)
141
149
  oj (3.11.3)
142
150
  ougai (2.0.0)
143
151
  oj (~> 3.10)
144
152
  parallel (1.27.0)
145
- parser (3.3.8.0)
153
+ parser (3.3.9.0)
146
154
  ast (~> 2.4.1)
147
155
  racc
148
156
  pp (0.6.2)
@@ -153,48 +161,54 @@ GEM
153
161
  date
154
162
  stringio
155
163
  public_suffix (6.0.2)
156
- racc (1.7.1)
157
- rack (2.2.7)
158
- rack-test (2.1.0)
164
+ racc (1.8.1)
165
+ rack (3.1.16)
166
+ rack-session (2.1.1)
167
+ base64 (>= 0.1.0)
168
+ rack (>= 3.0.0)
169
+ rack-test (2.2.0)
159
170
  rack (>= 1.3)
160
- rails (7.0.8.7)
161
- actioncable (= 7.0.8.7)
162
- actionmailbox (= 7.0.8.7)
163
- actionmailer (= 7.0.8.7)
164
- actionpack (= 7.0.8.7)
165
- actiontext (= 7.0.8.7)
166
- actionview (= 7.0.8.7)
167
- activejob (= 7.0.8.7)
168
- activemodel (= 7.0.8.7)
169
- activerecord (= 7.0.8.7)
170
- activestorage (= 7.0.8.7)
171
- activesupport (= 7.0.8.7)
171
+ rackup (2.2.1)
172
+ rack (>= 3)
173
+ rails (7.2.2.1)
174
+ actioncable (= 7.2.2.1)
175
+ actionmailbox (= 7.2.2.1)
176
+ actionmailer (= 7.2.2.1)
177
+ actionpack (= 7.2.2.1)
178
+ actiontext (= 7.2.2.1)
179
+ actionview (= 7.2.2.1)
180
+ activejob (= 7.2.2.1)
181
+ activemodel (= 7.2.2.1)
182
+ activerecord (= 7.2.2.1)
183
+ activestorage (= 7.2.2.1)
184
+ activesupport (= 7.2.2.1)
172
185
  bundler (>= 1.15.0)
173
- railties (= 7.0.8.7)
174
- rails-dom-testing (2.1.1)
186
+ railties (= 7.2.2.1)
187
+ rails-dom-testing (2.3.0)
175
188
  activesupport (>= 5.0.0)
176
189
  minitest
177
190
  nokogiri (>= 1.6)
178
- rails-html-sanitizer (1.6.0)
191
+ rails-html-sanitizer (1.6.2)
179
192
  loofah (~> 2.21)
180
- nokogiri (~> 1.14)
181
- railties (7.0.8.7)
182
- actionpack (= 7.0.8.7)
183
- activesupport (= 7.0.8.7)
184
- method_source
193
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
194
+ railties (7.2.2.1)
195
+ actionpack (= 7.2.2.1)
196
+ activesupport (= 7.2.2.1)
197
+ irb (~> 1.13)
198
+ rackup (>= 1.0.0)
185
199
  rake (>= 12.2)
186
- thor (~> 1.0)
187
- zeitwerk (~> 2.5)
200
+ thor (~> 1.0, >= 1.2.2)
201
+ zeitwerk (~> 2.6)
188
202
  rainbow (3.1.1)
189
- rake (13.2.1)
190
- rdoc (6.14.0)
203
+ rake (13.3.0)
204
+ rdoc (6.14.2)
191
205
  erb
192
206
  psych (>= 4.0.0)
193
207
  redis-client (0.14.1)
194
208
  connection_pool
195
209
  regexp_parser (2.10.0)
196
210
  relaxed-rubocop (2.5)
197
- reline (0.6.1)
211
+ reline (0.6.2)
198
212
  io-console (~> 0.5)
199
213
  request_store (1.7.0)
200
214
  rack (>= 1.4)
@@ -203,7 +217,7 @@ GEM
203
217
  rspec-core (~> 3.13.0)
204
218
  rspec-expectations (~> 3.13.0)
205
219
  rspec-mocks (~> 3.13.0)
206
- rspec-core (3.13.4)
220
+ rspec-core (3.13.5)
207
221
  rspec-support (~> 3.13.0)
208
222
  rspec-expectations (3.13.5)
209
223
  diff-lcs (>= 1.2.0, < 2.0)
@@ -211,16 +225,16 @@ GEM
211
225
  rspec-mocks (3.13.5)
212
226
  diff-lcs (>= 1.2.0, < 2.0)
213
227
  rspec-support (~> 3.13.0)
214
- rspec-rails (7.1.1)
215
- actionpack (>= 7.0)
216
- activesupport (>= 7.0)
217
- railties (>= 7.0)
228
+ rspec-rails (8.0.1)
229
+ actionpack (>= 7.2)
230
+ activesupport (>= 7.2)
231
+ railties (>= 7.2)
218
232
  rspec-core (~> 3.13)
219
233
  rspec-expectations (~> 3.13)
220
234
  rspec-mocks (~> 3.13)
221
235
  rspec-support (~> 3.13)
222
236
  rspec-support (3.13.4)
223
- rubocop (1.75.7)
237
+ rubocop (1.79.0)
224
238
  json (~> 2.3)
225
239
  language_server-protocol (~> 3.17.0.2)
226
240
  lint_roller (~> 1.1.0)
@@ -228,10 +242,11 @@ GEM
228
242
  parser (>= 3.3.0.2)
229
243
  rainbow (>= 2.2.2, < 4.0)
230
244
  regexp_parser (>= 2.9.3, < 3.0)
231
- rubocop-ast (>= 1.44.0, < 2.0)
245
+ rubocop-ast (>= 1.46.0, < 2.0)
232
246
  ruby-progressbar (~> 1.7)
247
+ tsort (>= 0.2.0)
233
248
  unicode-display_width (>= 2.4.0, < 4.0)
234
- rubocop-ast (1.44.1)
249
+ rubocop-ast (1.46.0)
235
250
  parser (>= 3.3.7.2)
236
251
  prism (~> 1.4)
237
252
  rubocop-performance (1.25.0)
@@ -248,19 +263,22 @@ GEM
248
263
  lint_roller (~> 1.1)
249
264
  rubocop (~> 1.72, >= 1.72.1)
250
265
  ruby-progressbar (1.13.0)
266
+ securerandom (0.4.1)
251
267
  sidekiq (7.0.9)
252
268
  concurrent-ruby (< 2)
253
269
  connection_pool (>= 2.3.0)
254
270
  rack (>= 2.2.4)
255
271
  redis-client (>= 0.11.0)
256
272
  stringio (3.1.7)
257
- thor (1.2.2)
273
+ thor (1.4.0)
258
274
  timeout (0.4.3)
275
+ tsort (0.2.0)
259
276
  tzinfo (2.0.6)
260
277
  concurrent-ruby (~> 1.0)
261
278
  unicode-display_width (3.1.4)
262
279
  unicode-emoji (~> 4.0, >= 4.0.4)
263
280
  unicode-emoji (4.0.4)
281
+ useragent (0.16.11)
264
282
  webmock (3.25.1)
265
283
  addressable (>= 2.8.0)
266
284
  crack (>= 0.3.2)
@@ -269,7 +287,7 @@ GEM
269
287
  base64
270
288
  websocket-extensions (>= 0.1.0)
271
289
  websocket-extensions (0.1.5)
272
- zeitwerk (2.6.9)
290
+ zeitwerk (2.7.3)
273
291
 
274
292
  PLATFORMS
275
293
  ruby
@@ -285,8 +303,8 @@ DEPENDENCIES
285
303
  rails (~> 7.0)
286
304
  rake (~> 13.2)
287
305
  rspec (~> 3.13)
288
- rspec-rails (~> 7.1)
289
- rubocop (~> 1.75.0)
306
+ rspec-rails (~> 8.0)
307
+ rubocop (~> 1.79.0)
290
308
  sidekiq (> 7.0)
291
309
  webmock (~> 3.25)
292
310
 
data/README.md CHANGED
@@ -49,6 +49,44 @@ require 'getaround_utils/railties/ougai'
49
49
 
50
50
  For more details, [read the spec](spec/getaround_utils/railties/ougai_spec.rb)
51
51
 
52
+ ## Engines
53
+
54
+ ### GetaroundUtils::Engine::Health
55
+
56
+ - Exposes the currently deployed release version:
57
+ - `GetaroundUtils::Engine::Health.release_version`
58
+ - Exposes the currently deployed commit SHA1:
59
+ - `GetaroundUtils::Engine::Health.commit_sha1`
60
+ - Provides a `Rack` application to expose "health" endpoints (used by Shipit)
61
+ - `GET /release_version`
62
+ - `GET /commit_sha1`
63
+ - `GET /migration_status`
64
+
65
+ The engine can be mounted in a Rails application:
66
+ ```ruby
67
+ # config/routes.rb
68
+ require 'getaround_utils/engines/health'
69
+
70
+ Rails.application.routes.draw do
71
+ mount GetaroundUtils::Engines::Health.engine, at: '/health'
72
+ # ...
73
+ end
74
+ ```
75
+
76
+ Or in a simple `Rack` application:
77
+ ```ruby
78
+ # config.ru
79
+ require 'getaround_utils/engines/health'
80
+
81
+ run Rack::Builder.new {
82
+ map '/health' do
83
+ run GetaroundUtils::Engines::Health.engine
84
+ end
85
+ # ...
86
+ }
87
+ ```
88
+ *This will generates `/health/release_version`, `/health/commit_sha1` and `/health/migration_status` endpoints*
89
+
52
90
  ## Mixins
53
91
 
54
92
  ### GetaroundUtils::Mixins::Loggable
@@ -100,11 +138,62 @@ For more details, [read the spec](spec/getaround_utils/mixins/loggable_spec.rb#L
100
138
 
101
139
  ## Misc
102
140
 
103
- ### GetaroundUtils::LogFormatters::DeepKeyValue
141
+ ### GetaroundUtils::Utils::DeepKeyValue
104
142
 
105
143
  This log formatter will serialize an object of any depth into a key-value string.
106
144
  It supports basic scalars (ie: `Hash`,`Array`,`Numeric`,`String`) and will call "#inspect" for any other type.
107
145
 
108
- For more details, [read the spec](spec/getaround_utils/log_formatters/deep_key_value_spec.rb)
146
+ For more details, [read the spec](spec/getaround_utils/utils/deep_key_value_spec.rb)
147
+
148
+ ### GetaroundUtils::Utils::ConfigUrl
149
+
150
+ This helper allows to manage configuration urls with password extracted in a dedicated variable.
109
151
 
152
+ It uses `*_URL` variable and tries to compute `*_PASSWORD` inside the parsed url.
153
+
154
+ ```ruby
155
+ # FOO_URL="redis://foo@localhost:666/10"
156
+ # FOO_PASSWORD="added-pwd"
157
+ # BAR_URL="whatever://bar:used-pwd@localhost:666/42"
158
+ # BAR_PASSWORD="not-used-pwd"
159
+ # ENV_TEST_NUMBER=1
160
+
161
+ GetaroundUtils::Utils::ConfigUrl
162
+ .from_env('FOO')
163
+ .tap { |uri| uri.path += ENV['ENV_TEST_NUMBER'] }
164
+ # => <URI::Generic redis://foo:added-pwd@localhost:666/101>
165
+ GetaroundUtils::Utils::ConfigUrl.from_env('BAR').to_s
166
+ # => "whatever://bar:used-pwd@localhost:666/42"
167
+ GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN')
168
+ # => KeyError: key not found "UNKNOWN_URL"
169
+ GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN', 'mysql://localhost/test')
170
+ # => <URI::Generic mysql://localhost/test>
171
+ GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN') { GetaroundUtils::Utils::ConfigUrl.from_env('BAZ') }
172
+ # => KeyError: key not found "BAZ_URL"
173
+ ```
174
+
175
+ For more details, [read the spec](spec/getaround_utils/utils/config_url_spec.rb)
176
+
177
+ ### GetaroundUtils::Utils::HandleError
178
+
179
+ Allows to easily notify our error provider by providing context metadata as keyword arguments.
180
+
181
+ *If there is no error provider defined, a `debug` message will be logged using `GetaroundUtils::Mixins::Loggable`*
182
+
183
+ ```ruby
184
+ module MyApp::Errors
185
+ def self.handle(error, **)
186
+ GetaroundUtils::Utils::HandleError.notify_of(error, **) do |event|
187
+ event.grouping_hash = 'hello-world' # Bugsnag example
188
+ end
189
+ end
190
+ end
191
+
192
+ begin
193
+ raise 'woopsie'
194
+ rescue StandardError => e
195
+ MyApp::Errors.handle(e, foo: 'bar', baz: 42)
196
+ end
197
+ ```
110
198
 
199
+ For more details, [read the spec](spec/getaround_utils/utils/handle_error_spec.rb)
@@ -17,13 +17,17 @@ Gem::Specification.new do |gem|
17
17
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
18
18
  end
19
19
 
20
+ gem.metadata = {
21
+ "changelog_uri" => "https://github.com/drivy/backend-configs/blob/main/getaround_utils/CHANGELOG.md",
22
+ }
23
+
20
24
  # Development dependencies
21
25
  gem.add_development_dependency 'getaround-rubocop', '= 0.2.11'
22
26
  gem.add_development_dependency 'irb', '~> 1.15'
23
27
  gem.add_development_dependency 'rake', '~> 13.2'
24
28
  gem.add_development_dependency 'rspec', '~> 3.13'
25
- gem.add_development_dependency 'rspec-rails', '~> 7.1'
26
- gem.add_development_dependency 'rubocop', '~> 1.75.0'
29
+ gem.add_development_dependency 'rspec-rails', '~> 8.0'
30
+ gem.add_development_dependency 'rubocop', '~> 1.79.0'
27
31
  gem.add_development_dependency 'webmock', '~> 3.25'
28
32
 
29
33
  # Functional (optional) dependencies
@@ -93,7 +93,8 @@ class GetaroundUtils::Railties::Ougai < Rails::Railtie
93
93
  config.logger = Rails.application.config.logger
94
94
 
95
95
  original_handler = config.error_handlers.shift
96
- config.error_handlers << lambda do |ex, ctx, **_|
96
+ # Third argument "config" was introduced in 7.x, enforced in 8.x
97
+ config.error_handlers << lambda do |ex, ctx, _config = nil|
97
98
  if Sidekiq.logger.is_a?(Ougai::Logger)
98
99
  Sidekiq.logger.warn(ex, job: ctx[:job])
99
100
  else
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module GetaroundUtils; end
6
+
7
+ module GetaroundUtils::Utils; end
8
+
9
+ module GetaroundUtils::Utils::ConfigUrl
10
+ def self.from_env(config_name, ...)
11
+ env_url = ENV.fetch("#{config_name}_URL", ...)
12
+ env_pwd = ENV.fetch("#{config_name}_PASSWORD", nil)
13
+ return if env_url.nil?
14
+
15
+ ::URI.parse(env_url).tap do |uri|
16
+ if env_pwd && !uri.userinfo
17
+ uri.userinfo = ":#{env_pwd}"
18
+ elsif env_pwd
19
+ uri.password ||= env_pwd
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'getaround_utils/mixins/loggable'
4
+
5
+ module GetaroundUtils; end
6
+
7
+ module GetaroundUtils::Utils; end
8
+
9
+ module GetaroundUtils::Utils::HandleError
10
+ extend GetaroundUtils::Mixins::Loggable
11
+
12
+ # @see https://docs.bugsnag.com/platforms/ruby/rails/reporting-handled-errors/#sending-custom-diagnostics
13
+ def self.notify_of(error, **metadata, &)
14
+ if defined?(::Bugsnag)
15
+ ::Bugsnag.notify(error) do |event|
16
+ metadata.each do |name, value|
17
+ if value.is_a?(Hash)
18
+ event.add_metadata(name, value)
19
+ else
20
+ event.add_metadata('custom', name, value)
21
+ end
22
+ end
23
+ yield event if block_given?
24
+ end
25
+ else
26
+ loggable_log(
27
+ :debug,
28
+ 'handled_error',
29
+ error_class: error.class.name,
30
+ error_message: error.to_s,
31
+ **metadata
32
+ )
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'getaround_utils/utils/config_url'
3
4
  require 'getaround_utils/utils/deep_key_value'
5
+ require 'getaround_utils/utils/handle_error'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GetaroundUtils
4
- VERSION = '0.2.36'
4
+ VERSION = '0.2.38'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getaround_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.36
4
+ version: 0.2.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-07-17 00:00:00.000000000 Z
12
+ date: 2025-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: getaround-rubocop
@@ -73,28 +73,28 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '7.1'
76
+ version: '8.0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '7.1'
83
+ version: '8.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rubocop
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 1.75.0
90
+ version: 1.79.0
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 1.75.0
97
+ version: 1.79.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: webmock
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -202,6 +202,7 @@ extra_rdoc_files: []
202
202
  files:
203
203
  - ".rubocop.yml"
204
204
  - ".ruby-version"
205
+ - CHANGELOG.md
205
206
  - Gemfile
206
207
  - Gemfile.lock
207
208
  - README.md
@@ -218,12 +219,15 @@ files:
218
219
  - lib/getaround_utils/railties/lograge.rb
219
220
  - lib/getaround_utils/railties/ougai.rb
220
221
  - lib/getaround_utils/utils.rb
222
+ - lib/getaround_utils/utils/config_url.rb
221
223
  - lib/getaround_utils/utils/deep_key_value.rb
224
+ - lib/getaround_utils/utils/handle_error.rb
222
225
  - lib/getaround_utils/version.rb
223
226
  homepage: https://github.com/drivy
224
227
  licenses:
225
228
  - MIT
226
- metadata: {}
229
+ metadata:
230
+ changelog_uri: https://github.com/drivy/backend-configs/blob/main/getaround_utils/CHANGELOG.md
227
231
  post_install_message:
228
232
  rdoc_options: []
229
233
  require_paths:
@@ -239,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
243
  - !ruby/object:Gem::Version
240
244
  version: '0'
241
245
  requirements: []
242
- rubygems_version: 3.5.16
246
+ rubygems_version: 3.5.21
243
247
  signing_key:
244
248
  specification_version: 4
245
249
  summary: Backend shared utility classes