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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95421cf63a2b9cfc2aadba02729ec31edb4f9c23
4
- data.tar.gz: 88d4e3448de789088dd0091a665c362c4ee8215b
3
+ metadata.gz: 2bc1979d804f1f5ae8a0e848eeeb2bbb2dd1f6f7
4
+ data.tar.gz: 366a494106df785d9414a99a85fa75b59eb91e73
5
5
  SHA512:
6
- metadata.gz: 152515d3efef6302211cedec9d75450aaca7ff5ed7dda382f309d526796a8c496b1f9003bd33c5cb151bd04d9b8713c7dd348724862a11d21a1d69547c2efafc
7
- data.tar.gz: b252e98113cd114a7cf8a0a61e3e604a958e9eaeddb162970bfaacb47003a6a4a560b6a1821202d63339667ede7d6b308419144d875f0e5addc1af22832b0f27
6
+ metadata.gz: 05d1baba5c6dc9aee2668573546b2b6c157321381b88e0b2674a71cbe22ec8a12bc55e2c6baf674e00f0f259722aeef9f5b08fd16b616498ebbdb8e026f666b9
7
+ data.tar.gz: 30af0bab6bcf6e354b1489ae5f9d87a01d3a9cfe9dde1cb9fb715b061e330a48607b50bf768b56910e24c1d5295aa3554a4293d9510970c34090712cad4bf3cf
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fedux_org-stdlib (0.9.4)
4
+ fedux_org-stdlib (0.9.5)
5
5
  activesupport
6
6
 
7
7
  PATH
@@ -276,8 +276,13 @@ module FeduxOrgStdlib
276
276
  config
277
277
  end
278
278
 
279
- def to_h(keys: known_options.to_a)
280
- known_options.keep_if { |o| keys.include? o }.each_with_object({}) { |e, a| a[e] = self.public_send(e) }
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)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # FeduxOrgStdlib
3
3
  module FeduxOrgStdlib
4
- VERSION = '0.9.5'
4
+ VERSION = '0.9.6'
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedux_org-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer