jsos 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -0
  4. data/jsos.gemspec +1 -1
  5. data/lib/jsos.rb +11 -1
  6. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d441cffbf9bb670f441a13fa351d1cad6970af3
4
- data.tar.gz: 6ccb84d6350854b0ee6e859404087163669ff49f
3
+ metadata.gz: a9412f7bbfd53a242bd550d7a7b9369a1bb61baf
4
+ data.tar.gz: de58cc657d6a008c89476e05fb8203acd3b993a4
5
5
  SHA512:
6
- metadata.gz: b822ba701f192cd25076818b23123a112affb0774012404f52acad154418ed0525a5218e130e31c7b94cb2b0f2a055e669d3fd3d0707e17c20edcf8fd1f26961
7
- data.tar.gz: cd6d096acc2a6cf5ee0e0cba723bec0acc83ad8deffd3da61f5657cd06821a197495856e450199a6ff894951513df97c8a2a82b50c25cc41aaf2602aaf8d44a0
6
+ metadata.gz: 5463f4da5331a4c2b5501308a2481c8ca57daacc070b6fe8e8e1ffbc740a31b002eee4cd57ce73e88aa01ecfec3a170e5bca5e6b29dc07031d46b306f5b88c3c
7
+ data.tar.gz: bc204f6bdf1b43be6fd98ff5e15c872af2845f4425a2b84c5f4e20d4aeff7cee3fafc74cc30e34367088d03d54269e3760673068d0a874e2c30de92d52ed36ff
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # CHANGELOG
2
+
3
+ ## v1.0.1 (Jan 07, 2016)
4
+ * Fix issue where initial nested data was not converted into new JSOS objects (#1)
5
+ * Create CHANGELOG
6
+
7
+ ## v1.0.0 (Dec 31, 2015)
8
+ * Initial release
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # JSOS
2
2
  [![Build Status](https://travis-ci.org/jdenen/jsos.svg?branch=master)](https://travis-ci.org/jdenen/jsos)
3
+ [![Gem Version](https://badge.fury.io/rb/jsos.svg)](https://badge.fury.io/rb/jsos)
3
4
 
4
5
  Use Ruby's OpenStruct object to represent JSON strings, making nested data a method call away.
5
6
 
data/jsos.gemspec CHANGED
@@ -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.0.0"
7
+ spec.version = "1.0.1"
8
8
  spec.authors = ["Johnson Denen"]
9
9
  spec.email = ["johnson.denen@gmail.com"]
10
10
 
data/lib/jsos.rb CHANGED
@@ -42,7 +42,9 @@ class JSOS < OpenStruct
42
42
 
43
43
  # @param state [String|Hash] defaults to nil
44
44
  def initialize(state = nil)
45
- state.is_a?(String) ? super(JSON.parse state) : super(state)
45
+ return super if state.nil?
46
+ state_hash = state.is_a?(String) ? JSON.parse(state) : state
47
+ super parse_state_hash(state_hash)
46
48
  end
47
49
 
48
50
  # @return [Hash]
@@ -83,4 +85,12 @@ class JSOS < OpenStruct
83
85
  def make_setter getter
84
86
  getter.to_s.concat('=').to_sym
85
87
  end
88
+
89
+ # @api private
90
+ def parse_state_hash state
91
+ state.inject({}) do |hash, (key, value)|
92
+ merge_value = value.is_a?(Hash) ? {key => JSOS.new(value)} : {key => value}
93
+ hash.merge(merge_value)
94
+ end
95
+ end
86
96
  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.0.0
4
+ version: 1.0.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: 2015-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
105
  - ".travis.yml"
106
+ - CHANGELOG.md
106
107
  - Gemfile
107
108
  - LICENSE.txt
108
109
  - README.md