json_schema_tools 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWMzMmM0YmMzMDY4YmVhMjQ4MjI4Nzk1MGQwNTVjYzFiYTNlM2Q0ZQ==
4
+ MzY3ZTE3OTFiYzg5OTY5MDQ4ZmRjNTE2MjIzNmE3ZjA5MDg0MTA3YQ==
5
5
  data.tar.gz: !binary |-
6
- NDU3MjkxYTUxNjNlMWNkOGE5MGJkZGNkOTUxOGE3OThjMDM3NDIzNQ==
6
+ MGQ4NjQ2MmQ3NWY0NGI1MWM3MjFjMjY0YjQxMWM1ODc1YmNiZGY2OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDBhMzllODdmMzgxOWQ3OWExM2IzZjU4YjIwYWZhODgyMzk5ZDU3NjUwNmY1
10
- Mjg3ODcxZjEzMGE3N2JkODY1ZmMxOWI1MDFkMDVlODc0ODRlNDU2Mjc4NTAw
11
- OGQ0NDQxOThkZGNkZjliMTYwMGY2ZDQ4ZmY2NDM3NjQ2YjU0YmI=
9
+ NjMwMGI3ZTY4YzdiZDFmMzA2NzQ2MWRjZjIzN2E4NDNjMzM1ODljZGFhNDM4
10
+ NjU0MjM2YjM0NWE3NTg0MmQ5MWI2OGI1OGFhMDNjMjA2ODQ4M2I5NjIzYWZj
11
+ MTUyY2Y5N2ZkOWUzZTZlNzY5MGI2MGZjNzI0YTY1YWVmNTAwMWY=
12
12
  data.tar.gz: !binary |-
13
- NTNkOTU5YmU0OGQzNDMyYzAyZWQ1Mjc3ZGRkNWIzOGQ0MjU0NzcxOGRkODNj
14
- NTcxNzEwZDAxNTAxMTk5Mzk4OGM1Y2U3NWEwMWY0NmY1NjZhZTQyNTA3ODYx
15
- NDU1NWUxYzYzZWU4NTkyNjgwNzYwYzZjZDVmZGFkMjNjNWQyNjc=
13
+ ZDE5YTA5NmE1NWQwNWNmOWRkN2FjNmJhODI3MGFhMWZkNDY2NzhjYzliM2E3
14
+ MmVhY2FlMDg0NTczYzgzZjE2OTlmNmZjMWU3NDExYzU5M2RmMzBlY2ZlYjY4
15
+ ZjQyYzk0NmM0ZmM5N2M5Y2Y1ZDI2MDFjY2M4NzM4YWM0MWQwZWQ=
data/CHANGELOG.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Changelog JSON Schema Tools
2
2
 
3
+ 2014-11
4
+
5
+ * remove as_json method(alias of as_schema_json) conflicting with active_resource/active_record. Nothing stops one from using/aliasing it in his own code.
3
6
 
4
7
  2014-10
5
8
 
6
- * handle circular dependencies in $ref arguments, so schema.to_h always resolves $refs properly
9
+ * handle circular dependencies in $ref arguments, so schema.to_h always resolves $refs properly
7
10
 
8
11
  2014-09
9
12
 
@@ -22,6 +25,7 @@
22
25
  * add $ref resolver to merge property definitions from another file
23
26
 
24
27
  2013-10
28
+
25
29
  * allow all object properties in link href placeholders => contacts/{id}/{number}
26
30
  * add base_url option to schema hash creation. Prepends an url to all links of a rendered object
27
31
  * add to_schema_json for simpler model to json conversion
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Toolbox to work with JSON Schema in Ruby:
6
6
 
7
7
  * blow up classes from schema
8
- * object.as_json conversion
8
+ * object.as_schema_json conversion
9
9
  * object.valid? validations with object.errors
10
10
 
11
11
  Simply use full blown classes or customize the bits and pieces:
@@ -123,7 +123,7 @@ class Client < ActiveRecord::Base
123
123
  end
124
124
 
125
125
  peter = Client.new name: 'Peter'
126
- peter.as_json
126
+ peter.as_schema_json
127
127
  #=> "client":{"id":12, "name": "Peter", "email":"",..}
128
128
 
129
129
  peter.as_hash
@@ -147,7 +147,7 @@ course they can be combined.
147
147
  Only use some fields e.g. to save bandwidth
148
148
 
149
149
  ```ruby
150
- peter.as_json(fields:['id', 'name'])
150
+ peter.as_schema_json(fields:['id', 'name'])
151
151
  #=> "client":{"id":12, "name": "Peter"}
152
152
  ```
153
153
 
@@ -155,13 +155,13 @@ Use a custom schema name e.g. to represent a client as contact. Assumes you also
155
155
  have a schema named contact.json
156
156
 
157
157
  ```ruby
158
- peter.as_json(class_name: 'contact')
158
+ peter.as_schema_json(class_name: 'contact')
159
159
  ```
160
160
 
161
161
  Set a custom schema path
162
162
 
163
163
  ```ruby
164
- peter.as_json( path: 'path-to/json-files/')
164
+ peter.as_schema_json( path: 'path-to/json-files/')
165
165
  ```
166
166
 
167
167
  By default the object hash has the class name (client) and the link-section on
@@ -173,7 +173,7 @@ inline:
173
173
 
174
174
  ```ruby
175
175
 
176
- peter.as_json( exclude_root: true )
176
+ peter.as_schema_json( exclude_root: true )
177
177
 
178
178
  #=> {"id":12, "name"=> "Peter",
179
179
  # "_class_name":"client",
@@ -218,7 +218,7 @@ contact.last_name = 'Rambo'
218
218
  # raw access
219
219
  contact.schema_attrs
220
220
  # to json
221
- contact.as_json
221
+ contact.as_schema_json
222
222
  ```
223
223
 
224
224
  ## Classes from Schema - KlassFactory
@@ -11,7 +11,6 @@ module SchemaTools
11
11
  def as_schema_json(opts={})
12
12
  ActiveSupport::JSON.encode(as_schema_hash(opts))
13
13
  end
14
- def as_json(opts={}) as_schema_json(opts); end
15
14
 
16
15
  # The object as hash with fields detected from its schema.
17
16
  # The schema name is derived from:
@@ -1,3 +1,3 @@
1
1
  module SchemaTools
2
- VERSION = '0.3.3'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Leciejewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json