recursive-open-struct 0.6.2 → 0.6.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 765e14c47a76030b5a36300eea04264d3a9daf19
4
- data.tar.gz: 8370dfc8bde5246291aec3594f3d27ea0162194c
3
+ metadata.gz: a1f1a8f65c6217fb268d9cb42d7a862c17331c9a
4
+ data.tar.gz: 0ac4e5cd8da82078b32e3c782668e1446f2383bb
5
5
  SHA512:
6
- metadata.gz: 05fea524625e1b5cef5cae0ca8e6aa46e459802cc93be57984e8cc7586c797221fa65d57e02c95f1cf0e73f2745110ddfb2478b3153431f51b9113c62987fd7f
7
- data.tar.gz: a2459d5a3655c0aa1508a7e3d52f6ff45a9ccbac695b404acb6f902e3fc343a8a85237ae897d8f9af4fea93b218d1f39aab98e55a7bc0ef0d434a50c319a7ce8
6
+ metadata.gz: 3ccb7649bea9011276fa62f1f5e1d22956446d846d41320616e1a1b83738bf1ede1baa128cc9fa2d283e1b591dbc8f765dcbde1f64ffd7a367535edda95114e1
7
+ data.tar.gz: 5c762d9925b274435e1753b1c24b4b4e84ddc49f84cc2780c40e39fd01aa803eb071b8f9afc1484aa974500fa08a34ccaf5c12602bafeb55131a22483b413ec3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.6.3 / 2015-04-11
2
+ ==================
3
+
4
+ * FIX: Thiago Guimaraes: Restore being able to create an ROS from a hash that
5
+ contains strings for keys instead of symbols for keys.
6
+
1
7
  0.6.2 / 2015-04-07
2
8
  ==================
3
9
 
@@ -12,7 +12,7 @@ class RecursiveOpenStruct < OpenStruct
12
12
  @deep_dup = DeepDup.new(recurse_over_arrays: @recurse_over_arrays)
13
13
 
14
14
  @table = args.fetch(:mutate_input_hash, false) ? hash : @deep_dup.call(hash)
15
- @table && @table.each_key { |k| new_ostruct_member(k.to_sym) }
15
+ @table && @table.each_key { |k| new_ostruct_member(k) }
16
16
 
17
17
  @sub_elements = {}
18
18
  end
@@ -22,7 +22,7 @@ class RecursiveOpenStruct < OpenStruct
22
22
 
23
23
  # Apply fix if necessary:
24
24
  # https://github.com/ruby/ruby/commit/2d952c6d16ffe06a28bb1007e2cd1410c3db2d58
25
- @table.each_key{|key| new_ostruct_member(key)} if RUBY_VERSION =~ /^1.9/
25
+ @table.each_key{|key| new_ostruct_member(key)} if RUBY_VERSION =~ /^1.9/
26
26
 
27
27
  # deep copy the table to separate the two objects
28
28
  @table = @deep_dup.call(orig.instance_variable_get(:@table))
@@ -41,7 +41,6 @@ class RecursiveOpenStruct < OpenStruct
41
41
  end
42
42
 
43
43
  def new_ostruct_member(name)
44
- name = name.to_sym
45
44
  unless self.respond_to?(name)
46
45
  class << self; self; end.class_eval do
47
46
  define_method(name) do
@@ -3,5 +3,5 @@
3
3
  require 'ostruct'
4
4
 
5
5
  class RecursiveOpenStruct < OpenStruct
6
- VERSION = "0.6.2"
6
+ VERSION = "0.6.3"
7
7
  end
@@ -11,10 +11,18 @@ describe RecursiveOpenStruct do
11
11
  ros.blah.should == "John Smith"
12
12
  end
13
13
 
14
- it "can be created from a hash" do
15
- h = { :asdf => 'John Smith' }
16
- ros = RecursiveOpenStruct.new(h)
17
- ros.asdf.should == "John Smith"
14
+ context "can be created from a hash" do
15
+ it "and keys are instanced as symbol" do
16
+ h = { :asdf => 'John Smith' }
17
+ ros = RecursiveOpenStruct.new(h)
18
+ ros.asdf.should == "John Smith"
19
+ end
20
+
21
+ it "and keys are instanced as string" do
22
+ h = { "asdf" => 'John Smith' }
23
+ ros = RecursiveOpenStruct.new(h)
24
+ ros.asdf.should == "John Smith"
25
+ end
18
26
  end
19
27
 
20
28
  it "can modify an existing key" do
@@ -154,7 +162,7 @@ describe RecursiveOpenStruct do
154
162
  RecursiveOpenStruct.new(
155
163
  { :blah => original_blah }, :recurse_over_arrays => true)
156
164
  end
157
-
165
+
158
166
  before(:each) { subject.blah } # enforce memoization
159
167
 
160
168
  context "when modifying an entire Hash" do
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.2
4
+ version: 0.6.3
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-04-08 00:00:00.000000000 Z
11
+ date: 2015-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler