recursive-open-struct 1.0.1 → 1.0.2

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: 91f6b03b9d7a4cb152dda016d3aa9aae975552cc
4
- data.tar.gz: d8b1c74c38127a90cd894e7ebff086e0b372ccc5
3
+ metadata.gz: 12d07e25ed0f3cedb3b40ede9f61407ea53a9927
4
+ data.tar.gz: a485cfb540bfb5bd8c91c423e51d54178667c43d
5
5
  SHA512:
6
- metadata.gz: 92e7c17033509bc5eab4e2dabe5617e5a602619cd65eda8a40a2c828a456f1d73160a34f37c3e435bd8be786ec00d0e62e277bf0e6f610ae06ff1dfd978f3a11
7
- data.tar.gz: 910614754bb46ad7dab007675af3a4cefc223fe724ad767c10d9a9f9c443385747cc5e25af671d46acfb219a47505e5b8322043dbddc7b6aabbf8a51892a1433
6
+ metadata.gz: 6e15e67bbc323ae60734aebe7a5f124c35ff96b22589ec295c8a6e374390ba9b869e9e34f0f1b04c5079853b950e77f0cdbb5b55933ce908f8bf66b012c23a65
7
+ data.tar.gz: 2d1466d7c584cf5d969ab5ae49ba5c79f17ef85fd86001e56ecac64e0317c92449c87b89dfc6d20ac4b7c372a6bc0eb560b8d3b44e942ba02d0810fc3f660fe8
data/.gitignore CHANGED
@@ -48,3 +48,5 @@ tmtags
48
48
  #*.rbc
49
49
 
50
50
  Gemfile.lock
51
+
52
+ .ruby-version
data/.travis.yml CHANGED
@@ -2,11 +2,12 @@
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.0.0
5
- - 2.1.7
6
- - 2.2.3
7
- - 2.3.0
5
+ - 2.1.10
6
+ - 2.2.5
7
+ - 2.3.1
8
+ - 2.4.0
8
9
  - ruby-head
9
10
  - jruby-19mode
10
- - jruby-9.0.0.0
11
+ - jruby-9.0.5.0
11
12
  - jruby-head
12
13
  sudo: false
data/AUTHORS.txt CHANGED
@@ -7,6 +7,7 @@ Recursive-open-struct was written by these fine people:
7
7
  * Matt Culpepper <matt@culpepper.co>
8
8
  * Matthew O'Riordan <matthew.oriordan@gmail.com>
9
9
  * Offirmo <offirmo.net@gmail.com>
10
+ * Pedro Sena <sena.pedro@gmail.com>
10
11
  * Peter Yeremenko <peter.yeremenko@gmail.com>
11
12
  * Sebastian Gaul <sebastian@mgvmedia.com>
12
13
  * Thiago Guimaraes <thiagogsr@gmail.com>
data/Rakefile CHANGED
@@ -53,3 +53,8 @@ task :update_authors do
53
53
  end
54
54
 
55
55
  task :build => [:update_authors, :fix_permissions]
56
+
57
+ desc "Run an interactive pry shell with ros required"
58
+ task :pry do
59
+ sh "pry -I lib -r recursive-open-struct"
60
+ end
@@ -116,15 +116,15 @@ class RecursiveOpenStruct < OpenStruct
116
116
  end
117
117
 
118
118
  def recurse_over_array(array)
119
- array.map do |a|
119
+ array.each_with_index do |a, i|
120
120
  if a.is_a? Hash
121
- self.class.new(a, :recurse_over_arrays => true, :mutate_input_hash => true)
121
+ array[i] = self.class.new(a, :recurse_over_arrays => true,
122
+ :mutate_input_hash => true, :preserve_original_keys => @preserve_original_keys)
122
123
  elsif a.is_a? Array
123
- recurse_over_array a
124
- else
125
- a
124
+ array[i] = recurse_over_array a
126
125
  end
127
126
  end
127
+ array
128
128
  end
129
129
 
130
130
  end
@@ -17,6 +17,7 @@ class RecursiveOpenStruct::DeepDup
17
17
  end
18
18
  elsif obj.is_a?(Array) && @recurse_over_arrays
19
19
  obj.each_with_object([]) do |value, arr|
20
+ value = value.is_a?(RecursiveOpenStruct) ? value.to_h : value
20
21
  arr << value_or_deep_dup(value, visited)
21
22
  end
22
23
  else
@@ -3,5 +3,5 @@
3
3
  require 'ostruct'
4
4
 
5
5
  class RecursiveOpenStruct < OpenStruct
6
- VERSION = "1.0.1"
6
+ VERSION = "1.0.2"
7
7
  end
@@ -261,6 +261,10 @@ describe RecursiveOpenStruct do
261
261
  it "ROS's it" do
262
262
  expect(subject.mystery.science[0].theatre).to eq 9000
263
263
  end
264
+
265
+ specify "the changes show up in .to_h" do
266
+ expect(subject.to_h).to eq({ mystery: { science: [{theatre: 9000}]}})
267
+ end
264
268
  end
265
269
 
266
270
  context 'after appending a hash to an array' 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: 1.0.1
4
+ version: 1.0.2
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: 2016-01-18 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler