complex_config 0.16.0 → 0.17.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/README.md +2 -0
- data/VERSION +1 -1
- data/complex_config.gemspec +3 -3
- data/lib/complex_config/errors.rb +3 -0
- data/lib/complex_config/provider.rb +28 -11
- data/lib/complex_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: 6a62d35017801f81211c900cfd841264193155e1f89ebc27c387b7649da6dbcc
|
4
|
+
data.tar.gz: 96cdc260febe8d2dff2f479421dcf7e94e61de4dacf77ee2ca30372c069e390c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae99c356a7467495f3311dd0aaca592078164458183076aae3fd3688d65d7d0e0b37bf209cb6b0873715240b9d6b1105e04dbbd60ce80d0d53566e5a67a07a5
|
7
|
+
data.tar.gz: a63690e1401e3df9bdc29cc6f9441812521bad478fb43ee4ed6be79d7bc39a220a56c90de3862b8d4510cd9ad04d48d534a92bcb0769500b8b7cb16c900f0328
|
data/README.md
CHANGED
@@ -144,6 +144,8 @@ Here is the `ComplexConfig::Plugins::MONEY` plugin for example:
|
|
144
144
|
|
145
145
|
## Changes
|
146
146
|
|
147
|
+
* 2019-03-18 Release 0.17.0
|
148
|
+
* Improve error message for missing encryption key
|
147
149
|
* 2019-03-14 Release 0.16.0
|
148
150
|
* Enable `- trim_mode` for ERB in yml files
|
149
151
|
* Allow `to_json` calls on settings
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.17.0
|
data/complex_config.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: complex_config 0.
|
2
|
+
# stub: complex_config 0.17.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "complex_config".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.17.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2019-03-
|
11
|
+
s.date = "2019-03-18"
|
12
12
|
s.description = "This library allows you to access configuration files via a simple interface".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["complex_config".freeze]
|
@@ -73,12 +73,7 @@ class ComplexConfig::Provider
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def decrypt_config(pathname)
|
76
|
-
|
77
|
-
my_ks = key_source(pathname)
|
78
|
-
if File.exist?(enc_pathname) && my_ks.ask_and_send(:key)
|
79
|
-
text = IO.binread(enc_pathname)
|
80
|
-
ComplexConfig::Encryption.new(my_ks.key_bytes).decrypt(text)
|
81
|
-
end
|
76
|
+
decrypt_config_case(pathname).first
|
82
77
|
end
|
83
78
|
|
84
79
|
def encrypt_config(pathname, config)
|
@@ -88,14 +83,21 @@ class ComplexConfig::Provider
|
|
88
83
|
|
89
84
|
def config(pathname, name = nil)
|
90
85
|
datas = []
|
91
|
-
|
86
|
+
path_exist = File.exist?(pathname)
|
87
|
+
if path_exist
|
92
88
|
datas << IO.binread(pathname)
|
93
89
|
end
|
94
|
-
|
90
|
+
decrypted, reason, enc_pathname = decrypt_config_case(pathname)
|
91
|
+
case reason
|
92
|
+
when :ok
|
95
93
|
datas << decrypted
|
94
|
+
when :key_missing
|
95
|
+
datas.empty? and raise ComplexConfig::EncryptionKeyMissing,
|
96
|
+
"encryption key for #{enc_pathname.to_s.inspect} is missing"
|
97
|
+
when :file_missing
|
98
|
+
datas.empty? and raise ComplexConfig::ConfigurationFileMissing,
|
99
|
+
"configuration file #{pathname.to_s.inspect} is missing"
|
96
100
|
end
|
97
|
-
datas.empty? and raise ComplexConfig::ConfigurationFileMissing,
|
98
|
-
"configuration file #{pathname.to_s.inspect} is missing"
|
99
101
|
results = datas.map { |d| evaluate(pathname, d) }
|
100
102
|
hashes = results.map { |r| ::YAML.load(r, pathname) }
|
101
103
|
settings = ComplexConfig::Settings.build(name, hashes.shift)
|
@@ -153,7 +155,7 @@ class ComplexConfig::Provider
|
|
153
155
|
|
154
156
|
def exist?(name)
|
155
157
|
!!config(pathname(name), name)
|
156
|
-
rescue ComplexConfig::ConfigurationFileMissing
|
158
|
+
rescue ComplexConfig::ConfigurationFileMissing, ComplexConfig::EncryptionKeyMissing
|
157
159
|
false
|
158
160
|
end
|
159
161
|
|
@@ -211,6 +213,21 @@ class ComplexConfig::Provider
|
|
211
213
|
|
212
214
|
private
|
213
215
|
|
216
|
+
def decrypt_config_case(pathname)
|
217
|
+
enc_pathname = pathname.to_s + '.enc'
|
218
|
+
my_ks = key_source(pathname)
|
219
|
+
if File.exist?(enc_pathname)
|
220
|
+
if my_ks.ask_and_send(:key)
|
221
|
+
text = IO.binread(enc_pathname)
|
222
|
+
decrypted = ComplexConfig::Encryption.new(my_ks.key_bytes).decrypt(text)
|
223
|
+
return decrypted, :ok, enc_pathname
|
224
|
+
else
|
225
|
+
return nil, :key_missing, enc_pathname
|
226
|
+
end
|
227
|
+
end
|
228
|
+
return nil, :file_missing, enc_pathname
|
229
|
+
end
|
230
|
+
|
214
231
|
def interpret_name_value(name, value)
|
215
232
|
if ComplexConfig::Settings === name
|
216
233
|
if value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: complex_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|