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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 281093ac30d6f1f5bf7fa5949466ce74b2223968db553e15e473e09c81fc574d
4
- data.tar.gz: 0a89d649b7b86d8a1cc55dba25af9dfdab2f7789f2c4daa996b0dab6ba7fd210
3
+ metadata.gz: 2b0e4d3f2c32f7c18ceac64edce77b91493fe72abf24fc6cd05a5b0deb315e68
4
+ data.tar.gz: f9b3bdbfa7cf25e8d94c5f87637ceb0f1dfab2eacc04100a600c7904171baa81
5
5
  SHA512:
6
- metadata.gz: e13e24a119085b1bf8e6f31d83cda3a8d99092026006601a48d21c29516eefb511d1cccaa3080f346bb91b91397433787638b13ee8e2980286b8c06cf0300d07
7
- data.tar.gz: 8151877e50ab9e2ca498ea52f990c3fce6e5a87a31972c09cea6bbe1c5654265f52e2a7c5dd577d934b0fdd1b8adf7eee1123481333714c4dedef42afd5d83e4
6
+ metadata.gz: 9a92e2cd960aed018a35ab16362141572ff123dc81a92d0f10cd2c651918d26b465ea14240b90134a1572afeecd733afafcaca56a0d3eea898d8801d7bb2c103
7
+ data.tar.gz: 9b168f4d7d4779e6617eadf41b39bb0d4ae867ef2e49dc757be5b1b4074b5d489a0485368263639189456b3462bd024e989591925f9ab20590dfec2b67c5ad4a
@@ -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
@@ -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', '~> 1.11'
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?(attribute_name.to_s)
83
+ elsif data.include?(attribute_definition.name_string)
83
84
  valid_keys << attribute_name
84
- value = data[attribute_name.to_s]
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
- def initialize(schema_key)
13
- super("Unexpected schemas #{schema_key}")
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avromatic
4
- VERSION = '2.0.1'
4
+ VERSION = '2.1.0'
5
5
  end
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.1
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: 2018-10-24 00:00:00.000000000 Z
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