avro-builder 0.14.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -1
- data/.travis.yml +10 -7
- data/Appraisals +23 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +2 -0
- data/README.md +61 -4
- data/Rakefile +2 -0
- data/avro-builder.gemspec +9 -7
- data/gemfiles/{avro_official.gemfile → avro_1.10.0.gemfile} +2 -2
- data/gemfiles/avro_1.8.2.gemfile +7 -0
- data/gemfiles/avro_1.9.0.gemfile +7 -0
- data/gemfiles/avro_1.9.1.gemfile +7 -0
- data/gemfiles/avro_patches_0.x.gemfile +8 -0
- data/gemfiles/avro_patches_1.x.gemfile +7 -0
- data/lib/avro/builder.rb +8 -1
- data/lib/avro/builder/aliasable.rb +2 -0
- data/lib/avro/builder/anonymous_types.rb +2 -0
- data/lib/avro/builder/definition_cache.rb +4 -3
- data/lib/avro/builder/dsl.rb +20 -2
- data/lib/avro/builder/dsl_attributes.rb +2 -0
- data/lib/avro/builder/dsl_options.rb +2 -0
- data/lib/avro/builder/enum.rb +2 -0
- data/lib/avro/builder/errors.rb +2 -0
- data/lib/avro/builder/field.rb +3 -1
- data/lib/avro/builder/file_handler.rb +5 -1
- data/lib/avro/builder/fixed.rb +2 -0
- data/lib/avro/builder/namespaceable.rb +2 -0
- data/lib/avro/builder/railtie.rb +3 -1
- data/lib/avro/builder/rake/avro_generate_task.rb +14 -3
- data/lib/avro/builder/rake/rails_avro_generate_task.rake +3 -1
- data/lib/avro/builder/record.rb +2 -0
- data/lib/avro/builder/schema_serializer_reference_state.rb +2 -0
- data/lib/avro/builder/schema_store.rb +2 -0
- data/lib/avro/builder/type_factory.rb +4 -2
- data/lib/avro/builder/types.rb +2 -0
- data/lib/avro/builder/types/array_type.rb +2 -0
- data/lib/avro/builder/types/complex_type.rb +2 -0
- data/lib/avro/builder/types/enum_type.rb +2 -0
- data/lib/avro/builder/types/fixed_type.rb +2 -0
- data/lib/avro/builder/types/map_type.rb +2 -0
- data/lib/avro/builder/types/named_error_handling.rb +2 -0
- data/lib/avro/builder/types/named_type.rb +3 -1
- data/lib/avro/builder/types/record_type.rb +5 -3
- data/lib/avro/builder/types/top_level.rb +2 -0
- data/lib/avro/builder/types/type.rb +8 -4
- data/lib/avro/builder/types/type_referencer.rb +2 -0
- data/lib/avro/builder/types/union_type.rb +3 -1
- data/lib/avro/builder/version.rb +3 -1
- metadata +52 -28
- data/gemfiles/avro_salsify_fork.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 200291b14e045c942db013af4e3288ff6f6fd58bd72dec71d07dcd5b3dd8feaa
|
4
|
+
data.tar.gz: 41ec29b767c1133feb64c91766681b58dd98696e27ee4be504a27a6201ee4950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: affd413784160d10c371d1d70547d58332d388726d31a727b242c85823a068e5d9e97d12a999ee96bcdd6db2796cbd6ea2f70566ccdd707bd3e21995373aac3c
|
7
|
+
data.tar.gz: d94ffa43cd149edf03046b17368d56d2b3229cc46ad92e3f1dd7588f056078ec4e6679f3157968989e319db7d25f10d461f25cca3e651d8fcb07b66d0531a004
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.5.8
|
data/.travis.yml
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
before_install:
|
7
|
-
- gem update --system
|
3
|
+
- 2.5.8
|
4
|
+
- 2.6.6
|
5
|
+
- 2.7.1
|
6
|
+
before_install: gem install bundler -v 2.0.1 --no-document
|
8
7
|
before_script:
|
9
8
|
- bundle exec appraisal install --jobs=3
|
10
9
|
script:
|
11
10
|
- bundle exec rubocop
|
12
|
-
- bundle exec appraisal avro-
|
13
|
-
- bundle exec appraisal avro-
|
11
|
+
- bundle exec appraisal avro-1.8.2 rspec
|
12
|
+
- bundle exec appraisal avro-1.9.0 rspec
|
13
|
+
- bundle exec appraisal avro-1.9.1 rspec
|
14
|
+
- bundle exec appraisal avro-1.10.0 rspec
|
15
|
+
- bundle exec appraisal avro-patches-0.x rspec
|
16
|
+
- bundle exec appraisal avro-patches-1.x rspec
|
data/Appraisals
CHANGED
@@ -1,7 +1,26 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise 'avro-1.8.2' do
|
4
|
+
gem 'avro', '1.8.2'
|
5
|
+
end
|
6
|
+
|
7
|
+
appraise 'avro-1.9.0' do
|
8
|
+
gem 'avro', '1.9.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise 'avro-1.9.1' do
|
12
|
+
gem 'avro', '1.9.1'
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise 'avro-1.10.0' do
|
16
|
+
gem 'avro', '1.10.0'
|
17
|
+
end
|
18
|
+
|
19
|
+
appraise 'avro-patches-0.x' do
|
20
|
+
gem 'avro', '1.8.2'
|
21
|
+
gem 'avro-patches', '< 1.0.0'
|
3
22
|
end
|
4
23
|
|
5
|
-
appraise 'avro-
|
6
|
-
gem 'avro-
|
24
|
+
appraise 'avro-patches-1.x' do
|
25
|
+
gem 'avro-patches', '>= 1.0.0'
|
7
26
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# avro-builder changelog
|
2
2
|
|
3
|
+
## v0.16.2
|
4
|
+
- Allow avro version up to v1.10.x. Support will be added for new
|
5
|
+
functionality in Avro v1.10 in a later release.
|
6
|
+
|
7
|
+
## v0.16.1
|
8
|
+
- Require avro version prior to v1.10.0.
|
9
|
+
|
10
|
+
## v0.16.0
|
11
|
+
- Add support for providing an explicit `namespace` on `extend`.
|
12
|
+
- Default lookup to current namespace before falling back on global search.
|
13
|
+
|
14
|
+
## v0.15.0
|
15
|
+
- Add support for declaring types as abstract.
|
16
|
+
|
3
17
|
## v0.14.1
|
4
18
|
- File handling fixes.
|
5
19
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -283,12 +283,13 @@ are more limited.
|
|
283
283
|
The official Ruby `avro` gem does not yet support logical types:
|
284
284
|
[AVRO-1695](https://issues.apache.org/jira/browse/AVRO-1695).
|
285
285
|
|
286
|
-
There is a
|
287
|
-
|
288
|
-
encoding and decoding logical types. To use this gem, reference it in your Gemfile
|
286
|
+
There is a [avro-patches](https://github.com/salsify/avro-patches) gem that patches
|
287
|
+
the official Avro Ruby gem to support
|
288
|
+
encoding and decoding logical types. To use this gem, reference it in your Gemfile
|
289
|
+
instead of the official Avro gem:
|
289
290
|
|
290
291
|
```ruby
|
291
|
-
gem 'avro-
|
292
|
+
gem 'avro-patches'
|
292
293
|
```
|
293
294
|
|
294
295
|
A logical type can be specified for a field using the `logical_type` attribute:
|
@@ -316,6 +317,25 @@ record :with_date_array
|
|
316
317
|
end
|
317
318
|
```
|
318
319
|
|
320
|
+
### Abstract Types
|
321
|
+
|
322
|
+
Types can be declared as abstract in the DSL. Declaring a type as abstract
|
323
|
+
prevents the rake task from generating an Avro JSON schema for the type.
|
324
|
+
|
325
|
+
A type can be declared as abstract using either an option or a method in the
|
326
|
+
DSL when defining the type:
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
record :unique_id, abstract: true
|
330
|
+
required :uuid, :fixed, size: 38
|
331
|
+
end
|
332
|
+
|
333
|
+
enum :status do
|
334
|
+
symbols %w(valid invalid)
|
335
|
+
abstract true
|
336
|
+
end
|
337
|
+
```
|
338
|
+
|
319
339
|
### Type Macros
|
320
340
|
|
321
341
|
`avro-builder` allows type macros to be defined that expand to types that
|
@@ -339,6 +359,9 @@ type_macro :timestamp, long(logical_type: 'timestamp-millis'),
|
|
339
359
|
namespace: 'com.my_company'
|
340
360
|
```
|
341
361
|
|
362
|
+
Type macros are always marked as abstract and do not generate an Avro JSON
|
363
|
+
schema file when using the rake task.
|
364
|
+
|
342
365
|
### Auto-loading and Imports
|
343
366
|
|
344
367
|
Specify paths to search for definitions:
|
@@ -359,6 +382,40 @@ record using `extends
|
|
359
382
|
the referenced record to the current record. The current record may override
|
360
383
|
fields in the record that it extends.
|
361
384
|
|
385
|
+
```
|
386
|
+
record :original do
|
387
|
+
required :first, :string
|
388
|
+
required :second, :int
|
389
|
+
end
|
390
|
+
|
391
|
+
record :extended do
|
392
|
+
extends :original
|
393
|
+
optional :first, :string
|
394
|
+
end
|
395
|
+
```
|
396
|
+
|
397
|
+
Additionally you can provide a `namespace` to `extends` if necessary to remove ambiguity.
|
398
|
+
|
399
|
+
```
|
400
|
+
namespace 'com.newbie'
|
401
|
+
|
402
|
+
record :original, namespace: 'com.og' do
|
403
|
+
required :first, :string
|
404
|
+
required :second, :int
|
405
|
+
end
|
406
|
+
|
407
|
+
record :original do
|
408
|
+
required :first, :string
|
409
|
+
required :second, :int
|
410
|
+
end
|
411
|
+
|
412
|
+
record :extended do
|
413
|
+
extends :original, namespace: 'com.og'
|
414
|
+
optional :first, :string
|
415
|
+
end
|
416
|
+
```
|
417
|
+
|
418
|
+
|
362
419
|
## Schema Store
|
363
420
|
|
364
421
|
The `Avro::Builder::SchemaStore` can be used to load DSL files and return cached
|
data/Rakefile
CHANGED
data/avro-builder.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'avro/builder/version'
|
5
6
|
|
@@ -19,14 +20,15 @@ Gem::Specification.new do |spec|
|
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
21
|
spec.require_paths = ['lib']
|
21
22
|
|
22
|
-
spec.add_runtime_dependency 'avro', '>= 1.7.0'
|
23
|
+
spec.add_runtime_dependency 'avro', '>= 1.7.0', '< 1.11'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'appraisal'
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
|
+
spec.add_development_dependency 'json_spec'
|
28
|
+
spec.add_development_dependency 'overcommit'
|
26
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
-
spec.add_development_dependency '
|
31
|
+
spec.add_development_dependency 'rspec-its'
|
32
|
+
spec.add_development_dependency 'salsify_rubocop', '~> 0.85.0'
|
29
33
|
spec.add_development_dependency 'simplecov'
|
30
|
-
spec.add_development_dependency 'salsify_rubocop', '~> 0.47.0'
|
31
|
-
spec.add_development_dependency 'overcommit'
|
32
34
|
end
|
data/lib/avro/builder.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'avro/builder/version'
|
2
4
|
require 'avro/builder/dsl'
|
3
5
|
require 'avro/builder/schema_store'
|
@@ -5,12 +7,17 @@ require 'avro/builder/schema_store'
|
|
5
7
|
module Avro
|
6
8
|
module Builder
|
7
9
|
|
10
|
+
# Accepts a string or block to eval and returns the Avro::Builder::DSL object
|
11
|
+
def self.build_dsl(str = nil, filename: nil, &block)
|
12
|
+
Avro::Builder::DSL.new(str, filename: filename, &block)
|
13
|
+
end
|
14
|
+
|
8
15
|
# Accepts a string or block to eval to define a JSON schema
|
9
16
|
def self.build(str = nil, filename: nil, &block)
|
10
17
|
Avro::Builder::DSL.new(str, filename: filename, &block).to_json
|
11
18
|
end
|
12
19
|
|
13
|
-
# Accepts a string or block to eval and returns an Avro::Schema
|
20
|
+
# Accepts a string or block to eval and returns an Avro::Schema object
|
14
21
|
def self.build_schema(str = nil, filename: nil, &block)
|
15
22
|
Avro::Builder::DSL.new(str, filename: filename, &block).as_schema
|
16
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
|
@@ -22,9 +24,7 @@ module Avro
|
|
22
24
|
key_str = Avro::Name.make_fullname(key.to_s, namespace && namespace.to_s)
|
23
25
|
object = schema_objects[key_str]
|
24
26
|
|
25
|
-
if object.nil? && !schema_names.include?(key.to_s)
|
26
|
-
object = builder.import(key)
|
27
|
-
end
|
27
|
+
object = builder.import(key) if object.nil? && !schema_names.include?(key.to_s)
|
28
28
|
|
29
29
|
raise DefinitionNotFoundError.new(key) if object.nil? && namespace.nil?
|
30
30
|
|
@@ -59,6 +59,7 @@ module Avro
|
|
59
59
|
|
60
60
|
def store_by_fullname(object, fullname = object.fullname)
|
61
61
|
raise DuplicateDefinitionError.new(fullname, object, schema_objects[fullname]) if schema_objects.key?(fullname)
|
62
|
+
|
62
63
|
schema_objects.store(fullname, object)
|
63
64
|
end
|
64
65
|
|
data/lib/avro/builder/dsl.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'avro'
|
2
4
|
require 'avro/builder/errors'
|
3
5
|
require 'avro/builder/dsl_options'
|
@@ -38,6 +40,10 @@ module Avro
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
def abstract?
|
44
|
+
@last_object && @last_object.abstract?
|
45
|
+
end
|
46
|
+
|
41
47
|
# Define an Avro schema record
|
42
48
|
def record(name = nil, options = {}, &block)
|
43
49
|
create_named_type(name, :record, options, &block)
|
@@ -92,7 +98,11 @@ module Avro
|
|
92
98
|
def type_macro(name, type_object, options = {})
|
93
99
|
raise "#{type_object.inspect} must be a type object" unless type_object.is_a?(Types::Type)
|
94
100
|
raise "namespace cannot be included in name: #{name}" if name.to_s.index('.')
|
95
|
-
|
101
|
+
|
102
|
+
type_clone = type_object.clone
|
103
|
+
type_clone.send(:abstract=, true)
|
104
|
+
cache.add_type_by_name(type_clone, name, options[:namespace] || namespace)
|
105
|
+
@last_object = type_clone
|
96
106
|
end
|
97
107
|
|
98
108
|
private
|
@@ -111,7 +121,15 @@ module Avro
|
|
111
121
|
end
|
112
122
|
|
113
123
|
def eval_file(name)
|
114
|
-
file_path =
|
124
|
+
file_path = if namespace
|
125
|
+
begin
|
126
|
+
find_file([namespace, name].join('.'))
|
127
|
+
rescue FileNotFoundError
|
128
|
+
find_file(name)
|
129
|
+
end
|
130
|
+
else
|
131
|
+
find_file(name)
|
132
|
+
end
|
115
133
|
instance_eval(File.read(file_path), file_path)
|
116
134
|
end
|
117
135
|
end
|
data/lib/avro/builder/enum.rb
CHANGED
data/lib/avro/builder/errors.rb
CHANGED
data/lib/avro/builder/field.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'avro/builder/type_factory'
|
2
4
|
require 'avro/builder/aliasable'
|
3
5
|
|
@@ -12,7 +14,7 @@ module Avro
|
|
12
14
|
include Avro::Builder::Aliasable
|
13
15
|
include Avro::Builder::AnonymousTypes
|
14
16
|
|
15
|
-
INTERNAL_ATTRIBUTES =
|
17
|
+
INTERNAL_ATTRIBUTES = [:optional_field].to_set.freeze
|
16
18
|
|
17
19
|
# These attributes may be set as options or via a block in the DSL
|
18
20
|
dsl_attributes :doc, :default, :order
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
# TODO: eventually this should be refactored into something standalone
|
@@ -19,6 +21,8 @@ module Avro
|
|
19
21
|
File.read(find_file(name))
|
20
22
|
end
|
21
23
|
|
24
|
+
FileNotFoundError = Class.new(StandardError)
|
25
|
+
|
22
26
|
def find_file(name)
|
23
27
|
# Ensure that the file_name that is searched for begins with a slash (/)
|
24
28
|
# and ends with a .rb extension. Additionally, if the name contains
|
@@ -31,7 +35,7 @@ module Avro
|
|
31
35
|
end
|
32
36
|
end.uniq
|
33
37
|
raise "Multiple matches: #{matches}" if matches.size > 1
|
34
|
-
raise "File not found #{file_name}" if matches.empty?
|
38
|
+
raise FileNotFoundError.new("File not found #{file_name}") if matches.empty?
|
35
39
|
|
36
40
|
matches.first
|
37
41
|
end
|
data/lib/avro/builder/fixed.rb
CHANGED
data/lib/avro/builder/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
class Railtie < Rails::Railtie
|
@@ -7,7 +9,7 @@ module Avro
|
|
7
9
|
end
|
8
10
|
|
9
11
|
rake_tasks do
|
10
|
-
load File.expand_path('
|
12
|
+
load File.expand_path('rake/rails_avro_generate_task.rake', __dir__)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake/tasklib'
|
2
4
|
require 'avro/builder'
|
3
5
|
|
@@ -31,13 +33,22 @@ module Avro
|
|
31
33
|
desc task_desc
|
32
34
|
task(name.to_sym => dependencies) do
|
33
35
|
raise '"root" must be specified for Avro DSL files' unless root
|
36
|
+
|
34
37
|
Avro::Builder.add_load_path(*[root, load_paths].flatten)
|
35
38
|
Dir["#{root}/**/*.rb"].each do |dsl_file|
|
36
39
|
puts "Generating Avro schema from #{dsl_file}"
|
37
40
|
output_file = dsl_file.sub('/dsl/', '/schema/').sub(/\.rb$/, ".#{filetype}")
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
dsl = Avro::Builder.build_dsl(filename: dsl_file)
|
42
|
+
if dsl.abstract?
|
43
|
+
if File.exist?(output_file)
|
44
|
+
puts "... Removing #{output_file} for abstract type"
|
45
|
+
FileUtils.rm(output_file)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
schema = dsl.to_json
|
49
|
+
FileUtils.mkdir_p(File.dirname(output_file))
|
50
|
+
File.write(output_file, schema.end_with?("\n") ? schema : schema << "\n")
|
51
|
+
end
|
41
52
|
end
|
42
53
|
end
|
43
54
|
end
|
data/lib/avro/builder/record.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
|
4
6
|
# This concern is used by classes that create new Type instances.
|
5
7
|
module TypeFactory
|
6
8
|
|
7
|
-
NAMED_TYPES =
|
8
|
-
COMPLEX_TYPES =
|
9
|
+
NAMED_TYPES = ['enum', 'fixed', 'record'].map(&:freeze).to_set.freeze
|
10
|
+
COMPLEX_TYPES = ['array', 'enum', 'fixed', 'map', 'record', 'union'].map(&:freeze).to_set.freeze
|
9
11
|
BUILTIN_TYPES = Avro::Schema::PRIMITIVE_TYPES.union(COMPLEX_TYPES).freeze
|
10
12
|
|
11
13
|
private
|
data/lib/avro/builder/types.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'avro/builder/namespaceable'
|
2
4
|
require 'avro/builder/aliasable'
|
3
5
|
require 'avro/builder/types/named_error_handling'
|
@@ -18,7 +20,7 @@ module Avro
|
|
18
20
|
|
19
21
|
dsl_attribute_alias :type_aliases, :aliases
|
20
22
|
|
21
|
-
# This module
|
23
|
+
# This module must be included after options are defined
|
22
24
|
include Avro::Builder::Types::NamedErrorHandling
|
23
25
|
|
24
26
|
def name(value = nil)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
module Types
|
@@ -6,7 +8,7 @@ module Avro
|
|
6
8
|
class RecordType < Avro::Builder::Types::NamedType
|
7
9
|
include Avro::Builder::AnonymousTypes
|
8
10
|
|
9
|
-
DSL_METHODS =
|
11
|
+
DSL_METHODS = [:required, :optional, :extends].to_set.freeze
|
10
12
|
|
11
13
|
dsl_attribute :doc
|
12
14
|
dsl_attribute_alias :type_doc, :doc
|
@@ -53,8 +55,8 @@ module Avro
|
|
53
55
|
|
54
56
|
# Adds fields from the record with the specified name to the current
|
55
57
|
# record.
|
56
|
-
def extends(name)
|
57
|
-
fields.merge!(cache.lookup_named_type(name, namespace).duplicated_fields)
|
58
|
+
def extends(name, options = {})
|
59
|
+
fields.merge!(cache.lookup_named_type(name, options.delete(:namespace) || namespace).duplicated_fields)
|
58
60
|
end
|
59
61
|
|
60
62
|
def to_h(reference_state = SchemaSerializerReferenceState.new)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
module Types
|
@@ -8,7 +10,7 @@ module Avro
|
|
8
10
|
include Avro::Builder::DslOptions
|
9
11
|
include Avro::Builder::DslAttributes
|
10
12
|
|
11
|
-
|
13
|
+
dsl_attributes :logical_type, :abstract
|
12
14
|
|
13
15
|
attr_reader :avro_type_name
|
14
16
|
|
@@ -18,6 +20,10 @@ module Avro
|
|
18
20
|
@field = field
|
19
21
|
end
|
20
22
|
|
23
|
+
def abstract?
|
24
|
+
!!abstract
|
25
|
+
end
|
26
|
+
|
21
27
|
def serialize(_reference_state)
|
22
28
|
if logical_type
|
23
29
|
{ type: avro_type_name, logicalType: logical_type }
|
@@ -78,9 +84,7 @@ module Avro
|
|
78
84
|
|
79
85
|
def validate_required_attribute!(attribute_name)
|
80
86
|
value = public_send(attribute_name)
|
81
|
-
if value.nil? || value.respond_to?(:empty?) && value.empty?
|
82
|
-
required_attribute_error!(attribute_name)
|
83
|
-
end
|
87
|
+
required_attribute_error!(attribute_name) if value.nil? || value.respond_to?(:empty?) && value.empty?
|
84
88
|
end
|
85
89
|
|
86
90
|
attr_accessor :field, :cache
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Avro
|
2
4
|
module Builder
|
3
5
|
module Types
|
@@ -5,7 +7,7 @@ module Avro
|
|
5
7
|
include Avro::Builder::Types::ComplexType
|
6
8
|
include Avro::Builder::Types::TypeReferencer
|
7
9
|
|
8
|
-
NULL_TYPE = 'null'
|
10
|
+
NULL_TYPE = 'null'
|
9
11
|
|
10
12
|
dsl_attribute :types do |*types|
|
11
13
|
if !types.empty?
|
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: 0.
|
4
|
+
version: 0.16.2
|
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:
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.7.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.11'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.7.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.11'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: appraisal
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,58 +50,72 @@ dependencies:
|
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
53
|
+
version: '2.0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '2.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: json_spec
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: overcommit
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
72
92
|
requirements:
|
73
93
|
- - "~>"
|
74
94
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
95
|
+
version: '10.0'
|
76
96
|
type: :development
|
77
97
|
prerelease: false
|
78
98
|
version_requirements: !ruby/object:Gem::Requirement
|
79
99
|
requirements:
|
80
100
|
- - "~>"
|
81
101
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
102
|
+
version: '10.0'
|
83
103
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
104
|
+
name: rspec
|
85
105
|
requirement: !ruby/object:Gem::Requirement
|
86
106
|
requirements:
|
87
|
-
- - "
|
107
|
+
- - "~>"
|
88
108
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
109
|
+
version: '3.0'
|
90
110
|
type: :development
|
91
111
|
prerelease: false
|
92
112
|
version_requirements: !ruby/object:Gem::Requirement
|
93
113
|
requirements:
|
94
|
-
- - "
|
114
|
+
- - "~>"
|
95
115
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
116
|
+
version: '3.0'
|
97
117
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
118
|
+
name: rspec-its
|
99
119
|
requirement: !ruby/object:Gem::Requirement
|
100
120
|
requirements:
|
101
121
|
- - ">="
|
@@ -114,16 +134,16 @@ dependencies:
|
|
114
134
|
requirements:
|
115
135
|
- - "~>"
|
116
136
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
137
|
+
version: 0.85.0
|
118
138
|
type: :development
|
119
139
|
prerelease: false
|
120
140
|
version_requirements: !ruby/object:Gem::Requirement
|
121
141
|
requirements:
|
122
142
|
- - "~>"
|
123
143
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
144
|
+
version: 0.85.0
|
125
145
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
146
|
+
name: simplecov
|
127
147
|
requirement: !ruby/object:Gem::Requirement
|
128
148
|
requirements:
|
129
149
|
- - ">="
|
@@ -158,8 +178,12 @@ files:
|
|
158
178
|
- avro-builder.gemspec
|
159
179
|
- bin/console
|
160
180
|
- bin/setup
|
161
|
-
- gemfiles/
|
162
|
-
- gemfiles/
|
181
|
+
- gemfiles/avro_1.10.0.gemfile
|
182
|
+
- gemfiles/avro_1.8.2.gemfile
|
183
|
+
- gemfiles/avro_1.9.0.gemfile
|
184
|
+
- gemfiles/avro_1.9.1.gemfile
|
185
|
+
- gemfiles/avro_patches_0.x.gemfile
|
186
|
+
- gemfiles/avro_patches_1.x.gemfile
|
163
187
|
- lib/avro/builder.rb
|
164
188
|
- lib/avro/builder/aliasable.rb
|
165
189
|
- lib/avro/builder/anonymous_types.rb
|
@@ -198,7 +222,7 @@ homepage: https://github.com/salsify/avro-builder.git
|
|
198
222
|
licenses:
|
199
223
|
- MIT
|
200
224
|
metadata: {}
|
201
|
-
post_install_message:
|
225
|
+
post_install_message:
|
202
226
|
rdoc_options: []
|
203
227
|
require_paths:
|
204
228
|
- lib
|
@@ -213,9 +237,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
237
|
- !ruby/object:Gem::Version
|
214
238
|
version: '0'
|
215
239
|
requirements: []
|
216
|
-
rubyforge_project:
|
217
|
-
rubygems_version: 2.6.
|
218
|
-
signing_key:
|
240
|
+
rubyforge_project:
|
241
|
+
rubygems_version: 2.7.6.2
|
242
|
+
signing_key:
|
219
243
|
specification_version: 4
|
220
244
|
summary: Ruby DSL to create Avro schemas
|
221
245
|
test_files: []
|