complex_config 0.18.1 → 0.19.2
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/.tool-versions +1 -0
- data/.travis.yml +1 -0
- data/VERSION +1 -1
- data/complex_config.gemspec +5 -5
- data/lib/complex_config/provider.rb +19 -6
- data/lib/complex_config/settings.rb +12 -2
- data/lib/complex_config/version.rb +1 -1
- data/spec/complex_config/provider_spec.rb +12 -0
- data/spec/complex_config/settings_spec.rb +5 -0
- data/spec/config/config_with_alias.yml +6 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3486d5210e50100d17dea40922e6958c06898ba4ec70d3830b58b50160ecdeba
|
|
4
|
+
data.tar.gz: ee463ae5164fee75e2a4454b1176b1d31903026924297aca8371814cf6e1649d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ea338ae3b2f8b9ea408d0a2e439afd14f21ba29937f82d33d01f3db6c155513e16108d3647345e3c05031c6ba06433ab9db7d626ba5be427758be6ad51f1981
|
|
7
|
+
data.tar.gz: 3cba305f3824ff5da2592283ce698ff7f06d28fe1c9c61caabd6fc77c7f0601664a7a4213bf8b47a14adb88bdb29ee43a44b4220ca9305b441678905d94c2b77
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.0.2
|
data/.travis.yml
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.19.2
|
data/complex_config.gemspec
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: complex_config 0.
|
|
2
|
+
# stub: complex_config 0.19.2 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.19.2"
|
|
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 = "
|
|
11
|
+
s.date = "2021-10-28"
|
|
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]
|
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/version.rb".freeze]
|
|
16
|
-
s.files = [".gitignore".freeze, ".rspec".freeze, ".travis.yml".freeze, ".utilsrc".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/complex_config".freeze, "complex_config.gemspec".freeze, "config/products.yml".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/version.rb".freeze, "spec/complex_config/config_spec.rb".freeze, "spec/complex_config/encryption_spec.rb".freeze, "spec/complex_config/key_source_spec.rb".freeze, "spec/complex_config/plugins_spec.rb".freeze, "spec/complex_config/provider_spec.rb".freeze, "spec/complex_config/settings_spec.rb".freeze, "spec/complex_config/shortcuts_spec.rb".freeze, "spec/config/broken_config.yml".freeze, "spec/config/config.yml".freeze, "spec/config/master.key".freeze, "spec/config/with-key-file.yml.enc".freeze, "spec/config/with-key-file.yml.key".freeze, "spec/config/without-key-file.yml.enc".freeze, "spec/spec_helper.rb".freeze]
|
|
16
|
+
s.files = [".gitignore".freeze, ".rspec".freeze, ".tool-versions".freeze, ".travis.yml".freeze, ".utilsrc".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/complex_config".freeze, "complex_config.gemspec".freeze, "config/products.yml".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/version.rb".freeze, "spec/complex_config/config_spec.rb".freeze, "spec/complex_config/encryption_spec.rb".freeze, "spec/complex_config/key_source_spec.rb".freeze, "spec/complex_config/plugins_spec.rb".freeze, "spec/complex_config/provider_spec.rb".freeze, "spec/complex_config/settings_spec.rb".freeze, "spec/complex_config/shortcuts_spec.rb".freeze, "spec/config/broken_config.yml".freeze, "spec/config/config.yml".freeze, "spec/config/config_with_alias.yml".freeze, "spec/config/master.key".freeze, "spec/config/with-key-file.yml.enc".freeze, "spec/config/with-key-file.yml.key".freeze, "spec/config/without-key-file.yml.enc".freeze, "spec/spec_helper.rb".freeze]
|
|
17
17
|
s.homepage = "https://github.com/flori/complex_config".freeze
|
|
18
18
|
s.licenses = ["Apache-2.0".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "ComplexConfig -- configuration library".freeze, "--main".freeze, "README.md".freeze]
|
|
20
|
-
s.rubygems_version = "3.
|
|
20
|
+
s.rubygems_version = "3.2.22".freeze
|
|
21
21
|
s.summary = "configuration library".freeze
|
|
22
22
|
s.test_files = ["spec/complex_config/config_spec.rb".freeze, "spec/complex_config/encryption_spec.rb".freeze, "spec/complex_config/key_source_spec.rb".freeze, "spec/complex_config/plugins_spec.rb".freeze, "spec/complex_config/provider_spec.rb".freeze, "spec/complex_config/settings_spec.rb".freeze, "spec/complex_config/shortcuts_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
23
23
|
|
|
@@ -65,7 +65,7 @@ class ComplexConfig::Provider
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def config_dir
|
|
68
|
-
@config_dir || (defined?(Rails) && Rails.root || Pathname.pwd) + 'config'
|
|
68
|
+
@config_dir || (defined?(Rails) && Rails.respond_to?(:root) && Rails.root || Pathname.pwd) + 'config'
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def pathname(name)
|
|
@@ -99,7 +99,12 @@ class ComplexConfig::Provider
|
|
|
99
99
|
"configuration file #{pathname.to_s.inspect} is missing"
|
|
100
100
|
end
|
|
101
101
|
results = datas.map { |d| evaluate(pathname, d) }
|
|
102
|
-
hashes =
|
|
102
|
+
hashes =
|
|
103
|
+
if ::Psych::VERSION < "4"
|
|
104
|
+
results.map { |r| ::YAML.load(r, pathname) }
|
|
105
|
+
else
|
|
106
|
+
results.map { |r| ::YAML.load(r, filename: pathname, aliases: true) }
|
|
107
|
+
end
|
|
103
108
|
settings = ComplexConfig::Settings.build(name, hashes.shift)
|
|
104
109
|
hashes.each { |h| settings.attributes_update(h) }
|
|
105
110
|
if shared = settings.shared?
|
|
@@ -169,10 +174,18 @@ class ComplexConfig::Provider
|
|
|
169
174
|
self
|
|
170
175
|
end
|
|
171
176
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
177
|
+
if RUBY_VERSION >= "3"
|
|
178
|
+
def evaluate(pathname, data)
|
|
179
|
+
erb = ::ERB.new(data, trim_mode: '-')
|
|
180
|
+
erb.filename = pathname.to_s
|
|
181
|
+
erb.result
|
|
182
|
+
end
|
|
183
|
+
else
|
|
184
|
+
def evaluate(pathname, data)
|
|
185
|
+
erb = ::ERB.new(data, nil, '-')
|
|
186
|
+
erb.filename = pathname.to_s
|
|
187
|
+
erb.result
|
|
188
|
+
end
|
|
176
189
|
end
|
|
177
190
|
|
|
178
191
|
def env
|
|
@@ -111,7 +111,7 @@ class ComplexConfig::Settings < BasicObject
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def ==(other)
|
|
114
|
-
to_h == other.to_h
|
|
114
|
+
other.respond_to?(:to_h) && to_h == other.to_h
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def to_yaml
|
|
@@ -187,7 +187,7 @@ class ComplexConfig::Settings < BasicObject
|
|
|
187
187
|
freeze
|
|
188
188
|
end
|
|
189
189
|
|
|
190
|
-
def
|
|
190
|
+
def attribute_get(name)
|
|
191
191
|
if !attribute_set?(name) and
|
|
192
192
|
value = ::ComplexConfig::Provider.apply_plugins(self, name)
|
|
193
193
|
then
|
|
@@ -197,6 +197,16 @@ class ComplexConfig::Settings < BasicObject
|
|
|
197
197
|
end
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
+
alias [] attribute_get
|
|
201
|
+
|
|
202
|
+
def attribute_get!(name)
|
|
203
|
+
if attribute_set?(name)
|
|
204
|
+
attribute_get(name)
|
|
205
|
+
else
|
|
206
|
+
raise ::ComplexConfig::AttributeMissing, "no attribute named #{name.inspect}"
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
200
210
|
def []=(name, value)
|
|
201
211
|
@table[name.to_sym] = value
|
|
202
212
|
end
|
|
@@ -269,6 +269,18 @@ RSpec.describe ComplexConfig::Provider do
|
|
|
269
269
|
end
|
|
270
270
|
end
|
|
271
271
|
|
|
272
|
+
context 'handling configuration files with aliases (considered unsafe)' do
|
|
273
|
+
before do
|
|
274
|
+
described_class.config_dir = Pathname.new(__FILE__) + '../../config'
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
it 'reads yaml files with aliases just fine' do
|
|
278
|
+
expect(
|
|
279
|
+
described_class.config(asset('config_with_alias.yml')).specific.extended
|
|
280
|
+
).to be true
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
272
284
|
context 'evaluating configuration files with ERB' do
|
|
273
285
|
it 'evaluates a config file correctly' do
|
|
274
286
|
expect(
|
|
@@ -133,6 +133,11 @@ EOT
|
|
|
133
133
|
expect(settings.foo.baz?).to be_falsy
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
+
it 'can trigger exception on attribute get' do
|
|
137
|
+
expect(settings.foo.attribute_get!(:bar)).to be_truthy
|
|
138
|
+
expect { settings.foo.attribute_get!(:baz) }.to raise_error ComplexConfig::AttributeMissing
|
|
139
|
+
end
|
|
140
|
+
|
|
136
141
|
it 'handles arrays correctly' do
|
|
137
142
|
settings = described_class[ary: [ 1, { hsh: 2 }, 3 ]]
|
|
138
143
|
expect(settings.to_h).to eq(ary: [ 1, { hsh: 2 }, 3 ])
|
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.19.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gem_hadar
|
|
@@ -155,6 +155,7 @@ extra_rdoc_files:
|
|
|
155
155
|
files:
|
|
156
156
|
- ".gitignore"
|
|
157
157
|
- ".rspec"
|
|
158
|
+
- ".tool-versions"
|
|
158
159
|
- ".travis.yml"
|
|
159
160
|
- ".utilsrc"
|
|
160
161
|
- COPYING
|
|
@@ -191,6 +192,7 @@ files:
|
|
|
191
192
|
- spec/complex_config/shortcuts_spec.rb
|
|
192
193
|
- spec/config/broken_config.yml
|
|
193
194
|
- spec/config/config.yml
|
|
195
|
+
- spec/config/config_with_alias.yml
|
|
194
196
|
- spec/config/master.key
|
|
195
197
|
- spec/config/with-key-file.yml.enc
|
|
196
198
|
- spec/config/with-key-file.yml.key
|
|
@@ -219,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
219
221
|
- !ruby/object:Gem::Version
|
|
220
222
|
version: '0'
|
|
221
223
|
requirements: []
|
|
222
|
-
rubygems_version: 3.
|
|
224
|
+
rubygems_version: 3.2.22
|
|
223
225
|
signing_key:
|
|
224
226
|
specification_version: 4
|
|
225
227
|
summary: configuration library
|