recursive-open-struct 0.6.4 → 0.6.5

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: 7067232359a27f9453674a17396798cb42b085d4
4
- data.tar.gz: 88fbfa54a7bff4548ab752ae681309afda312923
3
+ metadata.gz: 16edd384bbe19b6efc58d29e12740a3756f6e51a
4
+ data.tar.gz: 97ad4a2805226395ef2df02f61f5482b37bc047f
5
5
  SHA512:
6
- metadata.gz: 50a3ea326db6026dfa417ecb81919ecda0e1b997753ea908a28c22281a9586d8b081b33dee0bacafb12ab65f568f91646237386d40d46a0bd070159a4bd3c594
7
- data.tar.gz: bec50eceabca004115b14b176caf67253fa7b06414552d2051cc4d3502508c5a3fbab27f08027907aba1e7571391a03e92ac4c04a3260aa870b651f9eb8a785b
6
+ metadata.gz: 731c64834e1e18e6bcb2cd43fb112b6e87ebbabc6d63e31ce8cafaeb377e56f8601f2b9dcc4f02ecc2282f9a11c4176bb3dcd4f592e4126dad5ec6f9f4caf249
7
+ data.tar.gz: 173c905112efdc0d907af7de0730af75dd27fc733bd90a591bcb626048d5bb978c001d6e695b618db7204e214f17129ead2953c4fb573572da9ecd87ccd0280b
@@ -1,3 +1,8 @@
1
+ 0.6.5 / 2015-06-30
2
+ ==================
3
+
4
+ * FIX: Fix ROS when initialized with nil instead of a hash.
5
+
1
6
  0.6.4 / 2015-05-20
2
7
  ==================
3
8
 
@@ -9,7 +9,8 @@ class RecursiveOpenStruct < OpenStruct
9
9
  include Ruby19Backport if RUBY_VERSION =~ /\A1.9/
10
10
  include DebugInspect
11
11
 
12
- def initialize(hash={}, args={})
12
+ def initialize(hash=nil, args={})
13
+ hash ||= {}
13
14
  @recurse_over_arrays = args.fetch(:recurse_over_arrays, false)
14
15
  @deep_dup = DeepDup.new(recurse_over_arrays: @recurse_over_arrays)
15
16
 
@@ -3,5 +3,5 @@
3
3
  require 'ostruct'
4
4
 
5
5
  class RecursiveOpenStruct < OpenStruct
6
- VERSION = "0.6.4"
6
+ VERSION = "0.6.5"
7
7
  end
@@ -12,6 +12,23 @@ describe RecursiveOpenStruct do
12
12
  ros.blah = "John Smith"
13
13
  expect(ros.blah).to eq "John Smith"
14
14
  end
15
+
16
+ it 'returns nil for missing attributes' do
17
+ expect(ros.foo).to be_nil
18
+ end
19
+ end
20
+
21
+ context 'when initialized with nil' do
22
+ let(:hash) { nil }
23
+ it 'returns nil for missing attributes' do
24
+ expect(ros.foo).to be_nil
25
+ end
26
+ end
27
+
28
+ context 'when initialized with an empty hash' do
29
+ it 'returns nil for missing attributes' do
30
+ expect(ros.foo).to be_nil
31
+ end
15
32
  end
16
33
 
17
34
  context "when initialized from a hash" do
@@ -5,7 +5,7 @@ describe RecursiveOpenStruct do
5
5
 
6
6
  describe "recursive behavior" do
7
7
  let(:h) { { :blah => { :another => 'value' } } }
8
- subject { RecursiveOpenStruct.new(h) }
8
+ subject(:ros) { RecursiveOpenStruct.new(h) }
9
9
 
10
10
  it "can convert the entire hash tree back into a hash" do
11
11
  blank_obj = Object.new
@@ -280,5 +280,16 @@ describe RecursiveOpenStruct do
280
280
  end
281
281
  end # modifying an array and then recursing
282
282
  end # recursing over arrays
283
+
284
+ describe 'nested nil values' do
285
+ let(:h) { { foo: { bar: nil }} }
286
+ it 'returns nil' do
287
+ expect(subject.foo.bar).to be_nil
288
+ end
289
+
290
+ it 'returns a hash with the key and a nil value' do
291
+ expect(subject.to_hash).to eq({ foo: { bar: nil }})
292
+ end
293
+ end # nested nil values
283
294
  end # recursive behavior
284
295
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recursive-open-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - William (B.J.) Snow Orvis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler