wbconfigurator 0.2.1 → 0.3.2

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: 7221ce9fe344bbdd5bb0bf0727973bc941dbdc891b02e6fb87cfaedb86cde835
4
+ data.tar.gz: a722289ad9338c5dddce25b0fdf2bf872d98429b37fcae1b1576a6c48464f0af
5
5
  SHA512:
6
- metadata.gz: 75df96a0f04acc4560a2701a3c4152937dbcb0e2e848910d81cfb7769684e62f925910a792061071d05be8cb5b3ff09fe235294eb3201e0e3222d2ac96354b57
7
- data.tar.gz: eb64974f3661fc19d386e009c6951330c9cab7b62ea102bb60ac231e919f7013ccbf76d3977a4a35a127a4c1dc1dea3e1812a4654bfd25a29971a9b6ed4ced0c
6
+ metadata.gz: 172b64c6360add9f5d015afd09c6a47c48e5d3bd8d0d5b979e7cab8d088f0308524203010246ff3ca58d4f522ae4796d5e6a2ca24cb1ac540af2d71dfd3c7d59
7
+ data.tar.gz: 27c4288ace9c6f2979d26b3a8de36fa8285fe4c2168f8ecea9300d6f51409f167720f2dfd33791de27dbe82be430668f3fb6f51f052715b8c9fcbd9ffe140ed9
data/README.md CHANGED
@@ -5,7 +5,7 @@ It allows easy management of specific environment settings with YAML config file
5
5
 
6
6
  ## Usage
7
7
 
8
- Please see the [wiki](https://github.com/wildbit/configurator/wiki) for detailed instructions about how to use the tool.
8
+ Please see the [wiki](https://github.com/ActiveCampaign/qa-configurator/wiki) for detailed instructions about how to use the tool.
9
9
 
10
10
  ## Installation
11
11
 
@@ -24,8 +24,4 @@ Please leave all comments, bugs, requests and issues on the Issues page.
24
24
 
25
25
  ## License
26
26
 
27
- Configurator library is released under the [MIT](http://www.opensource.org/licenses/mit-license.php) license.
28
-
29
- ## Copyright
30
-
31
- Copyright © 2020 Wildbit LLC.
27
+ Configurator library is released under the [MIT](http://www.opensource.org/licenses/mit-license.php) license.
data/configurator.gemspec CHANGED
@@ -11,14 +11,14 @@ Gem::Specification.new do |s|
11
11
  s.license = 'MIT'
12
12
 
13
13
  s.authors = ['Igor Balos']
14
- s.email = ['ibalosh@gmail.com', 'igor@wildbit.com']
14
+ s.email = ['ibalosh@gmail.com', 'ibalos@activecampaign.com']
15
15
 
16
16
  s.summary = 'Config tool.'
17
17
  s.description = 'Configuration tool for simple management with yaml files.'
18
18
 
19
19
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
20
20
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
21
- s.homepage = 'https://github.com/wildbit/configurator'
21
+ s.homepage = 'https://github.com/ActiveCampaign/qa-configurator'
22
22
  s.require_paths = ['lib']
23
23
  s.required_rubygems_version = '>= 1.9.3'
24
24
  s.add_dependency 'secure_yaml', '~> 2.0'
data/lib/config/app.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
- require 'secure_yaml'
5
- require_relative 'patch/secure_yaml/cipher'
6
4
  require 'singleton'
7
5
  require 'ostruct'
6
+ require 'erb'
8
7
 
9
8
  # App::Configuration class helps loading configuration files.
10
9
  #
@@ -54,10 +53,12 @@ module App
54
53
  FILES_EXTENSION = 'yaml'
55
54
  DEFAULT_ENVIRONMENT = 'production'
56
55
  attr_accessor :environment,
57
- :files_path
56
+ :files_path,
57
+ :use_secure_yaml
58
58
 
59
59
  def initialize
60
60
  @environment = DEFAULT_ENVIRONMENT
61
+ @use_secure_yaml = false
61
62
  end
62
63
 
63
64
  def load_all!
@@ -127,7 +128,15 @@ module App
127
128
  end
128
129
 
129
130
  def load_from_yaml(filename)
130
- SecureYaml.load(File.open(file_full_path(filename)))
131
+ yaml_file = ERB.new(File.read(file_full_path(filename))).result
132
+
133
+ if use_secure_yaml
134
+ require 'secure_yaml'
135
+ require_relative 'patch/secure_yaml/cipher'
136
+ SecureYaml.load(yaml_file)
137
+ else
138
+ YAML::load(yaml_file)
139
+ end
131
140
  end
132
141
 
133
142
  # generate accessors for loaded data
@@ -160,4 +169,4 @@ module App
160
169
  def self.clear_config
161
170
  @config = Configurator.new
162
171
  end
163
- end
172
+ 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.2'
5
5
  end
data/spec/data/test.yaml CHANGED
@@ -1,2 +1,4 @@
1
1
  retry_count: 2
2
2
  display_errors: true
3
+ error_id: <%= "error_#{1+1}" %>
4
+ boolean: <%= true %>
@@ -6,21 +6,43 @@ 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
42
+
43
+ it 'erb content - boolean' do
44
+ App.config.load!(:test)
45
+ expect(App.config.test.boolean).to eq(true)
46
+ end
25
47
  end
26
48
  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.2
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-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: secure_yaml
@@ -27,7 +27,7 @@ dependencies:
27
27
  description: Configuration tool for simple management with yaml files.
28
28
  email:
29
29
  - ibalosh@gmail.com
30
- - igor@wildbit.com
30
+ - ibalos@activecampaign.com
31
31
  executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
@@ -45,7 +45,7 @@ files:
45
45
  - spec/data/test.yaml
46
46
  - spec/spec_helper.rb
47
47
  - spec/unit/app_spec.rb
48
- homepage: https://github.com/wildbit/configurator
48
+ homepage: https://github.com/ActiveCampaign/qa-configurator
49
49
  licenses:
50
50
  - MIT
51
51
  metadata: {}
@@ -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.