avro 1.9.2 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Licensed to the Apache Software Foundation (ASF) under one
2
3
  # or more contributor license agreements. See the NOTICE file
3
4
  # distributed with this work for additional information
@@ -16,8 +17,8 @@
16
17
 
17
18
  require 'test_help'
18
19
 
19
- class TestSchema < Test::Unit::TestCase
20
- def validate!(schema, value, options=nil)
20
+ class TestSchemaValidator < Test::Unit::TestCase
21
+ def validate!(schema, value, options = {})
21
22
  Avro::SchemaValidator.validate!(schema, value, options)
22
23
  end
23
24
 
@@ -169,13 +170,13 @@ class TestSchema < Test::Unit::TestCase
169
170
  def test_validate_float
170
171
  schema = hash_to_schema(type: 'float', name: 'name')
171
172
 
172
- assert_valid_schema(schema, [1.1, 1, Avro::Schema::LONG_MAX_VALUE], ['string'], true)
173
+ assert_valid_schema(schema, [1.1, 1, BigDecimal('1.1'), Avro::Schema::LONG_MAX_VALUE], ['string'], true)
173
174
  end
174
175
 
175
176
  def test_validate_double
176
177
  schema = hash_to_schema(type: 'double', name: 'name')
177
178
 
178
- assert_valid_schema(schema, [1.1, 1, Avro::Schema::LONG_MAX_VALUE], ['string'], true)
179
+ assert_valid_schema(schema, [1.1, 1, BigDecimal('1.1'), Avro::Schema::LONG_MAX_VALUE], ['string'], true)
179
180
  end
180
181
 
181
182
  def test_validate_fixed
@@ -196,6 +197,12 @@ class TestSchema < Test::Unit::TestCase
196
197
  assert_valid_schema(schema, [{ 'sub' => nil }], [{ 'sub' => 1 }])
197
198
  end
198
199
 
200
+ def test_validate_record_with_symbol_keys
201
+ schema = hash_to_schema(type: 'record', name: 'name', fields: [{ type: 'int', name: 'sub' }])
202
+
203
+ assert_valid_schema(schema, [{ sub: 1 }], [{ sub: '1' }])
204
+ end
205
+
199
206
  def test_validate_shallow_record
200
207
  schema = hash_to_schema(
201
208
  type: 'record', name: 'name', fields: [{ type: 'int', name: 'sub' }]
@@ -277,7 +284,7 @@ class TestSchema < Test::Unit::TestCase
277
284
 
278
285
  def test_validate_union_of_nil_and_record_inside_array
279
286
  schema = hash_to_schema(
280
- name: 'this does not matter',
287
+ name: 'this_does_not_matter',
281
288
  type: 'record',
282
289
  fields: [
283
290
  {
@@ -551,4 +558,18 @@ class TestSchema < Test::Unit::TestCase
551
558
  assert_equal(1, exception.result.errors.size)
552
559
  assert_equal("at . extra field 'color' - not in schema", exception.to_s)
553
560
  end
561
+
562
+ def test_validate_bytes_decimal
563
+ schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4, scale: 2)
564
+ assert_valid_schema(schema, [BigDecimal('1.23'), 4.2, 1], ['4.2', BigDecimal('233.2')], true)
565
+
566
+ schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4, scale: 4)
567
+ assert_valid_schema(schema, [BigDecimal('0.2345'), 0.2, 0.1], ['4.2', BigDecimal('233.2')], true)
568
+
569
+ schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4, scale: 0)
570
+ assert_valid_schema(schema, [BigDecimal('123'), 2], ['4.2', BigDecimal('233.2')], true)
571
+
572
+ schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4)
573
+ assert_valid_schema(schema, [BigDecimal('123'), 2], ['4.2', BigDecimal('233.2')], true)
574
+ end
554
575
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Licensed to the Apache Software Foundation (ASF) under one
2
3
  # or more contributor license agreements. See the NOTICE file
3
4
  # distributed with this work for additional information
data/test/tool.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Licensed to the Apache Software Foundation (ASF) under one
2
3
  # or more contributor license agreements. See the NOTICE file
3
4
  # distributed with this work for additional information
@@ -21,13 +22,13 @@ require 'logger'
21
22
 
22
23
  class GenericResponder < Avro::IPC::Responder
23
24
  def initialize(proto, msg, datum)
24
- proto_json = open(proto).read
25
+ proto_json = File.open(proto).read
25
26
  super(Avro::Protocol.parse(proto_json))
26
27
  @msg = msg
27
28
  @datum = datum
28
29
  end
29
30
 
30
- def call(message, request)
31
+ def call(message, _request)
31
32
  if message.name == @msg
32
33
  STDERR.puts "Message: #{message.name} Datum: #{@datum.inspect}"
33
34
  @datum
@@ -62,14 +63,14 @@ end
62
63
  def send_message(uri, proto, msg, datum)
63
64
  uri = URI.parse(uri)
64
65
  trans = Avro::IPC::HTTPTransceiver.new(uri.host, uri.port)
65
- proto_json = open(proto).read
66
+ proto_json = File.open(proto).read
66
67
  requestor = Avro::IPC::Requestor.new(Avro::Protocol.parse(proto_json),
67
68
  trans)
