jsos 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/jsos.gemspec +1 -1
  4. data/lib/jsos.rb +10 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98bbf0dc84ae37f267f3f795ec596ca7fbde666e
4
- data.tar.gz: cbcbf2375ece3fb7501ad39ef1fa1e937d2a73f1
3
+ metadata.gz: 42368bd5dfcd62a8c2ac7ec27b1100111fc793d0
4
+ data.tar.gz: 2338e2c122d978363754716eba8b80669528bc72
5
5
  SHA512:
6
- metadata.gz: dc8179e390b241bd32a276cb245aff3e58df030f60b17ba2a2a6a09a21c5a7a4278a250a4141384013c6f33e92868a5e518cd37c25372211146876a77889eb35
7
- data.tar.gz: 4f4636e94061e28093149c2c795cba5f22cb8c9647edf0178f1cdc4c8f8298c65fb3d46c606e8391e8c8b8dc743e7feb6e296668ad34e38b958d9a8487fca48b
6
+ metadata.gz: b17d9d0aafc1c2cfb768513379172be5874ebd8ad7b08217f8d46b0e6ad2723dbef8bd8b8c6f4b9e845e7038124bc1ebb822afafa33a43c2db0880a6236d710e
7
+ data.tar.gz: 71303c8f44bab7986a0118fa27bc153ee1837b139eccf97db1085a40a550e0d7397ffbcc1915b4a754018cfad35b2a5de025386825799fb93eb51be2034f936d
@@ -1,5 +1,19 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.2.1 (Feb 08, 2016)
4
+ * Hashes are converted into JSOS objects when part of an array value
5
+
6
+ ```ruby
7
+ json = "{\"foo\":[{\"foo\":\"bar\"}, \"baz\"]}"
8
+ jsos = JSOS.new(json)
9
+
10
+ jsos.foo
11
+ #=> ["#<JSOS foo=\"bar\">", "baz"]
12
+
13
+ jsos.foo.first.foo
14
+ #=> "bar"
15
+ ```
16
+
3
17
  ## v1.2.0 (Jan 13, 2016)
4
18
  * Add `JSOS#to_a`
5
19
  * Alias `JSOS#to_a` to `JSOS#to_ary`
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "jsos"
7
- spec.version = "1.2.0"
7
+ spec.version = "1.2.1"
8
8
  spec.authors = ["Johnson Denen"]
9
9
  spec.email = ["johnson.denen@gmail.com"]
10
10
 
@@ -109,7 +109,16 @@ class JSOS < OpenStruct
109
109
  # @api private
110
110
  def parse_state_hash state
111
111
  state.inject({}) do |hash, (key, value)|
112
- merge_value = value.is_a?(Hash) ? {key => JSOS.new(value)} : {key => value}
112
+ merge_value = case value
113
+ when Hash
114
+ { key => JSOS.new(value) }
115
+ when Array
116
+ array = value.map{ |v| JSOS.new(v) rescue v }
117
+ { key => array }
118
+ else
119
+ { key => value }
120
+ end
121
+
113
122
  hash.merge(merge_value)
114
123
  end
115
124
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnson Denen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler