checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: b453470fc3b7f050334ee9bd0fe33269de819a5d952e30325708e450487c58d0
4
- data.tar.gz: e10f924ab8691a5ce966f24f2bb24bb313d764480326db50e9206d3d9f9cb894
3
+ metadata.gz: bd600341d6cc6c754337abea31691dde899c4cf6652c143fe43b694dea22a1b2
4
+ data.tar.gz: edf44d5413369e6eac68026442405aee16f55e8fa8242fc9b906fa1dbf8e4245
5
5
SHA512:
6
- metadata.gz: 18da3e66f1ce1260399843ec9995f081f945e37521537db9afe175511c723a7216d80b507811d3aefb45ad3dbbb2c51bfe291f23a3cf413faeb33f967fd29d6b
7
- data.tar.gz: f17f454e99988c817c7332c6cc4bb7c548c3e7e2b0c59cb2a57a0802d71668b1b0a500fbb8ac8a28c37b1ba1f5034c5764c6f914549dfc37e6387b878500e6c6
6
+ metadata.gz: 7c8e200c9b1d1b04113a601a2f0501338a35de9f30f56546944929f2c0ea3caec41bbd449fe74a6cb8c75d8b1a15887e7ce72c9164048e9cb08cf015e1d629e8
7
+ data.tar.gz: c54469c995411267f9430088b51ee0ffc24711ff1f363ffdd49f6adfc66059d46c8e5c06e7bff20191c84e8497084800f4678e5af4d0153414f834079c722e41
data/lib/avro.rb CHANGED
@@ -22,7 +22,7 @@ require 'stringio'
22
22
require 'zlib'
23
23
24
24
module Avro
25
- VERSION = "0.1.0"
25
+ VERSION = "0.1.1"
26
26
27
27
class AvroError < StandardError; end
28
28
data/lib/avro/logical_types.rb CHANGED
@@ -61,6 +61,16 @@ module Avro
61
61
end
62
62
end
63
63
64
+ module Decimal
65
+ def self.encode(datum)
66
+ datum.to_s
67
+ end
68
+
69
+ def self.decode(datum)
70
+ BigDecimal(datum)
71
+ end
72
+ end
73
+
64
74
module Identity
65
75
def self.encode(datum)
66
76
datum
@@ -79,6 +89,9 @@ module Avro
79
89
"timestamp-millis" => TimestampMillis,
80
90
"timestamp-micros" => TimestampMicros
81
91
},
92
+ "bytes" => {
93
+ "decimal" => Decimal
94
+ }
82
95
}.freeze
83
96
84
97
def self.type_adapter(type, logical_type)
data/ros-avro.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
4
4
Gem::Specification.new do |s|
5
5
s.name = "ros-avro".freeze
6
- s.version = "0.1.0"
6
+ s.version = "0.1.1"
7
7
8
8
s.required_rubygems_version = Gem::Requirement.new(">= 1.2".freeze) if s.respond_to? :required_rubygems_version=
9
9
s.require_paths = ["lib".freeze]
data/test/test_io.rb CHANGED
@@ -355,6 +355,21 @@ EOS
355
355
end
356
356
end
357
357
358
+ def test_record_with_bigdecimal
359
+ require 'bigdecimal'
360
+ writer = StringIO.new
361
+ encoder = Avro::IO::BinaryEncoder.new(writer)
362
+ schema = Avro::Schema.parse('{"type":"bytes","logicalType":"decimal","precision":9,"scale":2}')
363
+ datum_writer = Avro::IO::DatumWriter.new(schema)
364
+ datum_writer.write(BigDecimal('1.2'), encoder)
365
+
366
+ reader = StringIO.new(writer.string)
367
+ decoder = Avro::IO::BinaryDecoder.new(reader)
368
+ datum_reader = Avro::IO::DatumReader.new(schema)
369
+ read_value = datum_reader.read(decoder)
370
+
371
+ assert_equal 0.12e1, read_value
372
+ end
358
373
359
374
def test_schema_promotion
360
375
promotable_schemas = ['"int"', '"long"', '"float"', '"double"']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: ros-avro
3
3
version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
platform: ruby
6
6
authors:
7
7
- Apache Software Foundation