jsoning 0.1.0 → 0.2.0

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: e4d959011ca794ad4e783b547f7cbfe0e503cbb7
4
- data.tar.gz: 4c6fea6be0eac306f0ffe0c7e5bd30c622e8efda
3
+ metadata.gz: ab99aea4b1e32c8cb1dd3b9ef9629de18fe57af5
4
+ data.tar.gz: c33e1687f59d31bed9ddbf1d299b9ad9b1bc81e5
5
5
  SHA512:
6
- metadata.gz: 699d0e152d55a6724a46dd6c35c5cc3840e69ee9f5c5f28d79c755e208635596b92d80193c4b5c0f12208e5d00a87aa5f5c80edf4a3d4e0ef8fa3628e7c12863
7
- data.tar.gz: 1cfff70c84f877c08397c6511922b0b5c2415b4eff8059177ed6b86a11e315ae5d6037ab16acae3e12cc0acac6e41f93b4693290b9bd3b113e08ee24f4189999
6
+ metadata.gz: bf0371b9055dce314f1a4400f192de4dbe1f886761d2accf30816d6256db22a1aae8175d9ea755a5d8327bb88dfce74dd77920c13482d872940a292cd8f508c8
7
+ data.tar.gz: 5607608a6b053dfc67bd37952da6e590e56e015ce012fd7701e5702b85becbe651b61f8c203dc8e5f62276782a520cc9de58d1b4dca7190e0f1c379ef2564cc6
data/README.md CHANGED
@@ -23,6 +23,11 @@ Or install it yourself as:
23
23
 
24
24
  $ gem install jsoning
25
25
 
26
+ ## What it can do?
27
+
28
+ 1. Generating JSON from your object
29
+ 2. Generating Hash from your object
30
+
26
31
  ## Assumptions
27
32
 
28
33
  We have classes already defined as follow:
@@ -164,7 +169,33 @@ Jsoning the user with pretty set to true, will return:
164
169
  }
165
170
  ```
166
171
 
167
- Wish it to be helpful for you! Enjoy!
172
+ ## Returning Hash
173
+
174
+ It is also possible to return hash as well:
175
+
176
+ ```ruby
177
+ Jsoning[user]
178
+ ```
179
+
180
+ The syntax above will return ruby hash object:
181
+
182
+ ```ruby
183
+ {"name"=>"Adam Baihaqi",
184
+ "years_old"=>21,
185
+ "gender"=>"male",
186
+ "books"=>[{"name"=>"Quiet: The Power of Introvert"}, {"name"=>"Harry Potter and the Half-Blood Prince"}],
187
+ "degree_detail"=>{"faculty"=>"School of IT", "degree"=>"B.Sc. (Hons) Computer Science"}}
188
+ ```
189
+
190
+ ## Changelog
191
+
192
+ == Version 0.1.0
193
+
194
+ 1. Ability to turn object into JSON
195
+
196
+ == Version 0.2.0
197
+
198
+ 2. Ability to turn object into a hash
168
199
 
169
200
  ## License
170
201
 
data/lib/jsoning.rb CHANGED
@@ -41,6 +41,11 @@ module Jsoning
41
41
  protocol.generate(object, options)
42
42
  end
43
43
 
44
+ def self.[](object)
45
+ protocol = protocol_for!(object.class)
46
+ protocol.parse(object)
47
+ end
48
+
44
49
  # monkey patch Kernel
45
50
  module ::Kernel
46
51
  private
@@ -1,3 +1,3 @@
1
1
  module Jsoning
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsoning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Pahlevi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-30 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler