avro-builder 1.0.1 → 1.1.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 +4 -4
- data/.circleci/config.yml +8 -7
- data/.github/CODEOWNERS +1 -0
- data/Appraisals +5 -1
- data/CHANGELOG.md +4 -0
- data/README.md +11 -3
- data/avro-builder.gemspec +8 -1
- data/gemfiles/avro_1.10.gemfile +1 -1
- data/gemfiles/avro_1.11.gemfile +7 -0
- data/lib/avro/builder/type_factory.rb +3 -1
- data/lib/avro/builder/types/bytes_type.rb +30 -0
- data/lib/avro/builder/types/fixed_type.rb +2 -2
- data/lib/avro/builder/types/type.rb +10 -5
- data/lib/avro/builder/types.rb +1 -0
- data/lib/avro/builder/version.rb +1 -1
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c3bfd2cd887dec4479df3b57f6749de1699c375a464fd8bcc0a53d70593db0b
|
4
|
+
data.tar.gz: cf9775f4d8cf8548b50bf860ceb8fbf896228cf7c5246f6668d8ea8f4a2c1ea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8ef969008d124f6f7445d53397ec5e7c2fa8de4a8e9bbb9f6a9496640be6279439042abc01c210f2f4367e3dd35202b6aaa61453727ae4ad7a99d337e85720
|
7
|
+
data.tar.gz: 3d253d37019c40e9d4f9737748b312c58986e34cdc04f6e8a1fedd79a5ab091d418df1e85e2308192b2bd329ad2b0daac6e157372053a944489eea9f12fd2777
|
data/.circleci/config.yml
CHANGED
@@ -2,14 +2,14 @@ version: 2.1
|
|
2
2
|
jobs:
|
3
3
|
lint:
|
4
4
|
docker:
|
5
|
-
- image: salsify/ruby_ci:2.6.
|
5
|
+
- image: salsify/ruby_ci:2.6.8
|
6
6
|
working_directory: ~/avro-builder
|
7
7
|
steps:
|
8
8
|
- checkout
|
9
9
|
- restore_cache:
|
10
10
|
keys:
|
11
|
-
- v2-gems-ruby-2.6.
|
12
|
-
- v2-gems-ruby-2.6.
|
11
|
+
- v2-gems-ruby-2.6.8-{{ checksum "avro-builder.gemspec" }}-{{ checksum "Gemfile" }}
|
12
|
+
- v2-gems-ruby-2.6.8-
|
13
13
|
- run:
|
14
14
|
name: Install Gems
|
15
15
|
command: |
|
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
bundle clean
|
19
19
|
fi
|
20
20
|
- save_cache:
|
21
|
-
key: v2-gems-ruby-2.6.
|
21
|
+
key: v2-gems-ruby-2.6.8-{{ checksum "avro-builder.gemspec" }}-{{ checksum "Gemfile" }}
|
22
22
|
paths:
|
23
23
|
- "vendor/bundle"
|
24
24
|
- "gemfiles/vendor/bundle"
|
@@ -71,7 +71,8 @@ workflows:
|
|
71
71
|
gemfile:
|
72
72
|
- "gemfiles/avro_1.9.gemfile"
|
73
73
|
- "gemfiles/avro_1.10.gemfile"
|
74
|
+
- "gemfiles/avro_1.11.gemfile"
|
74
75
|
ruby-version:
|
75
|
-
- "2.6.
|
76
|
-
- "2.7.
|
77
|
-
- "3.0.
|
76
|
+
- "2.6.8"
|
77
|
+
- "2.7.4"
|
78
|
+
- "3.0.2"
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @jturkel @kphelps @tjwp
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# avro-builder changelog
|
2
2
|
|
3
|
+
## v1.1.0
|
4
|
+
- Add support for Avro 1.11
|
5
|
+
- Add support for decimal logical types.
|
6
|
+
|
3
7
|
## v1.0.1
|
4
8
|
- Bug fix: Fix pretty formatting of schemas for Rails applications that don't
|
5
9
|
use oj or yajl by removing the dependency on multi_json.
|
data/README.md
CHANGED
@@ -279,9 +279,10 @@ end
|
|
279
279
|
|
280
280
|
### Logical Types
|
281
281
|
|
282
|
-
The DSL supports setting a logical type on any type except a union. The
|
283
|
-
|
284
|
-
are more
|
282
|
+
The DSL supports setting a logical type on any type except a union. The Avro
|
283
|
+
[spec](https://avro.apache.org/docs/current/spec.html#Logical+Types) lists the logical types
|
284
|
+
that are currently defined. Note: `avro-builder` is more permissive and any logical type can
|
285
|
+
be specified on a type.
|
285
286
|
|
286
287
|
A logical type can be specified for a field using the `logical_type` attribute:
|
287
288
|
|
@@ -308,6 +309,13 @@ record :with_date_array
|
|
308
309
|
end
|
309
310
|
```
|
310
311
|
|
312
|
+
#### Decimal Logical Types
|
313
|
+
|
314
|
+
The decimal logical type, for bytes and fixed types, is currently the only logical type that requires additional
|
315
|
+
attributes. For decimals, precision must be specified and scale may optionally be specified. `avro-builder`
|
316
|
+
supports both of these attributes for bytes and fixed decimals. See the Avro
|
317
|
+
[spec](https://avro.apache.org/docs/current/spec.html#Decimal) for more details.
|
318
|
+
|
311
319
|
### Abstract Types
|
312
320
|
|
313
321
|
Types can be declared as abstract in the DSL. Declaring a type as abstract
|
data/avro-builder.gemspec
CHANGED
@@ -15,6 +15,13 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = 'https://github.com/salsify/avro-builder.git'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to set allowed_push_host.'
|
23
|
+
end
|
24
|
+
|
18
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
26
|
spec.bindir = 'exe'
|
20
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -22,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
22
29
|
|
23
30
|
spec.required_ruby_version = '>= 2.6'
|
24
31
|
|
25
|
-
spec.add_runtime_dependency 'avro', '>= 1.9.0', '< 1.
|
32
|
+
spec.add_runtime_dependency 'avro', '>= 1.9.0', '< 1.12'
|
26
33
|
|
27
34
|
spec.add_development_dependency 'appraisal'
|
28
35
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
data/gemfiles/avro_1.10.gemfile
CHANGED
@@ -30,7 +30,9 @@ module Avro
|
|
30
30
|
# Return a new Type instance
|
31
31
|
def create_builtin_type(avro_type_name, field:, cache:)
|
32
32
|
name = avro_type_name.to_s.downcase
|
33
|
-
if
|
33
|
+
if name == 'bytes'
|
34
|
+
Avro::Builder::Types::BytesType.new(field: field, cache: cache)
|
35
|
+
elsif Avro::Schema::PRIMITIVE_TYPES.include?(name)
|
34
36
|
Avro::Builder::Types::Type.new(name, field: field, cache: cache)
|
35
37
|
elsif field.nil? && NAMED_TYPES.include?(name)
|
36
38
|
Avro::Builder.const_get(name.capitalize).new(cache: cache)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avro
|
4
|
+
module Builder
|
5
|
+
module Types
|
6
|
+
# Subclass for the primitive Bytes type because it supports the decimal logical type.
|
7
|
+
class BytesType < Type
|
8
|
+
dsl_attributes :precision, :scale
|
9
|
+
|
10
|
+
def initialize(cache:, field: nil)
|
11
|
+
super('bytes', field: field, cache: cache)
|
12
|
+
end
|
13
|
+
|
14
|
+
def serialize(reference_state)
|
15
|
+
super(reference_state, overrides: serialized_attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_h(reference_state)
|
19
|
+
super(reference_state, overrides: serialized_attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def serialized_attributes
|
25
|
+
{ precision: precision, scale: scale }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -5,7 +5,7 @@ module Avro
|
|
5
5
|
module Types
|
6
6
|
class FixedType < NamedType
|
7
7
|
|
8
|
-
|
8
|
+
dsl_attributes :size, :precision, :scale
|
9
9
|
|
10
10
|
def serialize(reference_state)
|
11
11
|
super(reference_state, overrides: serialized_attributes)
|
@@ -23,7 +23,7 @@ module Avro
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def serialized_attributes
|
26
|
-
{ size: size }
|
26
|
+
{ size: size, precision: precision, scale: scale }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -24,17 +24,16 @@ module Avro
|
|
24
24
|
!!abstract
|
25
25
|
end
|
26
26
|
|
27
|
-
def serialize(_reference_state)
|
27
|
+
def serialize(_reference_state, overrides: {})
|
28
28
|
if logical_type
|
29
|
-
|
29
|
+
serialized_attributes_hash(overrides)
|
30
30
|
else
|
31
31
|
avro_type_name
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def to_h(_reference_state)
|
36
|
-
|
37
|
-
.reject { |_, v| v.nil? }
|
35
|
+
def to_h(_reference_state, overrides: {})
|
36
|
+
serialized_attributes_hash(overrides)
|
38
37
|
end
|
39
38
|
|
40
39
|
def namespace
|
@@ -75,6 +74,12 @@ module Avro
|
|
75
74
|
|
76
75
|
private
|
77
76
|
|
77
|
+
def serialized_attributes_hash(overrides)
|
78
|
+
{ type: avro_type_name, logicalType: logical_type }
|
79
|
+
.merge(overrides)
|
80
|
+
.reject { |_, v| v.nil? }
|
81
|
+
end
|
82
|
+
|
78
83
|
def required_attribute_error!(attribute_name)
|
79
84
|
raise RequiredAttributeError.new(type: avro_type_name,
|
80
85
|
attribute: attribute_name,
|
data/lib/avro/builder/types.rb
CHANGED
data/lib/avro/builder/version.rb
CHANGED
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify Engineering
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.9.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '1.
|
22
|
+
version: '1.12'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.9.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.12'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: appraisal
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,7 @@ extensions: []
|
|
178
178
|
extra_rdoc_files: []
|
179
179
|
files:
|
180
180
|
- ".circleci/config.yml"
|
181
|
+
- ".github/CODEOWNERS"
|
181
182
|
- ".gitignore"
|
182
183
|
- ".overcommit.yml"
|
183
184
|
- ".rspec"
|
@@ -193,6 +194,7 @@ files:
|
|
193
194
|
- bin/console
|
194
195
|
- bin/setup
|
195
196
|
- gemfiles/avro_1.10.gemfile
|
197
|
+
- gemfiles/avro_1.11.gemfile
|
196
198
|
- gemfiles/avro_1.9.gemfile
|
197
199
|
- lib/avro/builder.rb
|
198
200
|
- lib/avro/builder/aliasable.rb
|
@@ -216,6 +218,7 @@ files:
|
|
216
218
|
- lib/avro/builder/type_factory.rb
|
217
219
|
- lib/avro/builder/types.rb
|
218
220
|
- lib/avro/builder/types/array_type.rb
|
221
|
+
- lib/avro/builder/types/bytes_type.rb
|
219
222
|
- lib/avro/builder/types/complex_type.rb
|
220
223
|
- lib/avro/builder/types/enum_type.rb
|
221
224
|
- lib/avro/builder/types/fixed_type.rb
|
@@ -231,8 +234,10 @@ files:
|
|
231
234
|
homepage: https://github.com/salsify/avro-builder.git
|
232
235
|
licenses:
|
233
236
|
- MIT
|
234
|
-
metadata:
|
235
|
-
|
237
|
+
metadata:
|
238
|
+
allowed_push_host: https://rubygems.org
|
239
|
+
rubygems_mfa_required: 'true'
|
240
|
+
post_install_message:
|
236
241
|
rdoc_options: []
|
237
242
|
require_paths:
|
238
243
|
- lib
|
@@ -247,8 +252,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
252
|
- !ruby/object:Gem::Version
|
248
253
|
version: '0'
|
249
254
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
251
|
-
signing_key:
|
255
|
+
rubygems_version: 3.2.22
|
256
|
+
signing_key:
|
252
257
|
specification_version: 4
|
253
258
|
summary: Ruby DSL to create Avro schemas
|
254
259
|
test_files: []
|