fedux_org-stdlib 0.9.5 → 0.9.6
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 +23 -1
- 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: 2bc1979d804f1f5ae8a0e848eeeb2bbb2dd1f6f7
|
4
|
+
data.tar.gz: 366a494106df785d9414a99a85fa75b59eb91e73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05d1baba5c6dc9aee2668573546b2b6c157321381b88e0b2674a71cbe22ec8a12bc55e2c6baf674e00f0f259722aeef9f5b08fd16b616498ebbdb8e026f666b9
|
7
|
+
data.tar.gz: 30af0bab6bcf6e354b1489ae5f9d87a01d3a9cfe9dde1cb9fb715b061e330a48607b50bf768b56910e24c1d5295aa3554a4293d9510970c34090712cad4bf3cf
|
data/Gemfile.lock
CHANGED
@@ -276,8 +276,13 @@ module FeduxOrgStdlib
|
|
276
276
|
config
|
277
277
|
end
|
278
278
|
|
279
|
-
def to_h(keys:
|
280
|
-
known_options.
|
279
|
+
def to_h(keys: [], remove_blank: false)
|
280
|
+
options_to_check = known_options.delete_if { |o| !keys.blank? && !keys.include?(o) }
|
281
|
+
|
282
|
+
options_to_check.each_with_object({}) do |e, a|
|
283
|
+
next if remove_blank && self.public_send(e).blank?
|
284
|
+
a[e] = self.public_send(e)
|
285
|
+
end
|
281
286
|
end
|
282
287
|
|
283
288
|
def to_yaml(**args)
|
data/spec/app_config_spec.rb
CHANGED
@@ -576,7 +576,7 @@ RSpec.describe AppConfig do
|
|
576
576
|
)
|
577
577
|
end
|
578
578
|
|
579
|
-
it 'filters keys' do
|
579
|
+
it 'filters keys by name' do
|
580
580
|
config_klass = Class.new(AppConfig) do
|
581
581
|
option :opt1, 'test1'
|
582
582
|
|
@@ -603,6 +603,28 @@ RSpec.describe AppConfig do
|
|
603
603
|
opt1: 'test1'
|
604
604
|
)
|
605
605
|
end
|
606
|
+
|
607
|
+
it 'filters keys if nil' do
|
608
|
+
config_klass = Class.new(AppConfig) do
|
609
|
+
option :opt1, 'test1'
|
610
|
+
option :opt2, []
|
611
|
+
option :opt3, {}
|
612
|
+
option :opt4, nil
|
613
|
+
|
614
|
+
def _class_name
|
615
|
+
'TestConfig'
|
616
|
+
end
|
617
|
+
|
618
|
+
def _module_name
|
619
|
+
'MyApplication'
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
config = config_klass.new
|
624
|
+
expect(config.to_h(remove_blank: true)).to eq(
|
625
|
+
opt1: 'test1'
|
626
|
+
)
|
627
|
+
end
|
606
628
|
end
|
607
629
|
|
608
630
|
context '#to_yaml' do
|