superconfig 2.0.1 → 2.1.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/.github/workflows/ruby-tests.yml +2 -2
- data/CHANGELOG.md +1 -5
- data/lib/superconfig.rb +13 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9e0e414be8780a5a7815b5cdceb25a430f86363bf9120e42b1d3a55ca756f46
|
4
|
+
data.tar.gz: 0a216ce70e1f2430517dec63f62efc22654c051898837e17979c3f91a6ebe565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa41c22654cec2830fc13fed09ff67b1db897b554d56109da014ba15152801a599524c88fedb482e4780cad795494ec36f49e39fd4e5b8d3d59e867418fc01a3
|
7
|
+
data.tar.gz: 2967f86046040444020ef8f04b8fe0161d1f27bf748b8c3c1ac464ebae342031ab1b5562c0194c1d780c4e13f19747c3b7ec2b5a6ae1ff1035d592adbeb2591d
|
data/CHANGELOG.md
CHANGED
data/lib/superconfig.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SuperConfig
|
4
|
-
VERSION = "2.0
|
4
|
+
VERSION = "2.1.0"
|
5
5
|
|
6
6
|
MissingEnvironmentVariable = Class.new(StandardError)
|
7
7
|
MissingCallable = Class.new(StandardError)
|
@@ -48,7 +48,7 @@ module SuperConfig
|
|
48
48
|
define_singleton_method(name) do
|
49
49
|
return default unless @env.key?(env_var)
|
50
50
|
|
51
|
-
coerce(
|
51
|
+
coerce(type, @env[env_var])
|
52
52
|
end
|
53
53
|
|
54
54
|
aliases.each do |alias_name|
|
@@ -169,43 +169,41 @@ module SuperConfig
|
|
169
169
|
"#{report.join("\n")}\n"
|
170
170
|
end
|
171
171
|
|
172
|
-
private def coerce_to_string(
|
172
|
+
private def coerce_to_string(value)
|
173
173
|
value
|
174
174
|
end
|
175
175
|
|
176
|
-
private def coerce_to_bool(
|
176
|
+
private def coerce_to_bool(value)
|
177
177
|
BOOL_TRUE.include?(value)
|
178
178
|
end
|
179
179
|
|
180
|
-
private def coerce_to_int(
|
180
|
+
private def coerce_to_int(value)
|
181
181
|
Integer(value) if !BOOL_FALSE.include?(value) && value
|
182
182
|
end
|
183
183
|
|
184
|
-
private def coerce_to_float(
|
184
|
+
private def coerce_to_float(value)
|
185
185
|
Float(value) if value
|
186
186
|
end
|
187
187
|
|
188
|
-
private def coerce_to_bigdecimal(
|
188
|
+
private def coerce_to_bigdecimal(value)
|
189
189
|
BigDecimal(value) if value
|
190
190
|
end
|
191
191
|
|
192
|
-
private def coerce_to_symbol(
|
192
|
+
private def coerce_to_symbol(value)
|
193
193
|
value&.to_sym
|
194
194
|
end
|
195
195
|
|
196
|
-
private def coerce_to_array(
|
197
|
-
value&.split(/, */)&.map {|v| coerce(
|
196
|
+
private def coerce_to_array(value, type)
|
197
|
+
value&.split(/, */)&.map {|v| coerce(type, v) }
|
198
198
|
end
|
199
199
|
|
200
|
-
private def coerce_to_json(
|
200
|
+
private def coerce_to_json(value)
|
201
201
|
value && JSON.parse(value)
|
202
|
-
rescue JSON::ParserError
|
203
|
-
raise ArgumentError, "#{name} is not a valid JSON string"
|
204
202
|
end
|
205
203
|
|
206
|
-
private def coerce(
|
204
|
+
private def coerce(type, value)
|
207
205
|
main_type, sub_type = type
|
208
|
-
args = [
|
206
|
+
args = [value]
|
209
207
|
args << sub_type if sub_type
|
210
208
|
|
211
209
|
send("coerce_to_#{main_type}", *args)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
187
|
+
rubygems_version: 3.3.3
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Access environment variables. Also includes presence validation, type coercion
|