avro-builder 0.16.2 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 200291b14e045c942db013af4e3288ff6f6fd58bd72dec71d07dcd5b3dd8feaa
4
- data.tar.gz: 41ec29b767c1133feb64c91766681b58dd98696e27ee4be504a27a6201ee4950
3
+ metadata.gz: a91ca8206639d20fe48b9ef6f634493a08af34afe223ad06d12c3e930f45bc91
4
+ data.tar.gz: 12ed60307f215d22416ffc2f2d33966ff4481e4cfadb4c011275e811dc6fcfa4
5
5
  SHA512:
6
- metadata.gz: affd413784160d10c371d1d70547d58332d388726d31a727b242c85823a068e5d9e97d12a999ee96bcdd6db2796cbd6ea2f70566ccdd707bd3e21995373aac3c
7
- data.tar.gz: d94ffa43cd149edf03046b17368d56d2b3229cc46ad92e3f1dd7588f056078ec4e6679f3157968989e319db7d25f10d461f25cca3e651d8fcb07b66d0531a004
6
+ metadata.gz: 2db9b4753353a9a1e8ecc4c90c5127d21fc4f13f985ce1ab6c5e387cc153691f5a27deb7f2784d92413dace0052c214c0f640779a296f6cfdcceb266c6ec9152
7
+ data.tar.gz: 96565b0a5bccb29930970c992e6f09dabb2c9af640a912ffaffe0c0e53f65820a1378fb7a4799585f9e45337d71c293476b87742c2ebd7060320f5bde8300ab3
@@ -1,5 +1,8 @@
1
1
  # avro-builder changelog
2
2
 
3
+ ## v0.17.0
4
+ - Add support for enum defaults introduced in Avro v1.10.0.
5
+
3
6
  ## v0.16.2
4
7
  - Allow avro version up to v1.10.x. Support will be added for new
5
8
  functionality in Avro v1.10 in a later release.
data/README.md CHANGED
@@ -165,6 +165,9 @@ fixed :g, size: 8
165
165
  enum :e, :X, :Y, :Z
166
166
  enum :d, symbols: [:A, :B]
167
167
 
168
+ # defaults can be set for enums with Ruby Avro v1.10.0
169
+ enum :c, symbols: [:A, :B], default: :A
170
+
168
171
  record :my_record_with_named do
169
172
  required :f_ref, :f
170
173
  required :fixed_inline, :fixed, size: 9
@@ -5,7 +5,7 @@ module Avro
5
5
  module Types
6
6
  class EnumType < NamedType
7
7
 
8
- dsl_attribute :doc
8
+ dsl_attributes :doc, :default
9
9
 
10
10
  dsl_attribute :symbols do |*values|
11
11
  # Define symbols explicitly to support values as a splat or single array
@@ -27,12 +27,19 @@ module Avro
27
27
  def validate!
28
28
  super
29
29
  validate_required_attribute!(:symbols)
30
+ validate_enum_default!
30
31
  end
31
32
 
32
33
  private
33
34
 
35
+ def validate_enum_default!
36
+ if !default.nil? && !symbols.map(&:to_sym).include?(default.to_sym)
37
+ raise AttributeError.new("enum default '#{default}' must be one of the enum symbols: #{symbols}")
38
+ end
39
+ end
40
+
34
41
  def serialized_attributes
35
- { symbols: symbols, doc: doc }
42
+ { symbols: symbols, doc: doc, default: default }
36
43
  end
37
44
  end
38
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avro
4
4
  module Builder
5
- VERSION = '0.16.2'
5
+ VERSION = '0.17.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avro-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.2
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-29 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro