norikra 0.0.22-java → 0.0.23-java

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.
@@ -52,8 +52,14 @@ module Norikra
52
52
  ary
53
53
  else # Hash
54
54
  obj.map {|k,v|
55
- if v.is_a?(Hash) || v.is_a?(Array)
56
- dig.call(v).map{|chain| [k] + chain}
55
+ if k.nil?
56
+ []
57
+ elsif v.is_a?(Hash) || v.is_a?(Array)
58
+ if v.empty?
59
+ []
60
+ else
61
+ dig.call(v).map{|chain| [k] + chain}
62
+ end
57
63
  else
58
64
  [[k, v]]
59
65
  end
@@ -1,3 +1,3 @@
1
1
  module Norikra
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
@@ -81,6 +81,31 @@ describe Norikra::FieldSet do
81
81
  expect(leaves[3]).to eql(['f1', 1, 4])
82
82
  expect(leaves[4]).to eql(['f2', 5])
83
83
  end
84
+
85
+ it 'does not return leaves with keys nil' do
86
+ leaves = Norikra::FieldSet.leaves({'f1' => [{'fz1' => 1, nil => {'fz3' => 2, 'fz4' => 3}}, 4], nil => 5})
87
+ expect(leaves.size).to eql(2)
88
+ expect(leaves[0]).to eql(['f1', 0, 'fz1', 1])
89
+ expect(leaves[1]).to eql(['f1', 1, 4])
90
+ end
91
+
92
+ it 'return leaves with values nil' do
93
+ leaves = Norikra::FieldSet.leaves({'f1' => [{'fz1' => 1}, nil, 4], 'f2' => 5, 'f3' => nil})
94
+ expect(leaves.size).to eql(5)
95
+ expect(leaves[0]).to eql(['f1', 0, 'fz1', 1])
96
+ expect(leaves[1]).to eql(['f1', 1, nil])
97
+ expect(leaves[2]).to eql(['f1', 2, 4])
98
+ expect(leaves[3]).to eql(['f2', 5])
99
+ expect(leaves[4]).to eql(['f3', nil])
100
+ end
101
+
102
+ it 'does not return leaves with empty containers' do
103
+ leaves = Norikra::FieldSet.leaves({'f1' => [{'fz1' => 1, 'fz2' => {}}, 4], 'f2' => 5, 'f3' => []})
104
+ expect(leaves.size).to eql(3)
105
+ expect(leaves[0]).to eql(['f1', 0, 'fz1', 1])
106
+ expect(leaves[1]).to eql(['f1', 1, 4])
107
+ expect(leaves[2]).to eql(['f2', 5])
108
+ end
84
109
  end
85
110
 
86
111
  describe '.field_names_key' do
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: norikra
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.22
5
+ version: 0.0.23
6
6
  platform: java
7
7
  authors:
8
8
  - TAGOMORI Satoshi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-29 00:00:00.000000000 Z
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mizuno