68
69
  p requestor.request(msg, datum)
69
70
  end
70
71
 
71
72
  def file_or_stdin(f)
72
- f == "-" ? STDIN : open(f)
73
+ f == "-" ? STDIN : File.open(f)
73
74
  end
74
75
 
75
76
  def main
@@ -100,9 +101,9 @@ def main
100
101
  if ARGV.size > 4
101
102
  case ARGV[4]
102
103
  when "-file"
103
- Avro::DataFile.open(ARGV[5]) {|f|
104
- f.each{|d| datum = d; break }
105
- }
104
+ Avro::DataFile.open(ARGV[5]) do |f|
105
+ datum = f.first
106
+ end
106
107
  when "-data"
107
108
  puts "JSON Decoder not yet implemented."
108
109
  return 1
@@ -124,7 +125,7 @@ def main
124
125
  if ARGV.size > 4
125
126
  case ARGV[4]
126
127
  when "-file"
127
- Avro::DataFile.open(ARGV[5]){|f| f.each{|d| datum = d; break } }
128
+ Avro::DataFile.open(ARGV[5]){ |f| datum = f.first }
128
129
  when "-data"
129
130
  puts "JSON Decoder not yet implemented"
130
131
  return 1
metadata CHANGED
@@ -1,48 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache Software Foundation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2021-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.0'
27
27
  description: Avro is a data serialization and RPC format
28
28
  email: dev@avro.apache.org
29
29
  executables: []
30
30
  extensions: []
31
- extra_rdoc_files:
32
- - CHANGELOG
33
- - LICENSE
34
- - lib/avro.rb
35
- - lib/avro/data_file.rb
36
- - lib/avro/io.rb
37
- - lib/avro/ipc.rb
38
- - lib/avro/logical_types.rb
39
- - lib/avro/protocol.rb
40
- - lib/avro/schema.rb
41
- - lib/avro/schema_compatibility.rb
42
- - lib/avro/schema_normalization.rb
43
- - lib/avro/schema_validator.rb
31
+ extra_rdoc_files: []
44
32
  files:
45
- - CHANGELOG
46
33
  - LICENSE
47
34
  - Manifest
48
35
  - NOTICE
@@ -50,6 +37,7 @@ files:
50
37
  - avro.gemspec
51
38
  - interop/test_interop.rb
52
39
  - lib/avro.rb
40
+ - lib/avro/VERSION.txt
53
41
  - lib/avro/data_file.rb
54
42
  - lib/avro/io.rb
55
43
  - lib/avro/ipc.rb
@@ -79,8 +67,12 @@ files:
79
67
  - test/tool.rb
80
68
  homepage: https://avro.apache.org/
81
69
  licenses:
82
- - Apache License 2.0 (Apache-2.0)
83
- metadata: {}
70
+ - Apache-2.0
71
+ metadata:
72
+ homepage_uri: https://avro.apache.org/
73
+ bug_tracker_uri: https://issues.apache.org/jira/browse/AVRO
74
+ source_code_uri: https://github.com/apache/avro
75
+ documentation_uri: https://avro.apache.org/docs/1.11.0/
84
76
  post_install_message:
85
77
  rdoc_options:
86
78
  - "--line-numbers"
@@ -92,27 +84,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
84
  requirements:
93
85
  - - ">="
94
86
  - !ruby/object:Gem::Version
95
- version: '0'
87
+ version: '2.6'
96
88
  required_rubygems_version: !ruby/object:Gem::Requirement
97
89
  requirements:
98
90
  - - ">="
99
91
  - !ruby/object:Gem::Version
100
- version: '1.2'
92
+ version: '0'
101
93
  requirements: []
102
- rubyforge_project: avro
103
- rubygems_version: 2.5.2.1
94
+ rubygems_version: 3.1.2
104
95
  signing_key:
105
96
  specification_version: 4
106
97
  summary: Apache Avro for Ruby
107
98
  test_files:
108
- - test/test_schema.rb
109
- - test/test_socket_transport.rb
99
+ - test/case_finder.rb
100
+ - test/random_data.rb
101
+ - test/sample_ipc_client.rb
102
+ - test/sample_ipc_http_client.rb
103
+ - test/sample_ipc_http_server.rb
104
+ - test/sample_ipc_server.rb
105
+ - test/test_datafile.rb
106
+ - test/test_fingerprints.rb
107
+ - test/test_help.rb
110
108
  - test/test_io.rb
111
109
  - test/test_logical_types.rb
112
- - test/test_help.rb
113
- - test/test_datafile.rb
114
110
  - test/test_protocol.rb
115
- - test/test_schema_validator.rb
111
+ - test/test_schema.rb
116
112
  - test/test_schema_compatibility.rb
117
113
  - test/test_schema_normalization.rb
118
- - test/test_fingerprints.rb
114
+ - test/test_schema_validator.rb
115
+ - test/test_socket_transport.rb
116
+ - test/tool.rb
data/CHANGELOG DELETED
@@ -1 +0,0 @@
1
- v0.0.1 stuff