avromatic 2.2.0 → 2.2.5
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 -1
- data/.travis.yml +8 -15
- data/Appraisals +16 -22
- data/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/avromatic.gemspec +4 -4
- data/gemfiles/{rails5_0.gemfile → avro1_10_rails5_2.gemfile} +3 -3
- data/gemfiles/{rails5_1.gemfile → avro1_10_rails6_0.gemfile} +3 -3
- data/gemfiles/{rails5_2.gemfile → avro1_8_rails5_2.gemfile} +0 -0
- data/gemfiles/{avro_patches_rails5_0.gemfile → avro1_9_rails5_2.gemfile} +3 -3
- data/gemfiles/{rails6_0.gemfile → avro1_9_rails6_0.gemfile} +1 -1
- data/gemfiles/avro_patches_rails5_2.gemfile +1 -1
- data/lib/avromatic.rb +1 -3
- data/lib/avromatic/io/datum_reader.rb +3 -3
- data/lib/avromatic/io/datum_writer.rb +6 -0
- data/lib/avromatic/model/attributes.rb +6 -6
- data/lib/avromatic/model/nested_models.rb +13 -2
- data/lib/avromatic/model/raw_serialization.rb +5 -2
- data/lib/avromatic/model/types/abstract_timestamp_type.rb +1 -1
- data/lib/avromatic/model/types/abstract_type.rb +10 -1
- data/lib/avromatic/model/types/array_type.rb +6 -2
- data/lib/avromatic/model/types/boolean_type.rb +5 -1
- data/lib/avromatic/model/types/custom_type.rb +5 -1
- data/lib/avromatic/model/types/date_type.rb +5 -1
- data/lib/avromatic/model/types/enum_type.rb +5 -1
- data/lib/avromatic/model/types/fixed_type.rb +5 -1
- data/lib/avromatic/model/types/float_type.rb +5 -1
- data/lib/avromatic/model/types/integer_type.rb +5 -1
- data/lib/avromatic/model/types/map_type.rb +7 -2
- data/lib/avromatic/model/types/null_type.rb +5 -1
- data/lib/avromatic/model/types/record_type.rb +5 -1
- data/lib/avromatic/model/types/string_type.rb +6 -2
- data/lib/avromatic/model/types/timestamp_micros_type.rb +4 -1
- data/lib/avromatic/model/types/timestamp_millis_type.rb +4 -1
- data/lib/avromatic/model/types/union_type.rb +6 -2
- data/lib/avromatic/model_registry.rb +2 -1
- data/lib/avromatic/rspec.rb +6 -1
- data/lib/avromatic/version.rb +1 -1
- metadata +48 -49
- data/gemfiles/avro_patches_rails5_1.gemfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdd13d41971f1b38c3b1a9496ec698a14122b69ed5442b4cca7ac7e7d099c6b2
|
4
|
+
data.tar.gz: af4fbf880781abeffc7e0807491ca43a0fdabdff5714c60bfe46b365caa355a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856111e8a1f7e5ec99cbbe20877095ff630182f27265617e7746437402e4146628c5ae2812f85a9f0cd5c234b748bd1b1c8abee8fddb92e21bc137537074a0d4
|
7
|
+
data.tar.gz: 275aa990b3a84aaa679141955a93800cb4764fc0bbf44a290cbaebd4d54e1cd443f2a3943431b2781bcc6165df06861c7a0d6f9c6bf4c754732737518935d896
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.8
|
data/.travis.yml
CHANGED
@@ -1,23 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
3
|
+
- 2.5.8
|
4
|
+
- 2.6.6
|
5
|
+
- 2.7.1
|
6
6
|
before_script:
|
7
7
|
- bundle exec rubocop
|
8
8
|
gemfile:
|
9
|
-
- gemfiles/
|
10
|
-
- gemfiles/
|
11
|
-
- gemfiles/
|
12
|
-
- gemfiles/
|
13
|
-
- gemfiles/
|
14
|
-
- gemfiles/avro_patches_rails5_1.gemfile
|
9
|
+
- gemfiles/avro1_8_rails5_2.gemfile
|
10
|
+
- gemfiles/avro1_9_rails5_2.gemfile
|
11
|
+
- gemfiles/avro1_10_rails5_2.gemfile
|
12
|
+
- gemfiles/avro1_9_rails6_0.gemfile
|
13
|
+
- gemfiles/avro1_10_rails6_0.gemfile
|
15
14
|
- gemfiles/avro_patches_rails5_2.gemfile
|
16
15
|
- gemfiles/avro_patches_rails6_0.gemfile
|
17
16
|
script: bundle exec rspec
|
18
|
-
matrix:
|
19
|
-
exclude:
|
20
|
-
- rvm: 2.4.6
|
21
|
-
gemfile: gemfiles/rails6_0.gemfile
|
22
|
-
- rvm: 2.4.6
|
23
|
-
gemfile: gemfiles/avro_patches_rails6_0.gemfile
|
data/Appraisals
CHANGED
@@ -1,43 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise '
|
3
|
+
appraise 'avro1_8-rails5_2' do
|
4
4
|
gem 'avro', '1.8.2'
|
5
|
-
gem 'activesupport', '~> 5.0
|
6
|
-
gem 'activemodel', '~> 5.0
|
5
|
+
gem 'activesupport', '~> 5.2.0'
|
6
|
+
gem 'activemodel', '~> 5.2.0'
|
7
7
|
end
|
8
8
|
|
9
|
-
appraise '
|
10
|
-
gem 'avro', '1.
|
11
|
-
gem 'activesupport', '~> 5.
|
12
|
-
gem 'activemodel', '~> 5.
|
9
|
+
appraise 'avro1_9-rails5_2' do
|
10
|
+
gem 'avro', '1.9.2'
|
11
|
+
gem 'activesupport', '~> 5.2.0'
|
12
|
+
gem 'activemodel', '~> 5.2.0'
|
13
13
|
end
|
14
14
|
|
15
|
-
appraise 'rails5_2' do
|
16
|
-
gem 'avro', '1.
|
15
|
+
appraise 'avro1_10-rails5_2' do
|
16
|
+
gem 'avro', '~> 1.10.0'
|
17
17
|
gem 'activesupport', '~> 5.2.0'
|
18
18
|
gem 'activemodel', '~> 5.2.0'
|
19
19
|
end
|
20
20
|
|
21
|
-
appraise 'rails6_0' do
|
22
|
-
gem 'avro', '1.9.
|
21
|
+
appraise 'avro1_9-rails6_0' do
|
22
|
+
gem 'avro', '1.9.2'
|
23
23
|
gem 'activesupport', '~> 6.0.0'
|
24
24
|
gem 'activemodel', '~> 6.0.0'
|
25
25
|
end
|
26
26
|
|
27
|
-
appraise '
|
28
|
-
gem 'avro
|
29
|
-
gem 'activesupport', '~>
|
30
|
-
gem 'activemodel', '~>
|
31
|
-
end
|
32
|
-
|
33
|
-
appraise 'avro-patches-rails5_1' do
|
34
|
-
gem 'avro-patches', '>= 0.4.1'
|
35
|
-
gem 'activesupport', '~> 5.1.4'
|
36
|
-
gem 'activemodel', '~> 5.1.4'
|
27
|
+
appraise 'avro1_10-rails6_0' do
|
28
|
+
gem 'avro', '~> 1.10.0'
|
29
|
+
gem 'activesupport', '~> 6.0.0'
|
30
|
+
gem 'activemodel', '~> 6.0.0'
|
37
31
|
end
|
38
32
|
|
39
33
|
appraise 'avro-patches-rails5_2' do
|
40
|
-
gem 'avro-patches', '>= 0.4.1'
|
34
|
+
gem 'avro-patches', '>= 0.4.1', '< 1.0'
|
41
35
|
gem 'activesupport', '~> 5.2.0'
|
42
36
|
gem 'activemodel', '~> 5.2.0'
|
43
37
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# avromatic changelog
|
2
2
|
|
3
|
+
## v2.2.5
|
4
|
+
- Optimize memory usage when serializing, deserializing and instantiating models.
|
5
|
+
|
6
|
+
## v2.2.4
|
7
|
+
- Compatibility with Avro v1.10.x.
|
8
|
+
|
9
|
+
## v2.2.3
|
10
|
+
- Fix bug where method `#referenced_model_classes` was declared as private instead of public.
|
11
|
+
|
12
|
+
## v2.2.2
|
13
|
+
- Fix missing models in the model registry when in development by loading the nested models of eager loaded models.
|
14
|
+
- Fake schema registry support for stubbing URLs with usernames and passwords.
|
15
|
+
|
16
|
+
## v2.2.1
|
17
|
+
- Avoid allocating default empty hash in `Avromatic::IO::DatumReader.read_data`
|
18
|
+
|
3
19
|
## v2.2.0
|
4
20
|
- Add support for Rails 6.0.
|
5
21
|
- Drop support for Ruby < 2.4.
|
data/README.md
CHANGED
@@ -142,7 +142,7 @@ instance.eql?(MyModel.new(id: 123, name: 'Tesla Model 3', enabled: true)) # => t
|
|
142
142
|
instance.hash # => -1279155042741869898
|
143
143
|
|
144
144
|
# Retrieve a hash of the model's attributes via to_h, to_hash or attributes
|
145
|
-
instance
|
145
|
+
instance.to_h # => {:id=>123, :name=>"Tesla Model 3", :enabled=>true}
|
146
146
|
```
|
147
147
|
|
148
148
|
Or an `Avro::Schema` object can be specified directly:
|
data/avromatic.gemspec
CHANGED
@@ -24,20 +24,20 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_runtime_dependency 'activemodel', '>= 5.0', '< 6.1'
|
26
26
|
spec.add_runtime_dependency 'activesupport', '>= 5.0', '< 6.1'
|
27
|
-
spec.add_runtime_dependency 'avro', '>= 1.7.7', '< 1.
|
27
|
+
spec.add_runtime_dependency 'avro', '>= 1.7.7', '< 1.11'
|
28
28
|
spec.add_runtime_dependency 'avro_schema_registry-client', '>= 0.3.0'
|
29
29
|
spec.add_runtime_dependency 'avro_turf'
|
30
30
|
spec.add_runtime_dependency 'ice_nine'
|
31
31
|
|
32
|
+
spec.add_development_dependency 'appraisal'
|
32
33
|
spec.add_development_dependency 'avro-builder', '>= 0.12.0'
|
33
34
|
spec.add_development_dependency 'bundler', '>= 1.11'
|
35
|
+
spec.add_development_dependency 'overcommit', '0.35.0'
|
34
36
|
spec.add_development_dependency 'rake', '~> 10.0'
|
35
37
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
spec.add_development_dependency 'salsify_rubocop', '~> 0.52.1.1'
|
36
39
|
spec.add_development_dependency 'simplecov'
|
37
40
|
spec.add_development_dependency 'webmock'
|
38
41
|
# For AvroSchemaRegistry::FakeServer
|
39
|
-
spec.add_development_dependency 'appraisal'
|
40
|
-
spec.add_development_dependency 'overcommit', '0.35.0'
|
41
|
-
spec.add_development_dependency 'salsify_rubocop', '~> 0.52.1.1'
|
42
42
|
spec.add_development_dependency 'sinatra'
|
43
43
|
end
|
File without changes
|
data/lib/avromatic.rb
CHANGED
@@ -85,9 +85,7 @@ module Avromatic
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def self.eager_load_models!
|
88
|
-
|
89
|
-
nested_models.ensure_registered_model(model_name.constantize)
|
90
|
-
end
|
88
|
+
@eager_load_model_names&.each { |model_name| model_name.constantize.register! }
|
91
89
|
end
|
92
90
|
private_class_method :eager_load_models!
|
93
91
|
end
|
@@ -10,7 +10,7 @@ module Avromatic
|
|
10
10
|
|
11
11
|
UNION_MEMBER_INDEX = Avromatic::IO::UNION_MEMBER_INDEX
|
12
12
|
|
13
|
-
def read_data(writers_schema, readers_schema, decoder, initial_record =
|
13
|
+
def read_data(writers_schema, readers_schema, decoder, initial_record = nil)
|
14
14
|
# schema matching
|
15
15
|
unless self.class.match_schemas(writers_schema, readers_schema)
|
16
16
|
raise Avro::IO::SchemaMatchException.new(writers_schema, readers_schema)
|
@@ -25,7 +25,7 @@ module Avromatic
|
|
25
25
|
optional = readers_schema.schemas.first.type_sym == :null
|
26
26
|
union_info = if readers_schema.schemas.size == 2 && optional
|
27
27
|
# Avromatic does not treat the union of null and 1 other type as a union
|
28
|
-
|
28
|
+
nil
|
29
29
|
elsif optional
|
30
30
|
# Avromatic does not treat the null of an optional field as part of the union
|
31
31
|
{ UNION_MEMBER_INDEX => rs_index - 1 }
|
@@ -52,7 +52,7 @@ module Avromatic
|
|
52
52
|
when :array; read_array(writers_schema, readers_schema, decoder)
|
53
53
|
when :map; read_map(writers_schema, readers_schema, decoder)
|
54
54
|
when :union; read_union(writers_schema, readers_schema, decoder)
|
55
|
-
when :record, :error, :request; read_record(writers_schema, readers_schema, decoder, initial_record)
|
55
|
+
when :record, :error, :request; read_record(writers_schema, readers_schema, decoder, initial_record || {})
|
56
56
|
else
|
57
57
|
raise Avro::AvroError.new("Cannot read unknown schema type: #{writers_schema.type}")
|
58
58
|
end
|
@@ -5,6 +5,10 @@ module Avromatic
|
|
5
5
|
# Subclass DatumWriter to use additional information about union member
|
6
6
|
# index.
|
7
7
|
class DatumWriter < Avro::IO::DatumWriter
|
8
|
+
class << self
|
9
|
+
attr_accessor :optimize
|
10
|
+
end
|
11
|
+
|
8
12
|
def write_union(writers_schema, datum, encoder)
|
9
13
|
optional = writers_schema.schemas.first.type_sym == :null
|
10
14
|
if datum.is_a?(Hash) && datum.key?(Avromatic::IO::UNION_MEMBER_INDEX)
|
@@ -14,6 +18,8 @@ module Avromatic
|
|
14
18
|
elsif optional && writers_schema.schemas.size == 2
|
15
19
|
# Optimize for the common case of a union that's just an optional field
|
16
20
|
index_of_schema = datum.nil? ? 0 : 1
|
21
|
+
elsif self.class.optimize && optional && datum.nil?
|
22
|
+
index_of_schema = 0
|
17
23
|
else
|
18
24
|
index_of_schema = writers_schema.schemas.find_index do |schema|
|
19
25
|
Avro::Schema.validate(schema, datum)
|
@@ -74,23 +74,23 @@ module Avromatic
|
|
74
74
|
def initialize(data = {})
|
75
75
|
super()
|
76
76
|
|
77
|
-
|
77
|
+
num_valid_keys = 0
|
78
78
|
attribute_definitions.each do |attribute_name, attribute_definition|
|
79
79
|
if data.include?(attribute_name)
|
80
|
-
|
80
|
+
num_valid_keys += 1
|
81
81
|
value = data.fetch(attribute_name)
|
82
82
|
send(attribute_definition.setter_name, value)
|
83
83
|
elsif data.include?(attribute_definition.name_string)
|
84
|
-
|
84
|
+
num_valid_keys += 1
|
85
85
|
value = data[attribute_definition.name_string]
|
86
86
|
send(attribute_definition.setter_name, value)
|
87
|
-
elsif !
|
87
|
+
elsif !_attributes.include?(attribute_name)
|
88
88
|
send(attribute_definition.setter_name, attribute_definition.default)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
unless Avromatic.allow_unknown_attributes ||
|
93
|
-
unknown_attributes = (data.keys.map(&:to_s) -
|
92
|
+
unless Avromatic.allow_unknown_attributes || num_valid_keys == data.size
|
93
|
+
unknown_attributes = (data.keys.map(&:to_s) - _attributes.keys.map(&:to_s)).sort
|
94
94
|
allowed_attributes = attribute_definitions.keys.map(&:to_s).sort
|
95
95
|
message = "Unexpected arguments for #{self.class.name}#initialize: #{unknown_attributes.join(', ')}. " \
|
96
96
|
"Only the following arguments are allowed: #{allowed_attributes.join(', ')}. Provided arguments: #{data.inspect}"
|
@@ -12,10 +12,21 @@ module Avromatic
|
|
12
12
|
module ClassMethods
|
13
13
|
# Register this model if it can be used as a nested model.
|
14
14
|
def register!
|
15
|
-
|
16
|
-
|
15
|
+
return unless key_avro_schema.nil? && value_avro_schema.type_sym == :record
|
16
|
+
|
17
|
+
roots = [self]
|
18
|
+
until roots.empty?
|
19
|
+
model = roots.shift
|
20
|
+
next if nested_models.registered?(model)
|
21
|
+
|
22
|
+
nested_models.register(model)
|
23
|
+
roots.concat(model.referenced_model_classes)
|
17
24
|
end
|
18
25
|
end
|
26
|
+
|
27
|
+
def referenced_model_classes
|
28
|
+
attribute_definitions.values.flat_map { |definition| definition.type.referenced_model_classes }.freeze
|
29
|
+
end
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
@@ -55,8 +55,11 @@ module Avromatic
|
|
55
55
|
|
56
56
|
def avro_hash(fields, strict: false, validate:)
|
57
57
|
avro_validate! if validate
|
58
|
-
|
59
|
-
|
58
|
+
fields.each_with_object(Hash.new) do |field, result|
|
59
|
+
next unless _attributes.include?(field)
|
60
|
+
|
61
|
+
value = _attributes[field]
|
62
|
+
result[field.to_s] = attribute_definitions[field].serialize(value, strict)
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
@@ -4,6 +4,9 @@ module Avromatic
|
|
4
4
|
module Model
|
5
5
|
module Types
|
6
6
|
class AbstractType
|
7
|
+
EMPTY_ARRAY = [].freeze
|
8
|
+
private_constant :EMPTY_ARRAY
|
9
|
+
|
7
10
|
def value_classes
|
8
11
|
raise "#{__method__} must be overridden by #{self.class.name}"
|
9
12
|
end
|
@@ -28,7 +31,13 @@ module Avromatic
|
|
28
31
|
raise "#{__method__} must be overridden by #{self.class.name}"
|
29
32
|
end
|
30
33
|
|
31
|
-
|
34
|
+
# Note we use positional args rather than keyword args to reduce
|
35
|
+
# memory allocations
|
36
|
+
def serialize(_value, _strict)
|
37
|
+
raise "#{__method__} must be overridden by #{self.class.name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def referenced_model_classes
|
32
41
|
raise "#{__method__} must be overridden by #{self.class.name}"
|
33
42
|
end
|
34
43
|
end
|
@@ -40,13 +40,17 @@ module Avromatic
|
|
40
40
|
value.nil? || (value.is_a?(::Array) && value.all? { |element| value_type.coerced?(element) })
|
41
41
|
end
|
42
42
|
|
43
|
-
def serialize(value, strict
|
43
|
+
def serialize(value, strict)
|
44
44
|
if value.nil?
|
45
45
|
value
|
46
46
|
else
|
47
|
-
value.map { |element| value_type.serialize(element, strict
|
47
|
+
value.map { |element| value_type.serialize(element, strict) }
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
def referenced_model_classes
|
52
|
+
value_type.referenced_model_classes
|
53
|
+
end
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
@@ -47,9 +47,13 @@ module Avromatic
|
|
47
47
|
(input.is_a?(::Symbol) && allowed_values.include?(input.to_s))
|
48
48
|
end
|
49
49
|
|
50
|
-
def serialize(value,
|
50
|
+
def serialize(value, _strict)
|
51
51
|
value
|
52
52
|
end
|
53
|
+
|
54
|
+
def referenced_model_classes
|
55
|
+
EMPTY_ARRAY
|
56
|
+
end
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
@@ -59,15 +59,20 @@ module Avromatic
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def serialize(value, strict
|
62
|
+
def serialize(value, strict)
|
63
63
|
if value.nil?
|
64
64
|
value
|
65
65
|
else
|
66
66
|
value.each_with_object({}) do |(element_key, element_value), result|
|
67
|
-
result[key_type.serialize(element_key, strict
|
67
|
+
result[key_type.serialize(element_key, strict)] = value_type.serialize(element_value, strict)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
def referenced_model_classes
|
73
|
+
# According to Avro's spec, keys can only be strings, so we can safely disregard #key_type here.
|
74
|
+
value_type.referenced_model_classes
|
75
|
+
end
|
71
76
|
end
|
72
77
|
end
|
73
78
|
end
|
@@ -39,7 +39,7 @@ module Avromatic
|
|
39
39
|
value.nil? || value.is_a?(record_class)
|
40
40
|
end
|
41
41
|
|
42
|
-
def serialize(value, strict
|
42
|
+
def serialize(value, strict)
|
43
43
|
if value.nil?
|
44
44
|
value
|
45
45
|
elsif !strict && Avromatic.use_custom_datum_writer && Avromatic.use_encoding_providers? && !record_class.config.mutable
|
@@ -51,6 +51,10 @@ module Avromatic
|
|
51
51
|
strict ? value.avro_value_datum(validate: false) : value.value_attributes_for_avro(validate: false)
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
def referenced_model_classes
|
56
|
+
[record_class].freeze
|
57
|
+
end
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
@@ -5,7 +5,7 @@ require 'avromatic/model/types/abstract_type'
|
|
5
5
|
module Avromatic
|
6
6
|
module Model
|
7
7
|
module Types
|
8
|
-
class StringType
|
8
|
+
class StringType < AbstractType
|
9
9
|
VALUE_CLASSES = [::String].freeze
|
10
10
|
INPUT_CLASSES = [::String, ::Symbol].freeze
|
11
11
|
|
@@ -39,9 +39,13 @@ module Avromatic
|
|
39
39
|
value.nil? || value.is_a?(::String)
|
40
40
|
end
|
41
41
|
|
42
|
-
def serialize(value,
|
42
|
+
def serialize(value, _strict)
|
43
43
|
value
|
44
44
|
end
|
45
|
+
|
46
|
+
def referenced_model_classes
|
47
|
+
EMPTY_ARRAY
|
48
|
+
end
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
@@ -13,6 +13,10 @@ module Avromatic
|
|
13
13
|
'timestamp-micros'
|
14
14
|
end
|
15
15
|
|
16
|
+
def referenced_model_classes
|
17
|
+
EMPTY_ARRAY
|
18
|
+
end
|
19
|
+
|
16
20
|
private
|
17
21
|
|
18
22
|
def truncated?(value)
|
@@ -25,7 +29,6 @@ module Avromatic
|
|
25
29
|
# of time zone.
|
26
30
|
::Time.at(input.to_i, input.usec)
|
27
31
|
end
|
28
|
-
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -13,6 +13,10 @@ module Avromatic
|
|
13
13
|
'timestamp-millis'
|
14
14
|
end
|
15
15
|
|
16
|
+
def referenced_model_classes
|
17
|
+
EMPTY_ARRAY
|
18
|
+
end
|
19
|
+
|
16
20
|
private
|
17
21
|
|
18
22
|
def truncated?(value)
|
@@ -25,7 +29,6 @@ module Avromatic
|
|
25
29
|
# of time zone.
|
26
30
|
::Time.at(input.to_i, input.usec / 1000 * 1000)
|
27
31
|
end
|
28
|
-
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -51,7 +51,7 @@ module Avromatic
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def serialize(value, strict
|
54
|
+
def serialize(value, strict)
|
55
55
|
# Avromatic does not treat the null of an optional field as part of the union
|
56
56
|
return nil if value.nil?
|
57
57
|
|
@@ -60,13 +60,17 @@ module Avromatic
|
|
60
60
|
raise ArgumentError.new("Expected #{value.inspect} to be one of #{value_classes.map(&:name)}")
|
61
61
|
end
|
62
62
|
|
63
|
-
hash = member_types[member_index].serialize(value, strict
|
63
|
+
hash = member_types[member_index].serialize(value, strict)
|
64
64
|
if !strict && Avromatic.use_custom_datum_writer && value.is_a?(Avromatic::Model::Attributes)
|
65
65
|
hash[Avromatic::IO::UNION_MEMBER_INDEX] = member_index
|
66
66
|
end
|
67
67
|
hash
|
68
68
|
end
|
69
69
|
|
70
|
+
def referenced_model_classes
|
71
|
+
member_types.flat_map(&:referenced_model_classes).tap(&:uniq!).freeze
|
72
|
+
end
|
73
|
+
|
70
74
|
private
|
71
75
|
|
72
76
|
def find_index(value)
|
data/lib/avromatic/rspec.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'uri'
|
3
4
|
require 'webmock/rspec'
|
4
5
|
require 'avro_schema_registry/test/fake_server'
|
5
6
|
|
6
7
|
RSpec.configure do |config|
|
7
8
|
config.before(:each) do
|
8
|
-
WebMock
|
9
|
+
# Strip the username/password from the URL so WebMock can match the URL
|
10
|
+
registry_uri = URI(Avromatic.registry_url)
|
11
|
+
registry_uri.userinfo = ''
|
12
|
+
|
13
|
+
WebMock.stub_request(:any, /^#{registry_uri}/).to_rack(AvroSchemaRegistry::FakeServer)
|
9
14
|
AvroSchemaRegistry::FakeServer.clear
|
10
15
|
Avromatic.build_messaging!
|
11
16
|
end
|
data/lib/avromatic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avromatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.5
|
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-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: 1.7.7
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '1.
|
62
|
+
version: '1.11'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: 1.7.7
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '1.
|
72
|
+
version: '1.11'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: avro_schema_registry-client
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: appraisal
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: avro-builder
|
117
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +154,20 @@ dependencies:
|
|
140
154
|
- - ">="
|
141
155
|
- !ruby/object:Gem::Version
|
142
156
|
version: '1.11'
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
name: overcommit
|
159
|
+
requirement: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - '='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 0.35.0
|
164
|
+
type: :development
|
165
|
+
prerelease: false
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - '='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 0.35.0
|
143
171
|
- !ruby/object:Gem::Dependency
|
144
172
|
name: rake
|
145
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,21 +197,21 @@ dependencies:
|
|
169
197
|
- !ruby/object:Gem::Version
|
170
198
|
version: '3.0'
|
171
199
|
- !ruby/object:Gem::Dependency
|
172
|
-
name:
|
200
|
+
name: salsify_rubocop
|
173
201
|
requirement: !ruby/object:Gem::Requirement
|
174
202
|
requirements:
|
175
|
-
- - "
|
203
|
+
- - "~>"
|
176
204
|
- !ruby/object:Gem::Version
|
177
|
-
version:
|
205
|
+
version: 0.52.1.1
|
178
206
|
type: :development
|
179
207
|
prerelease: false
|
180
208
|
version_requirements: !ruby/object:Gem::Requirement
|
181
209
|
requirements:
|
182
|
-
- - "
|
210
|
+
- - "~>"
|
183
211
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
212
|
+
version: 0.52.1.1
|
185
213
|
- !ruby/object:Gem::Dependency
|
186
|
-
name:
|
214
|
+
name: simplecov
|
187
215
|
requirement: !ruby/object:Gem::Requirement
|
188
216
|
requirements:
|
189
217
|
- - ">="
|
@@ -197,7 +225,7 @@ dependencies:
|
|
197
225
|
- !ruby/object:Gem::Version
|
198
226
|
version: '0'
|
199
227
|
- !ruby/object:Gem::Dependency
|
200
|
-
name:
|
228
|
+
name: webmock
|
201
229
|
requirement: !ruby/object:Gem::Requirement
|
202
230
|
requirements:
|
203
231
|
- - ">="
|
@@ -210,34 +238,6 @@ dependencies:
|
|
210
238
|
- - ">="
|
211
239
|
- !ruby/object:Gem::Version
|
212
240
|
version: '0'
|
213
|
-
- !ruby/object:Gem::Dependency
|
214
|
-
name: overcommit
|
215
|
-
requirement: !ruby/object:Gem::Requirement
|
216
|
-
requirements:
|
217
|
-
- - '='
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
version: 0.35.0
|
220
|
-
type: :development
|
221
|
-
prerelease: false
|
222
|
-
version_requirements: !ruby/object:Gem::Requirement
|
223
|
-
requirements:
|
224
|
-
- - '='
|
225
|
-
- !ruby/object:Gem::Version
|
226
|
-
version: 0.35.0
|
227
|
-
- !ruby/object:Gem::Dependency
|
228
|
-
name: salsify_rubocop
|
229
|
-
requirement: !ruby/object:Gem::Requirement
|
230
|
-
requirements:
|
231
|
-
- - "~>"
|
232
|
-
- !ruby/object:Gem::Version
|
233
|
-
version: 0.52.1.1
|
234
|
-
type: :development
|
235
|
-
prerelease: false
|
236
|
-
version_requirements: !ruby/object:Gem::Requirement
|
237
|
-
requirements:
|
238
|
-
- - "~>"
|
239
|
-
- !ruby/object:Gem::Version
|
240
|
-
version: 0.52.1.1
|
241
241
|
- !ruby/object:Gem::Dependency
|
242
242
|
name: sinatra
|
243
243
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,14 +276,13 @@ files:
|
|
276
276
|
- bin/console
|
277
277
|
- bin/setup
|
278
278
|
- gemfiles/.bundle/config
|
279
|
-
- gemfiles/
|
280
|
-
- gemfiles/
|
279
|
+
- gemfiles/avro1_10_rails5_2.gemfile
|
280
|
+
- gemfiles/avro1_10_rails6_0.gemfile
|
281
|
+
- gemfiles/avro1_8_rails5_2.gemfile
|
282
|
+
- gemfiles/avro1_9_rails5_2.gemfile
|
283
|
+
- gemfiles/avro1_9_rails6_0.gemfile
|
281
284
|
- gemfiles/avro_patches_rails5_2.gemfile
|
282
285
|
- gemfiles/avro_patches_rails6_0.gemfile
|
283
|
-
- gemfiles/rails5_0.gemfile
|
284
|
-
- gemfiles/rails5_1.gemfile
|
285
|
-
- gemfiles/rails5_2.gemfile
|
286
|
-
- gemfiles/rails6_0.gemfile
|
287
286
|
- lib/avromatic.rb
|
288
287
|
- lib/avromatic/io.rb
|
289
288
|
- lib/avromatic/io/datum_reader.rb
|
@@ -335,7 +334,7 @@ homepage: https://github.com/salsify/avromatic.git
|
|
335
334
|
licenses:
|
336
335
|
- MIT
|
337
336
|
metadata: {}
|
338
|
-
post_install_message:
|
337
|
+
post_install_message:
|
339
338
|
rdoc_options: []
|
340
339
|
require_paths:
|
341
340
|
- lib
|
@@ -350,8 +349,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
349
|
- !ruby/object:Gem::Version
|
351
350
|
version: '0'
|
352
351
|
requirements: []
|
353
|
-
rubygems_version: 3.0.
|
354
|
-
signing_key:
|
352
|
+
rubygems_version: 3.0.8
|
353
|
+
signing_key:
|
355
354
|
specification_version: 4
|
356
355
|
summary: Generate Ruby models from Avro schemas
|
357
356
|
test_files: []
|