myway_config 0.1.1 → 0.1.2
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/lib/myway_config/base.rb +22 -6
- data/lib/myway_config/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: 7d79d8c65a203d54153cbb96cbe6b3888049b6fa9bc6cb40ea2053da8f304083
|
|
4
|
+
data.tar.gz: 6da321eccf472702e51b6f5def3952701964a68640132f130ab132412d4cbc47
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17d350092da29838b7d506e9919182e963f8e1b017b7cb2fd8baa0f77d4e7bb5f3c75cacf4a357b16b568d2151e31f3172b8e023899ec082f3b050a0f6ba11e9
|
|
7
|
+
data.tar.gz: beb0ffbc157279b9958cd40328ac1efc90581ba9e1540d11225b3abf3313e062a41d57b805373a9fada2eaa1149026de157e3642adb87bfc5a138590a8c6ff21
|
data/lib/myway_config/base.rb
CHANGED
|
@@ -105,6 +105,23 @@ module MywayConfig
|
|
|
105
105
|
->(v) { v.nil? ? nil : v.to_s.to_sym }
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
# Boolean coercion helper
|
|
109
|
+
#
|
|
110
|
+
# Converts string values "true"/"false" to actual booleans.
|
|
111
|
+
# This is needed for environment variable values.
|
|
112
|
+
#
|
|
113
|
+
# @return [Proc] coercion proc that converts to boolean
|
|
114
|
+
def to_boolean
|
|
115
|
+
->(v) {
|
|
116
|
+
case v
|
|
117
|
+
when TrueClass, FalseClass then v
|
|
118
|
+
when String then v.downcase == 'true'
|
|
119
|
+
when nil then false
|
|
120
|
+
else !!v
|
|
121
|
+
end
|
|
122
|
+
}
|
|
123
|
+
end
|
|
124
|
+
|
|
108
125
|
# Deep merge helper for coercion
|
|
109
126
|
#
|
|
110
127
|
# @param base [Hash] base hash
|
|
@@ -183,17 +200,16 @@ module MywayConfig
|
|
|
183
200
|
coercions = {}
|
|
184
201
|
|
|
185
202
|
schema.each do |key, value|
|
|
186
|
-
#
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
else
|
|
190
|
-
attr_config key
|
|
191
|
-
end
|
|
203
|
+
# Don't pass defaults to attr_config - they come from bundled_defaults loader
|
|
204
|
+
# Passing defaults here would cause them to be applied AFTER env vars
|
|
205
|
+
attr_config key
|
|
192
206
|
|
|
193
207
|
coercions[key] = if value.is_a?(Hash)
|
|
194
208
|
config_section_coercion(key)
|
|
195
209
|
elsif value.is_a?(Symbol)
|
|
196
210
|
to_symbol
|
|
211
|
+
elsif boolean?(value)
|
|
212
|
+
to_boolean
|
|
197
213
|
end
|
|
198
214
|
end
|
|
199
215
|
|
data/lib/myway_config/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: myway_config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dewayne VanHoozer
|
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
90
90
|
- !ruby/object:Gem::Version
|
|
91
91
|
version: '0'
|
|
92
92
|
requirements: []
|
|
93
|
-
rubygems_version: 4.0.
|
|
93
|
+
rubygems_version: 4.0.4
|
|
94
94
|
specification_version: 4
|
|
95
95
|
summary: Configuration management extending anyway_config with XDG support and auto-configuration
|
|
96
96
|
test_files: []
|