wbconfigurator 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config/app.rb +4 -1
- data/lib/config/version.rb +1 -1
- data/spec/data/test.yaml +1 -0
- data/spec/unit/app_spec.rb +28 -11
- 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: eab5b88f48a27b6876fd7c088c7a5eecf42be7dedd73e0859ddd03667f72c22f
|
4
|
+
data.tar.gz: f6a3cdaf035c54c7a5b33d942bfc87b7077d54e9c651728d586b9f2f3155ba5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a11c4a85fd15c2a9a860cd342952443fdc33b3a5be83a7990808c93acb67736bd55d065f41ed4ef5eed63d95a1242fb02563a7511816eff681878017c3fd2f1
|
7
|
+
data.tar.gz: 42e41c07a67d7be9368e704c9930ea8ff18de17a16b8dc7f83e1f05cbcb24c58ec2a7da6830aa978818cc3d45b2ca75febd456b5babd9b6b0052e9abbbb18552
|
data/lib/config/app.rb
CHANGED
@@ -5,6 +5,7 @@ require 'secure_yaml'
|
|
5
5
|
require_relative 'patch/secure_yaml/cipher'
|
6
6
|
require 'singleton'
|
7
7
|
require 'ostruct'
|
8
|
+
require 'erb'
|
8
9
|
|
9
10
|
# App::Configuration class helps loading configuration files.
|
10
11
|
#
|
@@ -147,6 +148,8 @@ module App
|
|
147
148
|
Configurator::Struct.new(object)
|
148
149
|
when Array
|
149
150
|
object.map!(&method(:convert_to_struct))
|
151
|
+
when String
|
152
|
+
ERB.new(object).result
|
150
153
|
else
|
151
154
|
object
|
152
155
|
end
|
@@ -160,4 +163,4 @@ module App
|
|
160
163
|
def self.clear_config
|
161
164
|
@config = Configurator.new
|
162
165
|
end
|
163
|
-
end
|
166
|
+
end
|
data/lib/config/version.rb
CHANGED
data/spec/data/test.yaml
CHANGED
data/spec/unit/app_spec.rb
CHANGED
@@ -6,21 +6,38 @@ describe 'Configurator' do
|
|
6
6
|
App.config.files_path = File.join(File.dirname(__FILE__), '../data/')
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
context 'loading' do
|
10
|
+
it '.load_all!' do
|
11
|
+
expect { App.config.load_all! }.not_to raise_error
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
expect
|
14
|
-
expect(App.config.db.username).to eq('admin')
|
14
|
+
it '.load! - valid file' do
|
15
|
+
expect { App.config.load!(:db) }.not_to raise_error
|
15
16
|
end
|
16
|
-
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
it '.load! - invalid file' do
|
19
|
+
expect { App.config.load!(:dbs) }.to raise_error /Configuration file.*doesn't exist on path/
|
20
|
+
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
context 'content' do
|
24
|
+
it 'all config files' do
|
25
|
+
App.config.load_all!
|
26
|
+
|
27
|
+
aggregate_failures do
|
28
|
+
expect(App.config.test.display_errors).to be true
|
29
|
+
expect(App.config.db.username).to eq('admin')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'single file' do
|
34
|
+
App.config.load!(:db)
|
35
|
+
expect(App.config.db.username).to eq('admin')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'erb content' do
|
39
|
+
App.config.load!(:test)
|
40
|
+
expect(App.config.test.error_id).to eq('error_2')
|
41
|
+
end
|
25
42
|
end
|
26
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wbconfigurator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Balos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: secure_yaml
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: 1.9.3
|
66
66
|
requirements: []
|
67
|
-
rubygems_version: 3.
|
67
|
+
rubygems_version: 3.2.3
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Config tool.
|