getaround_utils 0.3.3 → 0.3.5

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: 5b8f527ba9f0f5c93d0aa5f5898278230277ccbe435b690c03d0b79eceb277ab
4
- data.tar.gz: 276a5197b07e3052fc813367d04ca0e04a84c1400da83c2487c83d22e8c43bce
3
+ metadata.gz: 197707c0b85b1de9d759389ce44867114b3a1e1bf231e72c23b40356040df563
4
+ data.tar.gz: 36109e28f921a5e8c97fd3f1512b0e2838f6416c2a7b1cd845d3e8784db14cd1
5
5
  SHA512:
6
- metadata.gz: 66dcca84c67e6f7f030c359fce44e48e154b7fa1c2b780a1a6ef9b0f4d6dd9045d2da248f13ead1e04cea5ed9e523d50b5bd5b5e001703e3f3b1fef00151d48e
7
- data.tar.gz: 327b48e801f84b263ae6be9d3e9c4535b3295e2a91634f77b39271d73d81a96ddc960dedc928d668513510f2701ac94da813f893510e11c4ae3769109d4b8677
6
+ metadata.gz: 451a09d17a3aa284e26c1b2700891a4a8df4e5d3a5f7819e7e425c7f6e4c0988471b1cb05df8fd4f1399e45f441e83674a3e3421d9e2b0239e9dace98981ca32
7
+ data.tar.gz: 8e0f3e45775ea0fd26f5d22603870f5f86f71963f0cbacbb88cf5fd46722a6202392825188cff9731a4202c8b85b52c849f23d7a61ce46aacaa0a9a0c349af1d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## [0.3.5] 2026-07-07
2
+
3
+ ### Fixed
4
+
5
+ - `GetaroundUtils::Utils::HandleError`: notify Bugsnag only when `BUGSNAG_API_KEY` is configured, otherwise log.
6
+
7
+ ### Added
8
+
9
+ - `GetaroundUtils::Utils::HealthCheckFile` ([#481](https://github.com/drivy/backend-configs/pull/481))
10
+ ```ruby
11
+ SIDEKIQ_HEALTH_FILE = GetaroundUtils::Utils::HealthCheckFile.new('sidekiq')
12
+ Sidekiq.configure_server do |config|
13
+ config.on(:startup) { SIDEKIQ_HEALTH_FILE.create }
14
+ config.on(:shutdown) { SIDEKIQ_HEALTH_FILE.delete }
15
+ end
16
+ ```
17
+
18
+ ## [0.3.4] 2026-02-27
19
+
20
+ ### Breaking Changes
21
+
22
+ - `GetaroundUtils::Utils::ConfigUrl.from_env` ([#460](https://github.com/drivy/backend-configs/pull/460))
23
+ - Add `_USERNAME` variable support
24
+ - Make sub variables overriding base url segments
25
+ ```dotenv
26
+ TEST_URL="whatever://foo:my-pwd@localhost:666/test"
27
+ TEST_USERNAME="bar"
28
+ TEST_PASSWORD="new-pwd"
29
+ ```
30
+ ```ruby
31
+ # BEFORE (<= 0.3.3)
32
+ GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
33
+ # => <URI::Generic whatever://foo:my-pwd@localhost:666/test>
34
+
35
+ # AFTER (> 0.3.3)
36
+ GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
37
+ # => <URI::Generic whatever://bar:new-pwd@localhost:666/test>
38
+ ```
39
+
1
40
  ## [0.3.3] 2026-02-27
2
41
  - `GetaroundUtils::I18nBackend::FlatKeys` should be a module
3
42
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getaround_utils (0.3.3)
4
+ getaround_utils (0.3.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -147,23 +147,25 @@ For more details, [read the spec](spec/getaround_utils/utils/deep_key_value_spec
147
147
 
148
148
  ### GetaroundUtils::Utils::ConfigUrl
149
149
 
150
- This helper allows to manage configuration urls with password extracted in a dedicated variable.
150
+ This helper allows to manage configuration urls with username and password extracted in dedicated variables.
151
151
 
152
- It uses `*_URL` variable and tries to compute `*_PASSWORD` inside the parsed url.
152
+ Uses `*_URL` variable and tries to compute `*_USERNAME` and `*_PASSWORD` variables inside the parsed url.
153
153
 
154
+ ```dotenv
155
+ FOO_URL="redis://foo@localhost:666/10"
156
+ FOO_PASSWORD="added-pwd"
157
+ BAR_URL="whatever://bar:baz@localhost:666/42"
158
+ BAR_USERNAME="user666"
159
+ BAR_PASSWORD="new-pwd"
160
+ ENV_TEST_NUMBER=1
161
+ ```
154
162
  ```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
163
  GetaroundUtils::Utils::ConfigUrl
162
164
  .from_env('FOO')
163
165
  .tap { |uri| uri.path += ENV['ENV_TEST_NUMBER'] }
164
166
  # => <URI::Generic redis://foo:added-pwd@localhost:666/101>
165
167
  GetaroundUtils::Utils::ConfigUrl.from_env('BAR').to_s
166
- # => "whatever://bar:used-pwd@localhost:666/42"
168
+ # => "whatever://user666:new-pwd@localhost:666/42"
167
169
  GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN')
168
170
  # => KeyError: key not found "UNKNOWN_URL"
169
171
  GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN', 'mysql://localhost/test')
@@ -197,3 +199,19 @@ end
197
199
  ```
198
200
 
199
201
  For more details, [read the spec](spec/getaround_utils/utils/handle_error_spec.rb)
202
+
203
+ ### GetaroundUtils::Utils::HealthCheckFile
204
+
205
+ Helper to easily create health check file used for Kubernetes Probes (Sidekiq, Captur, etc...)
206
+
207
+ *Example in `config/initializers/sidekiq.rb`*
208
+ ```ruby
209
+ SIDEKIQ_HEALTH_FILE = GetaroundUtils::Utils::HealthCheckFile.new('sidekiq')
210
+
211
+ Sidekiq.configure_server do |config|
212
+ config.on(:startup) { SIDEKIQ_HEALTH_FILE.create }
213
+ config.on(:shutdown) { SIDEKIQ_HEALTH_FILE.delete }
214
+ end
215
+ ```
216
+
217
+ For more details, [read the spec](spec/getaround_utils/utils/health_check_file_spec.rb)
@@ -9,15 +9,19 @@ module GetaroundUtils::Utils; end
9
9
  module GetaroundUtils::Utils::ConfigUrl
10
10
  def self.from_env(config_name, ...)
11
11
  env_url = ENV.fetch("#{config_name}_URL", ...)
12
+ env_usr = ENV.fetch("#{config_name}_USERNAME", nil)
12
13
  env_pwd = ENV.fetch("#{config_name}_PASSWORD", nil)
13
- return if env_url.nil?
14
+ return if env_url.nil? || env_url.empty? # rubocop:disable Rails/Blank
14
15
 
15
16
  ::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
17
+ uri_usr, uri_pwd = uri.userinfo&.split(':', 2)
18
+ uri_pwd = uri_pwd.to_s if uri.userinfo&.include?(':')
19
+ usr = env_usr.nil? ? uri_usr : env_usr
20
+ pwd = env_pwd.nil? ? uri_pwd : env_pwd
21
+ userinfo = usr.to_s
22
+ userinfo += ":#{pwd}" unless pwd.nil?
23
+
24
+ uri.userinfo = userinfo unless userinfo.empty?
21
25
  end
22
26
  end
23
27
  end
@@ -11,7 +11,7 @@ module GetaroundUtils::Utils::HandleError
11
11
 
12
12
  # @see https://docs.bugsnag.com/platforms/ruby/rails/reporting-handled-errors/#sending-custom-diagnostics
13
13
  def self.notify_of(error, **metadata, &)
14
- if defined?(::Bugsnag)
14
+ if defined?(::Bugsnag) && ::Bugsnag.configuration.api_key
15
15
  ::Bugsnag.notify(error) do |event|
16
16
  metadata.each do |name, value|
17
17
  if value.is_a?(Hash)
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'pathname'
5
+
6
+ module GetaroundUtils; end
7
+
8
+ module GetaroundUtils::Utils; end
9
+
10
+ class GetaroundUtils::Utils::HealthCheckFile
11
+ FILE_NAME = 'health_check_file'
12
+
13
+ attr_reader :path
14
+
15
+ def initialize(name)
16
+ raise ArgumentError, "Expected name as String, got: #{name.inspect}" if !name.is_a?(String) || name.empty?
17
+
18
+ @base_path = root_path.join('tmp', name)
19
+ @path = @base_path.join(FILE_NAME)
20
+ end
21
+
22
+ def create
23
+ FileUtils.mkdir_p(@base_path)
24
+ FileUtils.touch(@path)
25
+ end
26
+
27
+ def delete
28
+ FileUtils.rm_f(@path)
29
+ end
30
+
31
+ def exists?
32
+ File.exist?(@path)
33
+ end
34
+
35
+ private
36
+
37
+ def root_path
38
+ defined?(::Rails) ? Rails.root : Pathname.new('/')
39
+ end
40
+ end
@@ -3,3 +3,4 @@
3
3
  require 'getaround_utils/utils/config_url'
4
4
  require 'getaround_utils/utils/deep_key_value'
5
5
  require 'getaround_utils/utils/handle_error'
6
+ require 'getaround_utils/utils/health_check_file'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GetaroundUtils
4
- VERSION = '0.3.3'
4
+ VERSION = '0.3.5'
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.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy
@@ -222,6 +222,7 @@ files:
222
222
  - lib/getaround_utils/utils/config_url.rb
223
223
  - lib/getaround_utils/utils/deep_key_value.rb
224
224
  - lib/getaround_utils/utils/handle_error.rb
225
+ - lib/getaround_utils/utils/health_check_file.rb
225
226
  - lib/getaround_utils/version.rb
226
227
  homepage: https://github.com/drivy
227
228
  licenses: