philiprehberger-env_validator 0.4.0 → 0.5.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -1
- data/lib/philiprehberger/env_validator/result.rb +9 -3
- data/lib/philiprehberger/env_validator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dadb2f13023c0f7c7197f2891dbe002524aa699aaddc2d63cbea4fd3a114e57e
|
|
4
|
+
data.tar.gz: a234c798c769dbe6555076b89348937915eda6ec2ed6cbf7d14c83d34c5d3da8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 474b45b3c68dc48b405a3a43c79763c0c221a7f4a1625771df43ae3305a4c3c7208089e02522ac2f376ea98e7b80c92460ad86f6eb8b09efa12f3d05fbbd28c5
|
|
7
|
+
data.tar.gz: d8cfbf456a5ef7addc7fd08948b8b367f99e6a5b575d9278e8674c075f169903a2a1d8e5a16a692a41ec92b6e6a5aac6dffe275bd1ad9c2040379098695fb297
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.0] - 2026-04-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Result#to_h(exclude:)` accepts a list of symbol or string keys to omit from the returned hash, useful for redacting sensitive values during serialization
|
|
14
|
+
|
|
10
15
|
## [0.4.0] - 2026-04-16
|
|
11
16
|
|
|
12
17
|
### Added
|
data/README.md
CHANGED
|
@@ -80,8 +80,15 @@ end
|
|
|
80
80
|
config.keys # => ["PORT", "HOST"]
|
|
81
81
|
config.key?(:PORT) # => true
|
|
82
82
|
config.slice(:PORT) # => { "PORT" => 3000 }
|
|
83
|
+
config.to_h # => { "PORT" => 3000, "HOST" => "localhost" }
|
|
84
|
+
|
|
85
|
+
# Redact sensitive keys when serializing (e.g. for logs)
|
|
86
|
+
config.to_h(exclude: %i[api_key])
|
|
87
|
+
# => { "PORT" => 3000, "HOST" => "localhost" }
|
|
83
88
|
```
|
|
84
89
|
|
|
90
|
+
The `exclude:` list accepts symbols or strings and is matched against keys regardless of how they are stored internally.
|
|
91
|
+
|
|
85
92
|
### Prefix
|
|
86
93
|
|
|
87
94
|
Group related variables with a shared prefix:
|
|
@@ -157,7 +164,7 @@ Each element is stripped of surrounding whitespace and cast to `item_type`. An e
|
|
|
157
164
|
| `Result#keys` | List all defined variable names |
|
|
158
165
|
| `Result#key?(name)` | Check if a variable was defined |
|
|
159
166
|
| `Result#slice(*names)` | Get a subset hash of specific keys |
|
|
160
|
-
| `Result#to_h` | Get all values as a hash |
|
|
167
|
+
| `Result#to_h(exclude:)` | Get all values as a hash; pass `exclude:` to omit keys (symbols or strings) |
|
|
161
168
|
|
|
162
169
|
## Development
|
|
163
170
|
|
|
@@ -45,9 +45,15 @@ module Philiprehberger
|
|
|
45
45
|
@values.slice(*string_keys)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
# Return all validated values as a hash, optionally redacting keys.
|
|
49
|
+
#
|
|
50
|
+
# @param exclude [Array<Symbol, String>] keys to omit from the returned hash
|
|
51
|
+
# @return [Hash<String, Object>] all validated values, minus excluded keys
|
|
52
|
+
def to_h(exclude: [])
|
|
53
|
+
return @values.dup if exclude.nil? || exclude.empty?
|
|
54
|
+
|
|
55
|
+
excluded_keys = exclude.map(&:to_s)
|
|
56
|
+
@values.reject { |key, _| excluded_keys.include?(key.to_s) }
|
|
51
57
|
end
|
|
52
58
|
end
|
|
53
59
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-env_validator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Define environment variable schemas with type casting, required/optional
|
|
14
14
|
flags, and defaults. Validates at boot time and provides typed accessors.
|