rb-konfig 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/konfig.rb +6 -1
- data/lib/konfig/option.rb +5 -1
- data/lib/konfig/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13dc2b950e1107253dbd69374abda84a6bd609695fb28e49676c7d841397b58b
|
4
|
+
data.tar.gz: 15ccf9fa2b8be891e77f8bdc7c1dfe6050c4a6c660bd01524ab3693c4bb7e0f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b82d85c862f00fa50caa8102e5668c4ea95154e5997f24972056d52adf55f07d29b73286c1dc134264364f6c40153a3d353c420629174ebd25de69db68570d6
|
7
|
+
data.tar.gz: 783ba8be6af7e3c5e3c697dd6c5217c7fba54d9b38cd7a750aafc5db914990464b657130f97c10b350e95f3c3230e28850169ed6a4e17305e2dc5fc78f2aed52
|
data/README.md
CHANGED
@@ -84,6 +84,7 @@ You can change or reach the following from `Konfig.configuration`
|
|
84
84
|
* `mode`: No default value
|
85
85
|
* `workdir`: No default value
|
86
86
|
* `schema`: Configuration validation schema. If available, the loaded, merged and parsed configuration is validated against this schema. See [Dry-Schema](https://dry-rb.org/gems/dry-schema/) for more information.
|
87
|
+
* `fail_on_validation`: Fail if schema validation fails
|
87
88
|
|
88
89
|
### Data types
|
89
90
|
|
data/lib/konfig.rb
CHANGED
@@ -22,6 +22,7 @@ module Konfig
|
|
22
22
|
attr_writer :workdir
|
23
23
|
attr_writer :env_prefix
|
24
24
|
attr_writer :logger
|
25
|
+
attr_writer :fail_on_validation
|
25
26
|
|
26
27
|
def namespace
|
27
28
|
@namespace || "Settings"
|
@@ -82,6 +83,10 @@ module Konfig
|
|
82
83
|
|
83
84
|
def nil_word
|
84
85
|
@nil_word || "null"
|
85
|
-
|
86
|
+
end
|
87
|
+
|
88
|
+
def fail_on_validation
|
89
|
+
@fail_on_validation.nil? ? true : @fail_on_validation
|
90
|
+
end
|
86
91
|
end
|
87
92
|
end
|
data/lib/konfig/option.rb
CHANGED
@@ -32,7 +32,11 @@ module Konfig
|
|
32
32
|
|
33
33
|
unless v_res.success?
|
34
34
|
error = Konfig::ValidationError.format(v_res)
|
35
|
-
|
35
|
+
if Konfig.configuration.fail_on_validation
|
36
|
+
raise Konfig::ValidationError.new("Config validation failed:\n\n#{error}")
|
37
|
+
else
|
38
|
+
Konfig.configuration.logger.error "Config validation failed:\n\n#{error}"
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/konfig/version.rb
CHANGED