getaround_utils 0.3.3 → 0.3.4

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: 1a0b5e64b0be84ffcfe22850f5b73c5e6d08d7eb6d843e7792d35268626377c7
4
+ data.tar.gz: 9dcefce00a8ad7bbb89ed28e6e4264c3ba80139ef9c2d2e0ade8f9fe0fe739c7
5
5
  SHA512:
6
- metadata.gz: 66dcca84c67e6f7f030c359fce44e48e154b7fa1c2b780a1a6ef9b0f4d6dd9045d2da248f13ead1e04cea5ed9e523d50b5bd5b5e001703e3f3b1fef00151d48e
7
- data.tar.gz: 327b48e801f84b263ae6be9d3e9c4535b3295e2a91634f77b39271d73d81a96ddc960dedc928d668513510f2701ac94da813f893510e11c4ae3769109d4b8677
6
+ metadata.gz: dff6641aa462aaf39e532b023723e25f1d8af1bc9fcaa1b24a5ea7b896910788c5f7c66121940281474d760dbf7e9d08f7a7fd2234e777cf08964c433283b83a
7
+ data.tar.gz: 63b26fa1260b94a4884d49bd42ce0aeb13fd3c1c0b3b03fa31863d214e2ff323530de7315dd7843ba5dbb54b3bf8d2957efa90d51644c4a3c147aca1178e3860
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [0.3.4] 2026-02-27
2
+
3
+ ### Breaking Changes
4
+
5
+ - `GetaroundUtils::Utils::ConfigUrl.from_env` ([#460](https://github.com/drivy/backend-configs/pull/460))
6
+ - Add `_USERNAME` variable support
7
+ - Make sub variables overriding base url segments
8
+ ```dotenv
9
+ TEST_URL="whatever://foo:my-pwd@localhost:666/test"
10
+ TEST_USERNAME="bar"
11
+ TEST_PASSWORD="new-pwd"
12
+ ```
13
+ ```ruby
14
+ # BEFORE (<= 0.3.3)
15
+ GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
16
+ # => <URI::Generic whatever://foo:my-pwd@localhost:666/test>
17
+
18
+ # AFTER (> 0.3.3)
19
+ GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
20
+ # => <URI::Generic whatever://bar:new-pwd@localhost:666/test>
21
+ ```
22
+
1
23
  ## [0.3.3] 2026-02-27
2
24
  - `GetaroundUtils::I18nBackend::FlatKeys` should be a module
3
25
 
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.4)
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')
@@ -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
@@ -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.4'
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy