You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by su...@apache.org on 2017/02/14 23:42:58 UTC
avro git commit: AVRO-1996: compatibility with Ruby 2.4
Repository: avro
Updated Branches:
refs/heads/master 29129abee -> e9fd99ffa
AVRO-1996: compatibility with Ruby 2.4
Fixed failing tests for ruby.
Signed-off-by: Suraj Acharya <su...@apache.org>
Signed-off-by: Sean Busbey <bu...@apache.org>
This closes #191
Project: http://git-wip-us.apache.org/repos/asf/avro/repo
Commit: http://git-wip-us.apache.org/repos/asf/avro/commit/e9fd99ff
Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/e9fd99ff
Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/e9fd99ff
Branch: refs/heads/master
Commit: e9fd99ffa53e95ddbb1d136ddd6fabbfd2961f7f
Parents: 29129ab
Author: Tim Perkins <tp...@salsify.com>
Authored: Mon Jan 30 15:48:58 2017 -0500
Committer: sacharya <su...@apache.org>
Committed: Tue Feb 14 17:40:37 2017 -0600
----------------------------------------------------------------------
lang/ruby/lib/avro/schema.rb | 2 +-
lang/ruby/lib/avro/schema_validator.rb | 16 ++++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/avro/blob/e9fd99ff/lang/ruby/lib/avro/schema.rb
----------------------------------------------------------------------
diff --git a/lang/ruby/lib/avro/schema.rb b/lang/ruby/lib/avro/schema.rb
index 38d9c05..477528e 100644
--- a/lang/ruby/lib/avro/schema.rb
+++ b/lang/ruby/lib/avro/schema.rb
@@ -318,7 +318,7 @@ module Avro
attr_reader :size
def initialize(name, space, size, names=nil)
# Ensure valid cto args
- unless size.is_a?(Fixnum) || size.is_a?(Bignum)
+ unless size.is_a?(Integer)
raise AvroError, 'Fixed Schema requires a valid integer for size property.'
end
super(:fixed, name, space, names)
http://git-wip-us.apache.org/repos/asf/avro/blob/e9fd99ff/lang/ruby/lib/avro/schema_validator.rb
----------------------------------------------------------------------
diff --git a/lang/ruby/lib/avro/schema_validator.rb b/lang/ruby/lib/avro/schema_validator.rb
index 2b780d0..ca4f7f6 100644
--- a/lang/ruby/lib/avro/schema_validator.rb
+++ b/lang/ruby/lib/avro/schema_validator.rb
@@ -80,13 +80,13 @@ module Avro
when :string, :bytes
fail TypeMismatchError unless datum.is_a?(String)
when :int
- fail TypeMismatchError unless datum.is_a?(Fixnum) || datum.is_a?(Bignum)
+ fail TypeMismatchError unless datum.is_a?(Integer)
result.add_error(path, "out of bound value #{datum}") unless INT_RANGE.cover?(datum)
when :long
- fail TypeMismatchError unless datum.is_a?(Fixnum) || datum.is_a?(Bignum)
+ fail TypeMismatchError unless datum.is_a?(Integer)
result.add_error(path, "out of bound value #{datum}") unless LONG_RANGE.cover?(datum)
when :float, :double
- fail TypeMismatchError unless [Float, Fixnum, Bignum].any?(&datum.method(:is_a?))
+ fail TypeMismatchError unless [Float, Integer].any?(&datum.method(:is_a?))
when :fixed
if datum.is_a? String
message = "expected fixed with size #{expected_schema.size}, got \"#{datum}\" with size #{datum.size}"
@@ -165,7 +165,11 @@ module Avro
private
def actual_value_message(value)
- avro_type = ruby_to_avro_type(value.class)
+ avro_type = if value.class == Integer
+ ruby_integer_to_avro_type(value)
+ else
+ ruby_to_avro_type(value.class)
+ end
if value.nil?
avro_type
else
@@ -183,6 +187,10 @@ module Avro
Hash => 'record'
}.fetch(ruby_class, ruby_class)
end
+
+ def ruby_integer_to_avro_type(value)
+ INT_RANGE.cover?(value) ? 'int' : 'long'
+ end
end
end
end