avromatic 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/avromatic.gemspec +1 -1
- data/lib/avromatic/model/attributes.rb +4 -3
- data/lib/avromatic/model/message_decoder.rb +7 -3
- data/lib/avromatic/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b0e4d3f2c32f7c18ceac64edce77b91493fe72abf24fc6cd05a5b0deb315e68
|
4
|
+
data.tar.gz: f9b3bdbfa7cf25e8d94c5f87637ceb0f1dfab2eacc04100a600c7904171baa81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a92e2cd960aed018a35ab16362141572ff123dc81a92d0f10cd2c651918d26b465ea14240b90134a1572afeecd733afafcaca56a0d3eea898d8801d7bb2c103
|
7
|
+
data.tar.gz: 9b168f4d7d4779e6617eadf41b39bb0d4ae867ef2e49dc757be5b1b4074b5d489a0485368263639189456b3462bd024e989591925f9ab20590dfec2b67c5ad4a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# avromatic changelog
|
2
2
|
|
3
|
+
## v2.1.0
|
4
|
+
- Add `key_schema_name` and `value_schema_name` attributes to `UnexpectedKeyError`.
|
5
|
+
|
6
|
+
## v2.0.2
|
7
|
+
- Optimize model initialization and decoding
|
8
|
+
|
3
9
|
## v2.0.1
|
4
10
|
- Allow generated model attribute accessors to be overridden. This was a regression in Avromatic 2.0.0.
|
5
11
|
- Ensure that timestamp-millis are coerced when the number of microseconds is divisible by 1,000 but the
|
data/avromatic.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_runtime_dependency 'ice_nine'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'avro-builder', '>= 0.12.0'
|
33
|
-
spec.add_development_dependency 'bundler', '
|
33
|
+
spec.add_development_dependency 'bundler', '>= 1.11'
|
34
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
35
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
36
|
spec.add_development_dependency 'simplecov'
|
@@ -21,7 +21,7 @@ module Avromatic
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class AttributeDefinition
|
24
|
-
attr_reader :name, :setter_name, :type, :field, :default, :owner
|
24
|
+
attr_reader :name, :name_string, :setter_name, :type, :field, :default, :owner
|
25
25
|
delegate :serialize, to: :type
|
26
26
|
|
27
27
|
def initialize(owner:, field:, type:)
|
@@ -29,6 +29,7 @@ module Avromatic
|
|
29
29
|
@field = field
|
30
30
|
@type = type
|
31
31
|
@name = field.name.to_sym
|
32
|
+
@name_string = field.name.to_s.dup.freeze
|
32
33
|
@setter_name = "#{field.name}=".to_sym
|
33
34
|
@default = if field.default == :no_default
|
34
35
|
nil
|
@@ -79,9 +80,9 @@ module Avromatic
|
|
79
80
|
valid_keys << attribute_name
|
80
81
|
value = data.fetch(attribute_name)
|
81
82
|
send(attribute_definition.setter_name, value)
|
82
|
-
elsif data.include?(
|
83
|
+
elsif data.include?(attribute_definition.name_string)
|
83
84
|
valid_keys << attribute_name
|
84
|
-
value = data[
|
85
|
+
value = data[attribute_definition.name_string]
|
85
86
|
send(attribute_definition.setter_name, value)
|
86
87
|
elsif !attributes.include?(attribute_name)
|
87
88
|
send(attribute_definition.setter_name, attribute_definition.default)
|
@@ -9,8 +9,12 @@ module Avromatic
|
|
9
9
|
MAGIC_BYTE = [0].pack('C').freeze
|
10
10
|
|
11
11
|
class UnexpectedKeyError < StandardError
|
12
|
-
|
13
|
-
|
12
|
+
attr_reader :key_schema_name, :value_schema_name
|
13
|
+
|
14
|
+
def initialize(key_schema_name, value_schema_name)
|
15
|
+
super("Unexpected schemas #{[key_schema_name, value_schema_name]}")
|
16
|
+
@key_schema_name = key_schema_name
|
17
|
+
@value_schema_name = value_schema_name
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -84,7 +88,7 @@ module Avromatic
|
|
84
88
|
def extract_decode_args(*args)
|
85
89
|
message_key, message_value = extract_key_and_value(*args)
|
86
90
|
model_key = model_key_for_message(message_key, message_value)
|
87
|
-
raise UnexpectedKeyError.new(model_key) unless model_map.key?(model_key)
|
91
|
+
raise UnexpectedKeyError.new(*model_key) unless model_map.key?(model_key)
|
88
92
|
[model_map[model_key], message_key, message_value]
|
89
93
|
end
|
90
94
|
|
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.0
|
4
|
+
version: 2.1.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:
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -124,14 +124,14 @@ dependencies:
|
|
124
124
|
name: bundler
|
125
125
|
requirement: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- - "
|
127
|
+
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '1.11'
|
130
130
|
type: :development
|
131
131
|
prerelease: false
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - "
|
134
|
+
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '1.11'
|
137
137
|
- !ruby/object:Gem::Dependency
|