Hello community,
here is the log from the commit of package rubygem-json-schema for
openSUSE:Factory checked in at 2016-10-10 16:22:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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-06-02 09:36:54.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-json-schema.new/rubygem-json-schema.changes
2016-10-10 16:22:56.000000000 +0200
@@ -1,0 +2,6 @@
+Sat Oct 1 04:42:41 UTC 2016 - [email protected]
+
+- updated to version 2.7.0
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
json-schema-2.6.2.gem
New:
----
json-schema-2.7.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-json-schema.spec ++++++
--- /var/tmp/diff_new_pack.3DEl7h/_old 2016-10-10 16:22:59.000000000 +0200
+++ /var/tmp/diff_new_pack.3DEl7h/_new 2016-10-10 16:22:59.000000000 +0200
@@ -24,12 +24,12 @@
#
Name: rubygem-json-schema
-Version: 2.6.2
+Version: 2.7.0
Release: 0
%define mod_name json-schema
%define mod_full_name %{mod_name}-%{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: %{ruby >= 1.8.7}
+BuildRequires: %{ruby >= 1.9}
BuildRequires: %{rubygem gem2rpm}
BuildRequires: ruby-macros >= 5
Url: http://github.com/ruby-json-schema/json-schema/tree/master
++++++ json-schema-2.6.2.gem -> json-schema-2.7.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2016-05-13 16:54:29.000000000 +0200
+++ new/README.md 2016-09-29 15:26:19.000000000 +0200
@@ -256,6 +256,24 @@
rescue TypeError => e
e.message
end
+
+#
+# with the `:clear_cache` option set to true, the internal cache of schemas is
+# cleared after validation (otherwise schemas are cached for efficiency)
+#
+
+File.write("schema.json", v2_schema.to_json)
+
+# => true
+JSON::Validator.validate("schema.json", {})
+
+File.write("schema.json", schema.to_json)
+
+# => true
+JSON::Validator.validate("schema.json", {}, :clear_cache => true)
+
+# => false
+JSON::Validator.validate("schema.json", {})
```
Extending Schemas
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/json-schema/attributes/additionalitems.rb
new/lib/json-schema/attributes/additionalitems.rb
--- old/lib/json-schema/attributes/additionalitems.rb 2016-05-13
16:54:29.000000000 +0200
+++ new/lib/json-schema/attributes/additionalitems.rb 2016-09-29
15:26:19.000000000 +0200
@@ -11,7 +11,7 @@
case schema['additionalItems']
when false
- if schema['items'].length != data.length
+ if schema['items'].length < data.length
message = "The property '#{build_fragment(fragments)}' contains
additional array elements outside of the schema when none are allowed"
validation_error(processor, message, fragments, current_schema,
self, options[:record_errors])
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/json-schema/attributes/additionalproperties.rb
new/lib/json-schema/attributes/additionalproperties.rb
--- old/lib/json-schema/attributes/additionalproperties.rb 2016-05-13
16:54:29.000000000 +0200
+++ new/lib/json-schema/attributes/additionalproperties.rb 2016-09-29
15:26:19.000000000 +0200
@@ -14,7 +14,7 @@
if addprop.is_a?(Hash)
matching_properties = extra_properties # & addprop.keys
matching_properties.each do |key|
- additional_property_schema = JSON::Schema.new(addprop[key] ||
addprop, current_schema.uri, validator)
+ additional_property_schema = JSON::Schema.new(addprop,
current_schema.uri, validator)
additional_property_schema.validate(data[key], fragments + [key],
processor, options)
end
extra_properties -= matching_properties
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/json-schema/attributes/extends.rb
new/lib/json-schema/attributes/extends.rb
--- old/lib/json-schema/attributes/extends.rb 2016-05-13 16:54:29.000000000
+0200
+++ new/lib/json-schema/attributes/extends.rb 2016-09-29 15:26:19.000000000
+0200
@@ -24,8 +24,6 @@
def self.get_extended_uri_and_schema(s, current_schema, validator)
uri,schema = nil,nil
- s = {'$ref' => s} if s.is_a?(String)
-
if s.is_a?(Hash)
uri = current_schema.uri
if s['$ref']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/json-schema/attributes/items.rb
new/lib/json-schema/attributes/items.rb
--- old/lib/json-schema/attributes/items.rb 2016-05-13 16:54:29.000000000
+0200
+++ new/lib/json-schema/attributes/items.rb 2016-09-29 15:26:19.000000000
+0200
@@ -16,6 +16,7 @@
when Array
items.each_with_index do |item_schema, i|
+ break if i >= data.length
schema = JSON::Schema.new(item_schema, current_schema.uri,
validator)
schema.validate(data[i], fragments + [i.to_s], processor, options)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/json-schema/schema/reader.rb
new/lib/json-schema/schema/reader.rb
--- old/lib/json-schema/schema/reader.rb 2016-05-13 16:54:29.000000000
+0200
+++ new/lib/json-schema/schema/reader.rb 2016-09-29 15:26:19.000000000
+0200
@@ -3,9 +3,8 @@
module JSON
class Schema
- # Raised by {JSON::Schema::Reader} when one of its settings indicate
- # a schema should not be readed.
- class ReadRefused < StandardError
+ # Base for any reading exceptions encountered by {JSON::Schema::Reader}
+ class ReadError < StandardError
# @return [String] the requested schema location which was refused
attr_reader :location
@@ -15,7 +14,30 @@
def initialize(location, type)
@location = location
@type = type
- super("Read of #{type == :uri ? 'URI' : type} at #{location} refused!")
+ super(error_message)
+ end
+
+ private
+
+ def type_string
+ type == :uri ? 'URI' : type.to_s
+ end
+ end
+
+ # Raised by {JSON::Schema::Reader} when one of its settings indicate
+ # a schema should not be read.
+ class ReadRefused < ReadError
+ private
+ def error_message
+ "Read of #{type_string} at #{location} refused"
+ end
+ end
+
+ # Raised by {JSON::Schema::Reader} when an attempt to read a schema fails
+ class ReadFailed < ReadError
+ private
+ def error_message
+ "Read of #{type_string} at #{location} failed"
end
end
@@ -58,6 +80,8 @@
# @raise [JSON::Schema::ReadRefused] if +accept_uri+ or +accept_file+
# indicated the schema could not be read
# @raise [JSON::Schema::ParseError] if the schema was not a valid JSON
object
+ # @raise [JSON::Schema::ReadFailed] if reading the location was
acceptable but the
+ # attempt to retrieve it failed
def read(location)
uri = JSON::Util::URI.parse(location.to_s)
body = if uri.scheme.nil? || uri.scheme == 'file'
@@ -98,6 +122,8 @@
else
raise JSON::Schema::ReadRefused.new(uri.to_s, :uri)
end
+ rescue OpenURI::HTTPError, SocketError
+ raise JSON::Schema::ReadFailed.new(uri.to_s, :uri)
end
def read_file(pathname)
@@ -106,6 +132,8 @@
else
raise JSON::Schema::ReadRefused.new(pathname.to_s, :file)
end
+ rescue Errno::ENOENT
+ raise JSON::Schema::ReadFailed.new(pathname.to_s, :file)
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/json-schema/validator.rb
new/lib/json-schema/validator.rb
--- old/lib/json-schema/validator.rb 2016-05-13 16:54:29.000000000 +0200
+++ new/lib/json-schema/validator.rb 2016-09-29 15:26:19.000000000 +0200
@@ -18,7 +18,7 @@
class Validator
@@schemas = {}
- @@cache_schemas = false
+ @@cache_schemas = true
@@default_opts = {
:list => false,
:version => nil,
@@ -26,7 +26,7 @@
:record_errors => false,
:errors_as_objects => false,
:insert_defaults => false,
- :clear_cache => true,
+ :clear_cache => false,
:strict => false,
:parse_data => true
}
@@ -48,7 +48,7 @@
@validation_options = @options[:record_errors] ? {:record_errors =>
true} : {}
@validation_options[:insert_defaults] = true if
@options[:insert_defaults]
@validation_options[:strict] = true if @options[:strict] == true
- @validation_options[:clear_cache] = false if @options[:clear_cache] ==
false
+ @validation_options[:clear_cache] = true if !@@cache_schemas ||
@options[:clear_cache]
@@mutex.synchronize { @base_schema = initialize_schema(schema_data) }
@original_data = data
@@ -62,8 +62,7 @@
end
metaschema = base_validator ? base_validator.metaschema :
validator.metaschema
# Don't clear the cache during metaschema validation!
- meta_validator = JSON::Validator.new(metaschema, @base_schema.schema,
{:clear_cache => false})
- meta_validator.validate
+ self.class.validate!(metaschema, @base_schema.schema, {:clear_cache =>
false})
end
# If the :fragment option is set, try and validate against the fragment
@@ -110,12 +109,17 @@
end
# Run a simple true/false validation of data against a schema
- def validate()
+ def validate
@base_schema.validate(@data,[],self,@validation_options)
- if @options[:errors_as_objects]
- return @errors.map{|e| e.to_hash}
+
+ if @options[:record_errors]
+ if @options[:errors_as_objects]
+ @errors.map{|e| e.to_hash}
+ else
+ @errors.map{|e| e.to_string}
+ end
else
- return @errors.map{|e| e.to_string}
+ true
end
ensure
if @validation_options[:clear_cache] == true
@@ -239,9 +243,7 @@
class << self
def validate(schema, data,opts={})
begin
- validator = JSON::Validator.new(schema, data, opts)
- validator.validate
- return true
+ validate!(schema, data, opts)
rescue JSON::Schema::ValidationError, JSON::Schema::SchemaError
return false
end
@@ -258,7 +260,6 @@
def validate!(schema, data,opts={})
validator = JSON::Validator.new(schema, data, opts)
validator.validate
- return true
end
alias_method 'validate2', 'validate!'
@@ -271,9 +272,7 @@
end
def fully_validate(schema, data, opts={})
- opts[:record_errors] = true
- validator = JSON::Validator.new(schema, data, opts)
- validator.validate
+ validate!(schema, data, opts.merge(:record_errors => true))
end
def fully_validate_schema(schema, opts={})
@@ -299,7 +298,7 @@
end
def clear_cache
- @@schemas = {} if @@cache_schemas == false
+ @@schemas = {}
end
def schemas
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2016-05-13 16:54:29.000000000 +0200
+++ new/metadata 2016-09-29 15:26:19.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: json-schema
version: !ruby/object:Gem::Version
- version: 2.6.2
+ version: 2.7.0
platform: ruby
authors:
- Kenny Hoxworth
autorequire:
bindir: bin
cert_chain: []
-date: 2016-05-13 00:00:00.000000000 Z
+date: 2016-09-29 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rake
@@ -70,16 +70,16 @@
name: addressable
requirement: !ruby/object:Gem::Requirement
requirements:
- - - "~>"
+ - - ">="
- !ruby/object:Gem::Version
- version: 2.3.8
+ version: '2.4'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - "~>"
+ - - ">="
- !ruby/object:Gem::Version
- version: 2.3.8
+ version: '2.4'
description:
email: [email protected]
executables: []
@@ -161,7 +161,7 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: 1.8.7
+ version: '1.9'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="