json_to_ruby_class 0.1.0 → 0.1.1

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: addb9a72b44178eb7921de8d8e3b4c4c9fd27b90
4
- data.tar.gz: 57e310648396fb7ae530ccefb1c8a6e69de2dd69
3
+ metadata.gz: 2d4b496618f50ce3db3c2289f2b45b0b061401f3
4
+ data.tar.gz: e42dbca984291f936ac947c5feee50ee9dcfb336
5
5
  SHA512:
6
- metadata.gz: feccf03bcb6e136a3d6a58485376983139c3090da424f13a577492a107fe915a4af958cfb62c7c54fe895ba0a6d5e309d4071af991e27fc87c1d2cec1a56d98b
7
- data.tar.gz: 1e334624e3fc4593d0e51360724bf6546077161c7451a8899f150c502e0e33580ff9e5e29925c086278fe0fde8372e55b4ed79b7aa30d6d88352ba97cacd0aa0
6
+ metadata.gz: 472017c0bb8540751f2d9501d4b3fc99e2cad8170c9cb297c863cb3ac63a02cd5ff43d9fd099a1a61159c04325d2a1a115c9543bf07d18c13b4c11d68a9669a7
7
+ data.tar.gz: bcaf802d4be506ac8689fede841269badafab01c8540efde8ede556d92d945ce16b258573ec8dfd3fcbd7cb90b58b2cebec27e7c9ad859324c01712129886aba
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 0.1.1 (2016-07-09)
2
+
3
+ Bug fixes
4
+ * Remove duplicate attributes from the same model
5
+
6
+ ## 0.1.0 (2016-07-09)
7
+
8
+ * Initial commit
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # JsonToRubyClass
2
2
 
3
+ [![Build Status](https://travis-ci.org/arcanoid/json_to_ruby_class.svg?branch=master)](https://travis-ci.org/arcanoid/json_to_ruby_class)
4
+
3
5
  JsonToRubyClass is a gem that converts a JSON to a list of Ruby classes and outputs it into a string.
4
6
 
5
7
  ## Installation
@@ -20,7 +22,38 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
25
+ ```ruby
26
+ json = {
27
+ "students": [
28
+ {
29
+ "firstName": "John",
30
+ "lastName": "Doe",
31
+ "age": 15
32
+ },
33
+ {
34
+ "firstName": "Anna",
35
+ "lastName": "Smith",
36
+ "age": 16
37
+ }
38
+ ]
39
+ }
40
+
41
+ puts JsonToRubyClass.produce_models(json)
42
+ ```
43
+
44
+ This produces the following:
23
45
 
46
+ ```ruby
47
+ Class Student
48
+ attr_accessor :first_name,
49
+ :last_name,
50
+ :age
51
+ end
52
+
53
+ Class Example
54
+ attr_accessor :students
55
+ end
56
+ ```
24
57
 
25
58
  ## Development
26
59
 
@@ -1,3 +1,3 @@
1
1
  module JsonToRubyClass
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -32,7 +32,7 @@ module JsonToRubyClass
32
32
  accessors_to_be_used = accessors.map { |s| ":#{s.to_s.underscore}" }
33
33
 
34
34
  if (hash = existing_models_array.find { |model| model[:name] == model_name_to_be_used })
35
- hash[:accessors].push(accessors_to_be_used).uniq!
35
+ hash[:accessors].push(accessors_to_be_used).flatten!.uniq!
36
36
  else
37
37
  existing_models_array << {
38
38
  :name => (model_name.nil? ? 'Example' : model_name.to_s.camelcase),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_to_ruby_class
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasilis Kalligas
@@ -62,6 +62,7 @@ files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
64
  - ".travis.yml"
65
+ - CHANGELOG.md
65
66
  - CODE_OF_CONDUCT.md
66
67
  - Gemfile
67
68
  - LICENSE.txt