superconfig 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbd7451e326a63df725764a9e0b29dec045b330b499eefefe40437808e0049b0
4
- data.tar.gz: bfa6173594fe005b5a379e3208aaa2df3495ce9abbd25a25d443c8df282a97c9
3
+ metadata.gz: c9e0e414be8780a5a7815b5cdceb25a430f86363bf9120e42b1d3a55ca756f46
4
+ data.tar.gz: 0a216ce70e1f2430517dec63f62efc22654c051898837e17979c3f91a6ebe565
5
5
  SHA512:
6
- metadata.gz: e02df280e20253019f4f5d1e2c36df847c48e7057976371b6dd03ad19b873c42c9d2eba90d11a48a4e8cdd7059a7c488e6a986711ebe771d9380f115b96ebc01
7
- data.tar.gz: 9151d646da85061a80cad78aa9ea58391319550e5d72afcf8a7793ebd40ed6f37f0af22932de46f309009fe14c8e6e597e07535a4ee3d2d377b2e983d94fef01
6
+ metadata.gz: aa41c22654cec2830fc13fed09ff67b1db897b554d56109da014ba15152801a599524c88fedb482e4780cad795494ec36f49e39fd4e5b8d3d59e867418fc01a3
7
+ data.tar.gz: 2967f86046040444020ef8f04b8fe0161d1f27bf748b8c3c1ac464ebae342031ab1b5562c0194c1d780c4e13f19747c3b7ec2b5a6ae1ff1035d592adbeb2591d
@@ -24,9 +24,9 @@ jobs:
24
24
  - Gemfile
25
25
 
26
26
  steps:
27
- - uses: actions/checkout@v3
27
+ - uses: actions/checkout@v2.4.0
28
28
 
29
- - uses: actions/cache@v3
29
+ - uses: actions/cache@v2
30
30
  with:
31
31
  path: vendor/bundle
32
32
  key: >
data/CHANGELOG.md CHANGED
@@ -11,10 +11,6 @@ Prefix your message with one of the following:
11
11
  - [Security] in case of vulnerabilities.
12
12
  -->
13
13
 
14
- ## v2.0.1
15
-
16
- - [Changed] Ensure bad JSON strings doesn't leak it's contents.
17
-
18
- ## v2.0.0
14
+ ## Unreleased
19
15
 
20
16
  - Initial release.
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.1"
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(env_var, type, @env[env_var])
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(_name, value)
172
+ private def coerce_to_string(value)
173
173
  value
174
174
  end
175
175
 
176
- private def coerce_to_bool(_name, value)
176
+ private def coerce_to_bool(value)
177
177
  BOOL_TRUE.include?(value)
178
178
  end
179
179
 
180
- private def coerce_to_int(_name, value)
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(_name, value)
184
+ private def coerce_to_float(value)
185
185
  Float(value) if value
186
186
  end
187
187
 
188
- private def coerce_to_bigdecimal(_name, value)
188
+ private def coerce_to_bigdecimal(value)
189
189
  BigDecimal(value) if value
190
190
  end
191
191
 
192
- private def coerce_to_symbol(_name, value)
192
+ private def coerce_to_symbol(value)
193
193
  value&.to_sym
194
194
  end
195
195
 
196
- private def coerce_to_array(name, value, type)
197
- value&.split(/, */)&.map {|v| coerce(name, type, v) }
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(name, value)
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(name, type, value)
204
+ private def coerce(type, value)
207
205
  main_type, sub_type = type
208
- args = [name, value]
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.1
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: 2023-02-15 00:00:00.000000000 Z
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.4.6
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