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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98be19c8fa6f73d1e47870db4705593b72ff32e912bde9f80160555725fac942
4
- data.tar.gz: 253c4e7e0892c355f585242552035a19d8eaf948eb090d7c5f6374648207d674
3
+ metadata.gz: eab5b88f48a27b6876fd7c088c7a5eecf42be7dedd73e0859ddd03667f72c22f
4
+ data.tar.gz: f6a3cdaf035c54c7a5b33d942bfc87b7077d54e9c651728d586b9f2f3155ba5e
5
5
  SHA512:
6
- metadata.gz: 75df96a0f04acc4560a2701a3c4152937dbcb0e2e848910d81cfb7769684e62f925910a792061071d05be8cb5b3ff09fe235294eb3201e0e3222d2ac96354b57
7
- data.tar.gz: eb64974f3661fc19d386e009c6951330c9cab7b62ea102bb60ac231e919f7013ccbf76d3977a4a35a127a4c1dc1dea3e1812a4654bfd25a29971a9b6ed4ced0c
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Configurator
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/spec/data/test.yaml CHANGED
@@ -1,2 +1,3 @@
1
1
  retry_count: 2
2
2
  display_errors: true
3
+ error_id: <%= "error_#{1+1}" %>
@@ -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
- it '.load_all!' do
10
- App.config.load_all!
9
+ context 'loading' do
10
+ it '.load_all!' do
11
+ expect { App.config.load_all! }.not_to raise_error
12
+ end
11
13
 
12
- aggregate_failures do
13
- expect(App.config.test.display_errors).to be true
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
- it '.load! - valid file' do
19
- App.config.load!(:db)
20
- expect(App.config.db.username).to eq('admin')
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
- it '.load! - invalid file' do
24
- expect { App.config.load!(:dbs) }.to raise_error /Configuration file.*doesn't exist on path/
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.2.1
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: 2021-02-11 00:00:00.000000000 Z
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.0.9
67
+ rubygems_version: 3.2.3
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Config tool.