avro 1.7.3 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "avro"
5
- s.version = "1.7.3"
5
+ s.version = "1.7.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Apache Software Foundation"]
9
- s.date = "2012-12-03"
9
+ s.date = "2013-02-21"
10
10
  s.description = "Avro is a data serialization and RPC format"
11
11
  s.email = "avro-dev@hadoop.apache.org"
12
12
  s.extra_rdoc_files = ["CHANGELOG", "lib/avro.rb", "lib/avro/collect_hash.rb", "lib/avro/data_file.rb", "lib/avro/io.rb", "lib/avro/ipc.rb", "lib/avro/protocol.rb", "lib/avro/schema.rb"]
@@ -96,8 +96,9 @@ module Avro
96
96
  def read_string
97
97
  # A string is encoded as a long followed by that many bytes of
98
98
  # UTF-8 encoded character data.
99
- # FIXME utf-8 encode this in 1.9
100
- read_bytes
99
+ read_bytes.tap do |string|
100
+ string.force_encoding("UTF-8") if string.respond_to? :force_encoding
101
+ end
101
102
  end
102
103
 
103
104
  def read(len)
@@ -244,7 +245,7 @@ module Avro
244
245
  when 'record'
245
246
  return check_props(writers_schema, readers_schema, [:fullname])
246
247
  when 'error'
247
- return check_props(writers_scheam, readers_schema, [:fullname])
248
+ return check_props(writers_schema, readers_schema, [:fullname])
248
249
  when 'request'
249
250
  return true
250
251
  when 'fixed'
@@ -314,7 +315,7 @@ module Avro
314
315
  when 'array'; read_array(writers_schema, readers_schema, decoder)
315
316
  when 'map'; read_map(writers_schema, readers_schema, decoder)
316
317
  when 'union'; read_union(writers_schema, readers_schema, decoder)
317
- when 'record', 'errors', 'request'; read_record(writers_schema, readers_schema, decoder)
318
+ when 'record', 'error', 'request'; read_record(writers_schema, readers_schema, decoder)
318
319
  else
319
320
  raise AvroError, "Cannot read unknown schema type: #{writers_schema.type}"
320
321
  end
@@ -442,7 +443,7 @@ module Avro
442
443
  return read_map
443
444
  when 'union'
444
445
  return read_default_value(field_schema.schemas[0], default_value)
445
- when 'record'
446
+ when 'record', 'error'
446
447
  read_record = {}
447
448
  field_schema.fields.each do |field|
448
449
  json_val = default_value[field.name]
@@ -453,7 +454,7 @@ module Avro
453
454
  return read_record
454
455
  else
455
456
  fail_msg = "Unknown type: #{field_schema.type}"
456
- raise AvroError(fail_msg)
457
+ raise AvroError, fail_msg
457
458
  end
458
459
  end
459
460
 
@@ -565,7 +566,7 @@ module Avro
565
566
  when 'array'; write_array(writers_schema, datum, encoder)
566
567
  when 'map'; write_map(writers_schema, datum, encoder)
567
568
  when 'union'; write_union(writers_schema, datum, encoder)
568
- when 'record', 'errors', 'request'; write_record(writers_schema, datum, encoder)
569
+ when 'record', 'error', 'request'; write_record(writers_schema, datum, encoder)
569
570
  else
570
571
  raise AvroError.new("Unknown type: #{writers_schema.type}")
571
572
  end
@@ -58,7 +58,7 @@ class RandomData
58
58
  map[nextdata(Avro::Schema::PrimitiveSchema.new('string'))] = nextdata(schm.values, d+1)
59
59
  end
60
60
  map
61
- when 'record'
61
+ when 'record', 'error'
62
62
  m = {}
63
63
  schm.fields.each do |field|
64
64
  m[field.name] = nextdata(field.type, d+1)
@@ -73,6 +73,16 @@ EOS
73
73
  check_default(record_schema, '{"f": 11}', {"f" => 11})
74
74
  end
75
75
 
76
+ def test_error
77
+ error_schema = <<EOS
78
+ {"type": "error",
79
+ "name": "TestError",
80
+ "fields": [{"name": "message",
81
+ "type": "string"}]}
82
+ EOS
83
+ check_default(error_schema, '{"message": "boom"}', {"message" => "boom"})
84
+ end
85
+
76
86
  def test_enum
77
87
  enum_schema = '{"type": "enum", "name": "Test","symbols": ["A", "B"]}'
78
88
  check_default(enum_schema, '"B"', "B")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avro
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
- - 3
10
- version: 1.7.3
9
+ - 4
10
+ version: 1.7.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Apache Software Foundation
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-03 00:00:00 Z
18
+ date: 2013-02-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: yajl-ruby