fedux_org-stdlib 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fedux_org_stdlib/app_config.rb +7 -2
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/spec/app_config_spec.rb +26 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc0a196b126b4e30907761028202f93c5af01d7b
|
4
|
+
data.tar.gz: 031a51de4aaa8ff386e361d9cfdeb99ff12640f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2efff3e23bc3088d79fe548b155490a76acd412840f58b2e3a52b19396b734e4a5a689b9de63a1926c6120cc72e0bb5f09b3aa51e0fb87646ea37a70e752dc4
|
7
|
+
data.tar.gz: 1c6ecf6db87829858c3a5395c26b8fa28730d21f1e169818bd01b0384b804fdf4effa8dc3133be07093903b8295ac73a76eb6d85a0e0f7d3436f6584d440b42e
|
data/Gemfile.lock
CHANGED
@@ -71,7 +71,7 @@ module FeduxOrgStdlib
|
|
71
71
|
class AppConfig
|
72
72
|
class << self
|
73
73
|
|
74
|
-
#
|
74
|
+
# @api private
|
75
75
|
def known_options
|
76
76
|
@options ||= Set.new
|
77
77
|
end
|
@@ -205,7 +205,7 @@ module FeduxOrgStdlib
|
|
205
205
|
elsif yaml.kind_of? Hash
|
206
206
|
yaml = yaml.deep_symbolize_keys
|
207
207
|
|
208
|
-
yaml_withknown_options = yaml.deep_symbolize_keys.slice(*self.
|
208
|
+
yaml_withknown_options = yaml.deep_symbolize_keys.slice(*self.known_options)
|
209
209
|
unknown_options = yaml.keys - yaml_withknown_options.keys
|
210
210
|
|
211
211
|
logger.warn "Unknown config options #{(unknown_options).to_list} in config file #{file} detected. Please define them in your config class or remove the entries in your config file or disable check via `check_unknown_options: false` to get rid of this warning." unless unknown_options.blank? && check_unknown_options == true
|
@@ -217,6 +217,11 @@ module FeduxOrgStdlib
|
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
|
+
# Show known options for configuration
|
221
|
+
def known_options
|
222
|
+
self.class.known_options
|
223
|
+
end
|
224
|
+
|
220
225
|
# Lock the configuration
|
221
226
|
def lock
|
222
227
|
_config.freeze
|
data/spec/app_config_spec.rb
CHANGED
@@ -371,6 +371,7 @@ RSpec.describe AppConfig do
|
|
371
371
|
option :opt1, nil
|
372
372
|
option :opt2, ''
|
373
373
|
option :opt3, 'asdf'
|
374
|
+
option :opt4, false
|
374
375
|
|
375
376
|
def _class_name
|
376
377
|
'TestConfig'
|
@@ -388,8 +389,33 @@ RSpec.describe AppConfig do
|
|
388
389
|
opt1 | "is undefined"
|
389
390
|
opt2 | "is undefined"
|
390
391
|
opt3 | "asdf"
|
392
|
+
opt4 | "false"
|
391
393
|
EOS
|
392
394
|
end
|
393
395
|
end
|
394
396
|
end
|
397
|
+
|
398
|
+
context '#known_options' do
|
399
|
+
it 'outputs a list of known options' do
|
400
|
+
with_environment 'HOME' => working_directory do
|
401
|
+
config_klass = Class.new(AppConfig) do
|
402
|
+
option :opt1, 'test1'
|
403
|
+
option :opt2, 'test2'
|
404
|
+
option :opt3, { opt1: 'test1', opt2: 'test2' }
|
405
|
+
|
406
|
+
def _class_name
|
407
|
+
'TestConfig'
|
408
|
+
end
|
409
|
+
|
410
|
+
def _module_name
|
411
|
+
'MyApplication'
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
config = config_klass.new
|
416
|
+
expect(config.known_options).to include :opt1, :opt2, :opt3
|
417
|
+
expect(config.class.known_options).to eq config.known_options
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
395
421
|
end
|