avro-builder 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +7 -0
- data/lib/avro/builder/dsl.rb +7 -3
- data/lib/avro/builder/dsl_attributes.rb +6 -6
- data/lib/avro/builder/dsl_options.rb +10 -32
- data/lib/avro/builder/enum.rb +8 -0
- data/lib/avro/builder/errors.rb +1 -11
- data/lib/avro/builder/field.rb +6 -12
- data/lib/avro/builder/fixed.rb +8 -0
- data/lib/avro/builder/record.rb +8 -0
- data/lib/avro/builder/type_factory.rb +11 -8
- data/lib/avro/builder/types/array_type.rb +1 -1
- data/lib/avro/builder/types/complex_type.rb +4 -4
- data/lib/avro/builder/types/map_type.rb +1 -1
- data/lib/avro/builder/types/named_error_handling.rb +62 -0
- data/lib/avro/builder/types/named_type.rb +24 -6
- data/lib/avro/builder/types/record_type.rb +7 -7
- data/lib/avro/builder/types/top_level.rb +66 -0
- data/lib/avro/builder/types/type.rb +5 -5
- data/lib/avro/builder/types/type_referencer.rb +4 -4
- data/lib/avro/builder/types.rb +1 -0
- data/lib/avro/builder/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55be55b48ed971e75719a7c77d72002a384ae371
|
4
|
+
data.tar.gz: 164cddb8d0eb7ab54df709751bc0bd3d0b9a4164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af77d1df17425d13af42225a8c1ca04e99464e1a907c588699159cf0b0b6248e1fa1af1443f1de64ec186680ec03a895547157e1923cef62132d49e69552e16f
|
7
|
+
data.tar.gz: 31bd7491a67a0cd075fbf193aa896cadb27ca0ce9c68851bf1e2aa4b302678ae14c34cc81ae1b327523f4c7d450df8f2eeba1f42cff0b6d491826c21c4785e1c
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# avro-builder changelog
|
2
2
|
|
3
|
+
## v0.7.0
|
4
|
+
- Only allow `type_name` and `type_namespace` options for naming named types
|
5
|
+
defined inline.
|
6
|
+
- Only allow first argument to set name, and `namespace` option for top-level
|
7
|
+
types.
|
8
|
+
- Only allow `aliases` attribute to set aliases for top-level types.
|
9
|
+
|
3
10
|
## v0.6.0
|
4
11
|
- Support recursive definitions.
|
5
12
|
- Coerce aliases to be represented as an array.
|
data/lib/avro/builder/dsl.rb
CHANGED
@@ -7,6 +7,9 @@ require 'avro/builder/definition_cache'
|
|
7
7
|
require 'avro/builder/type_factory'
|
8
8
|
require 'avro/builder/types'
|
9
9
|
require 'avro/builder/field'
|
10
|
+
require 'avro/builder/record'
|
11
|
+
require 'avro/builder/enum'
|
12
|
+
require 'avro/builder/fixed'
|
10
13
|
require 'avro/builder/file_handler'
|
11
14
|
require 'avro/builder/schema_serializer_reference_state'
|
12
15
|
|
@@ -79,10 +82,11 @@ module Avro
|
|
79
82
|
@cache ||= Avro::Builder::DefinitionCache.new(self)
|
80
83
|
end
|
81
84
|
|
82
|
-
def create_named_type(name,
|
83
|
-
create_and_configure_builtin_type(
|
85
|
+
def create_named_type(name, avro_type_name, options = {}, &block)
|
86
|
+
create_and_configure_builtin_type(avro_type_name,
|
84
87
|
cache: cache,
|
85
|
-
internal: {
|
88
|
+
internal: { _name: name,
|
89
|
+
namespace: namespace },
|
86
90
|
options: options,
|
87
91
|
&block).tap do |type|
|
88
92
|
type.validate!
|
@@ -19,10 +19,6 @@ module Avro
|
|
19
19
|
base.extend ClassMethods
|
20
20
|
end
|
21
21
|
|
22
|
-
def dsl_attribute?(name)
|
23
|
-
self.class.dsl_attribute_names.include?(name.to_sym)
|
24
|
-
end
|
25
|
-
|
26
22
|
module ClassMethods
|
27
23
|
# If a block is specified then it is used to define the
|
28
24
|
# combined getter/setter method for the DSL attribute.
|
@@ -60,13 +56,13 @@ module Avro
|
|
60
56
|
end
|
61
57
|
end
|
62
58
|
|
63
|
-
private
|
64
|
-
|
65
59
|
def add_attribute_name(name)
|
66
60
|
dsl_attribute_names << name
|
67
61
|
add_option_name(name)
|
68
62
|
end
|
69
63
|
|
64
|
+
private
|
65
|
+
|
70
66
|
def define_accessor(name)
|
71
67
|
ivar = :"@#{name}"
|
72
68
|
define_method(name) do |value = nil|
|
@@ -82,6 +78,10 @@ module Avro
|
|
82
78
|
private(writer)
|
83
79
|
end
|
84
80
|
end
|
81
|
+
|
82
|
+
def dsl_attribute?(name)
|
83
|
+
self.class.dsl_attribute_names.include?(name.to_sym)
|
84
|
+
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -19,11 +19,17 @@ module Avro
|
|
19
19
|
end
|
20
20
|
|
21
21
|
module ClassMethods
|
22
|
-
|
23
|
-
|
22
|
+
|
23
|
+
# Defines a private writer with #{dsl_name}= to set an attribute stored in the
|
24
|
+
# instance variable @#{name}.
|
25
|
+
def dsl_option(name, dsl_name:)
|
24
26
|
add_option_name(name)
|
25
|
-
|
26
|
-
|
27
|
+
add_attribute_name(dsl_name)
|
28
|
+
aliased_writer = "#{dsl_name}="
|
29
|
+
define_method(aliased_writer) do |value|
|
30
|
+
instance_variable_set("@#{name}", value)
|
31
|
+
end
|
32
|
+
private(aliased_writer)
|
27
33
|
end
|
28
34
|
|
29
35
|
def dsl_option_names
|
@@ -35,37 +41,9 @@ module Avro
|
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
|
-
private
|
39
|
-
|
40
44
|
def add_option_name(name)
|
41
45
|
dsl_option_names << name
|
42
46
|
end
|
43
|
-
|
44
|
-
def define_private_writer(name)
|
45
|
-
attr_writer(name)
|
46
|
-
private("#{name}=")
|
47
|
-
end
|
48
|
-
|
49
|
-
# Define a accessor method that raises an error if called as a writer.
|
50
|
-
# If the optional block is specified then it is evaluated as the reader.
|
51
|
-
def define_reader(name, &block)
|
52
|
-
if block_given?
|
53
|
-
define_method(name) do |value = nil|
|
54
|
-
value ? unsupported_block_attribute(name, type_name) : instance_eval(&block)
|
55
|
-
end
|
56
|
-
else
|
57
|
-
define_method(name) do |value = nil|
|
58
|
-
value ? unsupported_block_attribute(name, type_name) : instance_variable_get("@#{name}")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def unsupported_block_attribute(attribute, type)
|
67
|
-
raise UnsupportedBlockAttributeError.new(attribute: attribute,
|
68
|
-
type: type)
|
69
47
|
end
|
70
48
|
end
|
71
49
|
end
|
data/lib/avro/builder/errors.rb
CHANGED
@@ -38,16 +38,6 @@ module Avro
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
def initialize(attribute:, type:, field: nil)
|
43
|
-
target = if field
|
44
|
-
"field '#{field}' of type :#{type}"
|
45
|
-
else
|
46
|
-
"type :#{type}"
|
47
|
-
end
|
48
|
-
super("'#{attribute}' must be set directly using an option on #{target}, "\
|
49
|
-
'not via a block')
|
50
|
-
end
|
51
|
-
end
|
41
|
+
AttributeError = Class.new(StandardError)
|
52
42
|
end
|
53
43
|
end
|
data/lib/avro/builder/field.rb
CHANGED
@@ -17,9 +17,7 @@ module Avro
|
|
17
17
|
# These attributes may be set as options or via a block in the DSL
|
18
18
|
dsl_attributes :doc, :default, :order
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
def initialize(name:, type_name:, record:, cache:, internal: {}, options: {}, &block)
|
20
|
+
def initialize(name:, avro_type_name:, record:, cache:, internal: {}, options: {}, &block)
|
23
21
|
@cache = cache
|
24
22
|
@record = record
|
25
23
|
@name = name.to_s
|
@@ -33,14 +31,14 @@ module Avro
|
|
33
31
|
send(key, type_options.delete(key)) if dsl_attribute?(key)
|
34
32
|
end
|
35
33
|
|
36
|
-
@type = if builtin_type?(
|
37
|
-
create_and_configure_builtin_type(
|
34
|
+
@type = if builtin_type?(avro_type_name)
|
35
|
+
create_and_configure_builtin_type(avro_type_name,
|
38
36
|
field: self,
|
39
37
|
cache: cache,
|
40
38
|
internal: internal,
|
41
39
|
options: type_options)
|
42
40
|
else
|
43
|
-
cache.lookup_named_type(
|
41
|
+
cache.lookup_named_type(avro_type_name, namespace)
|
44
42
|
end
|
45
43
|
|
46
44
|
# DSL calls must be evaluated after the type has been constructed
|
@@ -66,9 +64,7 @@ module Avro
|
|
66
64
|
# and return the namespace value from the enclosing record.
|
67
65
|
def namespace(value = nil)
|
68
66
|
if value
|
69
|
-
|
70
|
-
field: @name,
|
71
|
-
type: type.type_name)
|
67
|
+
type.namespace(value)
|
72
68
|
else
|
73
69
|
record.namespace
|
74
70
|
end
|
@@ -77,9 +73,7 @@ module Avro
|
|
77
73
|
# Delegate setting name explicitly via DSL to type
|
78
74
|
def name(value = nil)
|
79
75
|
if value
|
80
|
-
|
81
|
-
field: @name,
|
82
|
-
type: type.type_name)
|
76
|
+
type.name(value)
|
83
77
|
else
|
84
78
|
# Return the name of the field
|
85
79
|
@name
|
@@ -4,40 +4,43 @@ module Avro
|
|
4
4
|
# This concern is used by classes that create new Type instances.
|
5
5
|
module TypeFactory
|
6
6
|
|
7
|
-
|
7
|
+
NAMED_TYPES = %w(enum fixed record).map(&:freeze).to_set.freeze
|
8
|
+
COMPLEX_TYPES = %w(array enum fixed map record union).map(&:freeze).to_set.freeze
|
8
9
|
BUILTIN_TYPES = Avro::Schema::PRIMITIVE_TYPES.union(COMPLEX_TYPES).freeze
|
9
10
|
|
10
11
|
private
|
11
12
|
|
12
13
|
# Return a new Type instance
|
13
|
-
def create_builtin_type(
|
14
|
-
name =
|
14
|
+
def create_builtin_type(avro_type_name, field:, cache:)
|
15
|
+
name = avro_type_name.to_s.downcase
|
15
16
|
if Avro::Schema::PRIMITIVE_TYPES.include?(name)
|
16
17
|
Avro::Builder::Types::Type.new(name, field: field, cache: cache)
|
18
|
+
elsif field.nil? && NAMED_TYPES.include?(name)
|
19
|
+
Avro::Builder.const_get(name.capitalize).new(cache: cache)
|
17
20
|
elsif COMPLEX_TYPES.include?(name)
|
18
21
|
Avro::Builder::Types.const_get("#{name.capitalize}Type").new(field: field, cache: cache)
|
19
22
|
else
|
20
|
-
raise "Invalid builtin type: #{
|
23
|
+
raise "Invalid builtin type: #{avro_type_name}"
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
27
|
# Return a new Type instance, including propagating internal state
|
25
28
|
# and setting attributes via the DSL
|
26
|
-
def create_and_configure_builtin_type(
|
29
|
+
def create_and_configure_builtin_type(avro_type_name,
|
27
30
|
field: nil,
|
28
31
|
cache: nil,
|
29
32
|
internal: {},
|
30
33
|
options: {},
|
31
34
|
&block)
|
32
|
-
create_builtin_type(
|
35
|
+
create_builtin_type(avro_type_name, field: field, cache: cache).tap do |type|
|
33
36
|
type.configure_options(internal.merge(options))
|
34
37
|
type.cache!
|
35
38
|
type.instance_eval(&block) if block_given?
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
def builtin_type?(
|
40
|
-
BUILTIN_TYPES.include?(
|
42
|
+
def builtin_type?(avro_type_name)
|
43
|
+
BUILTIN_TYPES.include?(avro_type_name.to_s)
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -12,7 +12,7 @@ module Avro
|
|
12
12
|
|
13
13
|
# Override initialize so that type name is not required
|
14
14
|
def initialize(cache:, field: nil)
|
15
|
-
super(self.class.
|
15
|
+
super(self.class.avro_type_name, cache: cache, field: field)
|
16
16
|
end
|
17
17
|
|
18
18
|
def namespace
|
@@ -21,9 +21,9 @@ module Avro
|
|
21
21
|
|
22
22
|
module ClassMethods
|
23
23
|
|
24
|
-
# Infer
|
25
|
-
def
|
26
|
-
@
|
24
|
+
# Infer avro_type_name based on class
|
25
|
+
def avro_type_name
|
26
|
+
@avro_type_name ||= name.split('::').last.sub('Type', '').downcase.to_sym
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Avro
|
2
|
+
module Builder
|
3
|
+
module Types
|
4
|
+
|
5
|
+
# This concern provides error handling for attributes related to naming
|
6
|
+
# that are handled differently at the top-level vs inline.
|
7
|
+
module NamedErrorHandling
|
8
|
+
|
9
|
+
# Errors for attributes specified via block
|
10
|
+
|
11
|
+
def type_name(_value)
|
12
|
+
name_attribute_error!
|
13
|
+
end
|
14
|
+
|
15
|
+
def type_namespace(_value)
|
16
|
+
namespace_attribute_error!
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Errors for misnamed options
|
22
|
+
|
23
|
+
def name=(_value)
|
24
|
+
type_name_instead_of_name_error!
|
25
|
+
end
|
26
|
+
|
27
|
+
def namespace=(_value)
|
28
|
+
type_namespace_instead_of_namespace_error!
|
29
|
+
end
|
30
|
+
|
31
|
+
# Methods to raise errors
|
32
|
+
|
33
|
+
def specify_as_type_option_error!(name)
|
34
|
+
raise AttributeError
|
35
|
+
.new("'type_#{name}' must be specified as an option, not via a block")
|
36
|
+
end
|
37
|
+
|
38
|
+
def name_attribute_error!
|
39
|
+
specify_as_type_option_error!(:name)
|
40
|
+
end
|
41
|
+
|
42
|
+
def namespace_attribute_error!
|
43
|
+
specify_as_type_option_error!(:namespace)
|
44
|
+
end
|
45
|
+
|
46
|
+
def type_option_instead_of_option_error!(name)
|
47
|
+
raise AttributeError
|
48
|
+
.new("'type_#{name}' must be specified as an option instead of '#{name}'")
|
49
|
+
end
|
50
|
+
|
51
|
+
def type_name_instead_of_name_error!
|
52
|
+
type_option_instead_of_option_error!(:name)
|
53
|
+
end
|
54
|
+
|
55
|
+
def type_namespace_instead_of_namespace_error!
|
56
|
+
type_option_instead_of_option_error!(:namespace)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'avro/builder/types/configurable_type'
|
2
2
|
require 'avro/builder/namespaceable'
|
3
3
|
require 'avro/builder/aliasable'
|
4
|
+
require 'avro/builder/types/named_error_handling'
|
4
5
|
|
5
6
|
module Avro
|
6
7
|
module Builder
|
@@ -14,13 +15,30 @@ module Avro
|
|
14
15
|
include Avro::Builder::Types::ConfigurableType
|
15
16
|
include Avro::Builder::Aliasable
|
16
17
|
|
17
|
-
dsl_option :
|
18
|
-
dsl_option :
|
19
|
-
@name || "__#{name_fragment}_#{type_name}"
|
20
|
-
end
|
18
|
+
dsl_option :name, dsl_name: :type_name
|
19
|
+
dsl_option :namespace, dsl_name: :type_namespace
|
21
20
|
|
22
21
|
dsl_attribute_alias :type_aliases, :aliases
|
23
22
|
|
23
|
+
# This module most be included after options are defined
|
24
|
+
include Avro::Builder::Types::NamedErrorHandling
|
25
|
+
|
26
|
+
def name(value = nil)
|
27
|
+
if value.nil?
|
28
|
+
@name || "__#{name_fragment}_#{avro_type_name}"
|
29
|
+
else
|
30
|
+
type_name_instead_of_name_error!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def namespace(value = nil)
|
35
|
+
if value.nil?
|
36
|
+
@namespace
|
37
|
+
else
|
38
|
+
type_namespace_instead_of_namespace_error!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
24
42
|
def validate!
|
25
43
|
required_attribute_error!(:name) if field.nil? && @name.nil?
|
26
44
|
end
|
@@ -43,7 +61,7 @@ module Avro
|
|
43
61
|
reference_state.definition_or_reference(fullname) do
|
44
62
|
{
|
45
63
|
name: name,
|
46
|
-
type:
|
64
|
+
type: avro_type_name,
|
47
65
|
namespace: namespace
|
48
66
|
}.merge(overrides).reject { |_, v| v.nil? }
|
49
67
|
end
|
@@ -55,7 +73,7 @@ module Avro
|
|
55
73
|
def to_h(_reference_state, overrides: {})
|
56
74
|
{
|
57
75
|
name: name,
|
58
|
-
type:
|
76
|
+
type: avro_type_name,
|
59
77
|
namespace: namespace,
|
60
78
|
aliases: aliases
|
61
79
|
}.merge(overrides).reject { |_, v| v.nil? }
|
@@ -11,7 +11,7 @@ module Avro
|
|
11
11
|
dsl_attribute_alias :type_doc, :doc
|
12
12
|
|
13
13
|
def initialize(name = nil, options: {}, cache:, field: nil, &block)
|
14
|
-
@
|
14
|
+
@avro_type_name = :record
|
15
15
|
@name = name
|
16
16
|
@cache = cache
|
17
17
|
@field = field
|
@@ -25,12 +25,12 @@ module Avro
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# Add a required field to the record
|
28
|
-
def required(name,
|
28
|
+
def required(name, avro_type_name, options = {}, &block)
|
29
29
|
new_field = Avro::Builder::Field.new(name: name,
|
30
|
-
|
30
|
+
avro_type_name: avro_type_name,
|
31
31
|
record: self,
|
32
32
|
cache: cache,
|
33
|
-
internal: {
|
33
|
+
internal: { type_namespace: namespace },
|
34
34
|
options: options,
|
35
35
|
&block)
|
36
36
|
add_field(new_field)
|
@@ -38,12 +38,12 @@ module Avro
|
|
38
38
|
|
39
39
|
# Add an optional field to the record. In Avro this is represented
|
40
40
|
# as a union of null and the type specified here.
|
41
|
-
def optional(name,
|
41
|
+
def optional(name, avro_type_name, options = {}, &block)
|
42
42
|
new_field = Avro::Builder::Field.new(name: name,
|
43
|
-
|
43
|
+
avro_type_name: avro_type_name,
|
44
44
|
record: self,
|
45
45
|
cache: cache,
|
46
|
-
internal: {
|
46
|
+
internal: { type_namespace: namespace,
|
47
47
|
optional_field: true },
|
48
48
|
options: options,
|
49
49
|
&block)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Avro
|
2
|
+
module Builder
|
3
|
+
module Types
|
4
|
+
|
5
|
+
# This concern is used by types that can be defined at the top-level,
|
6
|
+
# i.e. outside a field.
|
7
|
+
module TopLevel
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.add_option_name :_name
|
11
|
+
end
|
12
|
+
|
13
|
+
# Provide a way to set the name internally for a top-level type.
|
14
|
+
def _name=(value)
|
15
|
+
@name = value
|
16
|
+
end
|
17
|
+
private :_name=
|
18
|
+
|
19
|
+
# Namespace is settable as a top-level option
|
20
|
+
attr_writer :namespace
|
21
|
+
|
22
|
+
module TopLevelErrorHandling
|
23
|
+
|
24
|
+
# Options disallowed for top-level types.
|
25
|
+
|
26
|
+
def type_name=(_value)
|
27
|
+
name_attribute_error!
|
28
|
+
end
|
29
|
+
|
30
|
+
def type_namespace=(_value)
|
31
|
+
namespace_instead_of_type_namespace_error!
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def type_aliases=(_value)
|
37
|
+
raise AttributeError
|
38
|
+
.new("'aliases' must be used instead of 'type_aliases'")
|
39
|
+
end
|
40
|
+
alias_method :type_aliases, :type_aliases=
|
41
|
+
|
42
|
+
def name_attribute_error!
|
43
|
+
raise AttributeError
|
44
|
+
.new("name must be specified as the first argument for #{avro_type_name}")
|
45
|
+
end
|
46
|
+
alias_method :type_name_instead_of_name_error!, :name_attribute_error!
|
47
|
+
private :type_name_instead_of_name_error!
|
48
|
+
|
49
|
+
def namespace_attribute_error!
|
50
|
+
raise AttributeError
|
51
|
+
.new("'namespace' must be specified as an option, not via a block")
|
52
|
+
end
|
53
|
+
alias_method :type_namespace_instead_of_namespace_error!, :namespace_attribute_error!
|
54
|
+
private :type_namespace_instead_of_namespace_error!
|
55
|
+
|
56
|
+
def namespace_instead_of_type_namespace_error!
|
57
|
+
raise AttributeError
|
58
|
+
.new("'namespace' must be specified as an option instead of 'type_namespace'")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
include TopLevelErrorHandling
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -8,16 +8,16 @@ module Avro
|
|
8
8
|
include Avro::Builder::DslOptions
|
9
9
|
include Avro::Builder::DslAttributes
|
10
10
|
|
11
|
-
attr_reader :
|
11
|
+
attr_reader :avro_type_name
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
13
|
+
def initialize(avro_type_name, cache:, field: nil)
|
14
|
+
@avro_type_name = avro_type_name
|
15
15
|
@cache = cache
|
16
16
|
@field = field
|
17
17
|
end
|
18
18
|
|
19
19
|
def serialize(_reference_state)
|
20
|
-
|
20
|
+
avro_type_name
|
21
21
|
end
|
22
22
|
|
23
23
|
def namespace
|
@@ -57,7 +57,7 @@ module Avro
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def required_attribute_error!(attribute_name)
|
60
|
-
raise RequiredAttributeError.new(type:
|
60
|
+
raise RequiredAttributeError.new(type: avro_type_name,
|
61
61
|
attribute: attribute_name,
|
62
62
|
field: field && field.name,
|
63
63
|
name: @name)
|
@@ -8,11 +8,11 @@ module Avro
|
|
8
8
|
module TypeReferencer
|
9
9
|
include Avro::Builder::TypeFactory
|
10
10
|
|
11
|
-
def create_builtin_or_lookup_named_type(
|
12
|
-
if builtin_type?(
|
13
|
-
create_builtin_type(
|
11
|
+
def create_builtin_or_lookup_named_type(avro_type_name)
|
12
|
+
if builtin_type?(avro_type_name)
|
13
|
+
create_builtin_type(avro_type_name, field: field, cache: cache)
|
14
14
|
else
|
15
|
-
cache.lookup_named_type(
|
15
|
+
cache.lookup_named_type(avro_type_name)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
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: 0.
|
4
|
+
version: 0.7.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: 2016-05-
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- ".overcommit.yml"
|
134
134
|
- ".rspec"
|
135
135
|
- ".rubocop.yml"
|
136
|
+
- ".ruby-version"
|
136
137
|
- ".travis.yml"
|
137
138
|
- CHANGELOG.md
|
138
139
|
- Gemfile
|
@@ -148,10 +149,13 @@ files:
|
|
148
149
|
- lib/avro/builder/dsl.rb
|
149
150
|
- lib/avro/builder/dsl_attributes.rb
|
150
151
|
- lib/avro/builder/dsl_options.rb
|
152
|
+
- lib/avro/builder/enum.rb
|
151
153
|
- lib/avro/builder/errors.rb
|
152
154
|
- lib/avro/builder/field.rb
|
153
155
|
- lib/avro/builder/file_handler.rb
|
156
|
+
- lib/avro/builder/fixed.rb
|
154
157
|
- lib/avro/builder/namespaceable.rb
|
158
|
+
- lib/avro/builder/record.rb
|
155
159
|
- lib/avro/builder/schema_serializer_reference_state.rb
|
156
160
|
- lib/avro/builder/type_factory.rb
|
157
161
|
- lib/avro/builder/types.rb
|
@@ -161,8 +165,10 @@ files:
|
|
161
165
|
- lib/avro/builder/types/enum_type.rb
|
162
166
|
- lib/avro/builder/types/fixed_type.rb
|
163
167
|
- lib/avro/builder/types/map_type.rb
|
168
|
+
- lib/avro/builder/types/named_error_handling.rb
|
164
169
|
- lib/avro/builder/types/named_type.rb
|
165
170
|
- lib/avro/builder/types/record_type.rb
|
171
|
+
- lib/avro/builder/types/top_level.rb
|
166
172
|
- lib/avro/builder/types/type.rb
|
167
173
|
- lib/avro/builder/types/type_referencer.rb
|
168
174
|
- lib/avro/builder/types/union_type.rb
|
@@ -187,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
193
|
version: '0'
|
188
194
|
requirements: []
|
189
195
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.5.1
|
191
197
|
signing_key:
|
192
198
|
specification_version: 4
|
193
199
|
summary: Ruby DSL to create Avro schemas
|