Hello community,
here is the log from the commit of package rubygem-json-schema for openSUSE:Factory checked in at 2016-06-02 09:36:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-json-schema (Old)
and /work/SRC/openSUSE:Factory/.rubygem-json-schema.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-json-schema"
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-json-schema/rubygem-json-schema.changes 2016-03-26 15:22:15.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.rubygem-json-schema.new/rubygem-json-schema.changes 2016-06-02 09:36:54.000000000 +0200
@@ -1,0 +2,6 @@
+Sat May 14 04:40:59 UTC 2016 - coolo@suse.com
+
+- updated to version 2.6.2
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
json-schema-2.6.1.gem
New:
----
json-schema-2.6.2.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-json-schema.spec ++++++
--- /var/tmp/diff_new_pack.ja5LnH/_old 2016-06-02 09:36:55.000000000 +0200
+++ /var/tmp/diff_new_pack.ja5LnH/_new 2016-06-02 09:36:55.000000000 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-json-schema
-Version: 2.6.1
+Version: 2.6.2
Release: 0
%define mod_name json-schema
%define mod_full_name %{mod_name}-%{version}
++++++ json-schema-2.6.1.gem -> json-schema-2.6.2.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2016-02-26 11:03:19.000000000 +0100
+++ new/README.md 2016-05-13 16:54:29.000000000 +0200
@@ -1,5 +1,5 @@
-![https://travis-ci.org/ruby-json-schema/json-schema](https://travis-ci.org/ruby-json-schema/json-schema.svg?branch=master)
-![https://codeclimate.com/github/ruby-json-schema/json-schema](https://codeclimate.com/github/ruby-json-schema/json-schema/badges/gpa.svg)
+[![Travis](https://travis-ci.org/ruby-json-schema/json-schema.svg?branch=master)](https://travis-ci.org/ruby-json-schema/json-schema)
+[![Code Climate](https://codeclimate.com/github/ruby-json-schema/json-schema/badges/gpa.svg)](https://codeclimate.com/github/ruby-json-schema/json-schema)
Ruby JSON Schema Validator
==========================
@@ -42,10 +42,10 @@
$ gem install json-schema-2.5.2.gem
```
-Usage
+Validation
-----
-Three base validation methods exist:
+Three base validation methods exist:
1. `validate`: returns a boolean on whether a validation attempt passes
2. `validate!`: throws a `JSON::Schema::ValidationError` with an appropriate message/trace on where the validation failed
@@ -67,79 +67,15 @@
that the `$schema` attribute takes precedence over the `:version` option during
parsing and validation.
-### Validate Ruby objects against a Ruby schema
-
For further information on json schema itself refer to <a
href="http://spacetelescope.github.io/understanding-json-schema/">Understanding
JSON Schema</a>.
-```rb
-require 'rubygems'
-require 'json-schema'
-
-schema = {
- "type" => "object",
- "required" => ["a"],
- "properties" => {
- "a" => {"type" => "integer"}
- }
-}
-
-data = {
- "a" => 5
-}
-
-JSON::Validator.validate(schema, data)
-```
-
-### Validate a JSON string against a JSON schema file
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-JSON::Validator.validate('schema.json', '{"a" : 5}')
-```
-
-### Validate a list of objects against a schema that represents the individual objects
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-data = ['user','user','user']
-JSON::Validator.validate('user.json', data, :list => true)
-```
-
-### Strictly validate an object's properties
-
-With the `:strict` option, validation fails when an object contains properties
-that are not defined in the schema's property list or doesn't match the
-`additionalProperties` property. Furthermore, all properties are treated as
-`required` regardless of `required` properties set in the schema.
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-schema = {
- "type" => "object",
- "properties" => {
- "a" => {"type" => "integer"},
- "b" => {"type" => "integer"}
- }
-}
-
-JSON::Validator.validate(schema, {"a" => 1, "b" => 2}, :strict => true) # ==> true
-JSON::Validator.validate(schema, {"a" => 1, "b" => 2, "c" => 3}, :strict => true) # ==> false
-JSON::Validator.validate(schema, {"a" => 1}, :strict => true) # ==> false
-```
-
-### Catch a validation error and print it out
+Basic Usage
+--------------
-```rb
-require 'rubygems'
-require 'json-schema'
+```ruby
+require "json-schema"
schema = {
"type" => "object",
@@ -149,215 +85,188 @@
}
}
-data = {
- "a" => "taco"
-}
+#
+# validate ruby objects against a ruby schema
+#
+
+# => true
+JSON::Validator.validate(schema, { "a" => 5 })
+# => false
+JSON::Validator.validate(schema, {})
+
+#
+# validate a json string against a json schema file
+#
+
+require "json"
+File.write("schema.json", JSON.dump(schema))
+
+# => true
+JSON::Validator.validate('schema.json', '{ "a": 5 }')
+
+#
+# raise an error when validation fails
+#
+# => "The property '#/a' of type String did not match the following type: integer"
begin
- JSON::Validator.validate!(schema, data)
-rescue JSON::Schema::ValidationError
- puts $!.message
+ JSON::Validator.validate!(schema, { "a" => "taco" })
+rescue JSON::Schema::ValidationError => e
+ e.message
end
-```
-
-### Fully validate against a schema and catch all errors
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-schema = {
- "type" => "object",
- "required" => ["a","b"],
- "properties" => {
- "a" => {"type" => "integer"},
- "b" => {"type" => "string"}
- }
-}
-
-data = {
- "a" => "taco"
-}
-
-errors = JSON::Validator.fully_validate(schema, data)
-
-# ["The property '#/a' of type String did not match the following type: integer in schema 03179a21-197e-5414-9611-e9f63e8324cd#", "The property '#/' did not contain a required property of 'b' in schema 03179a21-197e-5414-9611-e9f63e8324cd#"]
-```
-
-### Fully validate against a schema and catch all errors as objects
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-schema = {
- "type" => "object",
- "required" => ["a","b"],
- "properties" => {
- "a" => {"type" => "integer"},
- "b" => {"type" => "string"}
- }
-}
-
-data = {
- "a" => "taco"
-}
-errors = JSON::Validator.fully_validate(schema, data, :errors_as_objects => true)
+#
+# return an array of error messages when validation fails
+#
-# [{:message=>"The property '#/a' of type String did not match the following type: integer in schema 03179a21-197e-5414-9611-e9f63e8324cd#", :schema=>#, :failed_attribute=>"Type", :fragment=>"#/a"}, {:message=>"The property '#/' did not contain a required property of 'b' in schema 03179a21-197e-5414-9611-e9f63e8324cd#", :schema=>#, :failed_attribute=>"Properties", :fragment=>"#/"}]
+# => ["The property '#/a' of type String did not match the following type: integer in schema 18a1ffbb-4681-5b00-bd15-2c76aee4b28f"]
+JSON::Validator.fully_validate(schema, { "a" => "taco" })
```
-### Validate against a fragment of a supplied schema
+Advanced Options
+-----------------
-```rb
-require 'rubygems'
-require 'json-schema'
+```ruby
+require "json-schema"
schema = {
- "type" => "object",
- "required" => ["a","b"],
+ "type"=>"object",
+ "required" => ["a"],
"properties" => {
- "a" => {"type" => "integer"},
- "b" => {"type" => "string"},
- "c" => {
+ "a" => {
+ "type" => "integer",
+ "default" => 42
+ },
+ "b" => {
"type" => "object",
"properties" => {
- "z" => {"type" => "integer"}
+ "x" => {
+ "type" => "integer"
+ }
}
}
}
}
-data = {
- "z" => 1
-}
-
-JSON::Validator.validate(schema, data, :fragment => "#/properties/c")
-```
-
-### Validate a JSON object against a JSON schema object, while also validating the schema itself
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-schema = {
- "type" => "object",
- "required" => ["a"],
- "properties" => {
- "a" => {"type" => "integer", "required" => "true"} # This will fail schema validation!
- }
-}
-
-data = {
- "a" => 5
-}
-
-JSON::Validator.validate(schema, data, :validate_schema => true)
-```
-
-### Validate a JSON object against a JSON schema object, while inserting default values from the schema
-
-With the `:insert_defaults` option set to true any missing property that has a
-default value specified in the schema will be inserted into the validated data.
-The inserted default value is validated hence catching a schema that specifies
-an invalid default value.
-
-```rb
-require 'rubygems'
-require 'json-schema'
-
-schema = {
- "type" => "object",
- "required" => ["a"],
- "properties" => {
- "a" => {"type" => "integer", "default" => 42},
- "b" => {"type" => "integer"}
- }
-}
-
-# Would not normally validate because "a" is missing and required by schema,
-# but "default" option allows insertion of valid default.
-data = {
- "b" => 5
-}
+#
+# with the `:list` option, a list can be validated against a schema that represents the individual objects
+#
+
+# => true
+JSON::Validator.validate(schema, [{"a" => 1}, {"a" => 2}, {"a" => 3}], :list => true)
+# => false
+JSON::Validator.validate(schema, [{"a" => 1}, {"a" => 2}, {"a" => 3}])
+
+#
+# with the `:errors_as_objects` option, `#fully_validate` returns errors as hashes instead of strings
+#
+
+# => [{:schema=>#