avromatic 2.2.6 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +89 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +4 -1
- data/Appraisals +8 -14
- data/CHANGELOG.md +26 -0
- data/README.md +6 -20
- data/avromatic.gemspec +9 -8
- data/bin/console +4 -3
- data/gemfiles/avro1_10_rails6_1.gemfile +9 -0
- data/gemfiles/{avro1_8_rails5_2.gemfile → avro1_9_rails6_1.gemfile} +3 -3
- data/lib/avromatic.rb +4 -5
- data/lib/avromatic/io.rb +1 -7
- data/lib/avromatic/io/datum_reader.rb +18 -68
- data/lib/avromatic/io/datum_writer.rb +5 -11
- data/lib/avromatic/io/union_datum.rb +25 -0
- data/lib/avromatic/messaging.rb +4 -2
- data/lib/avromatic/model/attributes.rb +22 -3
- data/lib/avromatic/model/configurable.rb +6 -2
- data/lib/avromatic/model/configuration.rb +5 -0
- data/lib/avromatic/model/field_helper.rb +5 -1
- data/lib/avromatic/model/messaging_serialization.rb +2 -1
- data/lib/avromatic/model/nested_models.rb +4 -2
- data/lib/avromatic/model/raw_serialization.rb +65 -25
- data/lib/avromatic/model/types/record_type.rb +3 -6
- data/lib/avromatic/model/types/union_type.rb +11 -8
- data/lib/avromatic/model/validation.rb +2 -2
- data/lib/avromatic/model_registry.rb +11 -2
- data/lib/avromatic/rspec.rb +1 -0
- data/lib/avromatic/version.rb +1 -1
- metadata +41 -29
- data/.travis.yml +0 -16
- data/gemfiles/avro_patches_rails5_2.gemfile +0 -9
- data/gemfiles/avro_patches_rails6_0.gemfile +0 -9
- data/lib/avromatic/patches.rb +0 -18
- data/lib/avromatic/patches/schema_validator_patch.rb +0 -39
@@ -42,8 +42,11 @@ module Avromatic
|
|
42
42
|
def ensure_registered_model(model)
|
43
43
|
name = model_fullname(model)
|
44
44
|
if registered?(name)
|
45
|
-
|
46
|
-
|
45
|
+
existing_model = fetch(name)
|
46
|
+
unless existing_model.equal?(model)
|
47
|
+
raise "Attempted to replace existing Avromatic model #{model_debug_name(existing_model)} with new model " \
|
48
|
+
"#{model_debug_name(model)} as '#{name}'. Perhaps '#{model_debug_name(model)}' needs to be eager loaded " \
|
49
|
+
'via the Avromatic eager_load_models setting?'
|
47
50
|
end
|
48
51
|
else
|
49
52
|
register(model)
|
@@ -65,5 +68,11 @@ module Avromatic
|
|
65
68
|
|
66
69
|
value.start_with?('.') ? value.from(1) : value
|
67
70
|
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def model_debug_name(model)
|
75
|
+
model.name || model.to_s
|
76
|
+
end
|
68
77
|
end
|
69
78
|
end
|
data/lib/avromatic/rspec.rb
CHANGED
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:
|
4
|
+
version: 3.0.2
|
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: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,47 +16,47 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '6.
|
22
|
+
version: '6.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '5.
|
29
|
+
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '6.
|
32
|
+
version: '6.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '5.
|
39
|
+
version: '5.2'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '6.
|
42
|
+
version: '6.2'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '5.
|
49
|
+
version: '5.2'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '6.
|
52
|
+
version: '6.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: avro
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
59
|
+
version: 1.9.0
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.11'
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.
|
69
|
+
version: 1.9.0
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '1.11'
|
@@ -76,14 +76,14 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
79
|
+
version: 0.4.0
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.
|
86
|
+
version: 0.4.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: avro_turf
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,16 +144,16 @@ dependencies:
|
|
144
144
|
name: bundler
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- - "
|
147
|
+
- - "~>"
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: '
|
149
|
+
version: '2.0'
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
153
|
requirements:
|
154
|
-
- - "
|
154
|
+
- - "~>"
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: '
|
156
|
+
version: '2.0'
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: overcommit
|
159
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,28 +174,42 @@ dependencies:
|
|
174
174
|
requirements:
|
175
175
|
- - "~>"
|
176
176
|
- !ruby/object:Gem::Version
|
177
|
-
version: '
|
177
|
+
version: '13.0'
|
178
178
|
type: :development
|
179
179
|
prerelease: false
|
180
180
|
version_requirements: !ruby/object:Gem::Requirement
|
181
181
|
requirements:
|
182
182
|
- - "~>"
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version: '
|
184
|
+
version: '13.0'
|
185
185
|
- !ruby/object:Gem::Dependency
|
186
186
|
name: rspec
|
187
187
|
requirement: !ruby/object:Gem::Requirement
|
188
188
|
requirements:
|
189
189
|
- - "~>"
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version: '3.
|
191
|
+
version: '3.8'
|
192
192
|
type: :development
|
193
193
|
prerelease: false
|
194
194
|
version_requirements: !ruby/object:Gem::Requirement
|
195
195
|
requirements:
|
196
196
|
- - "~>"
|
197
197
|
- !ruby/object:Gem::Version
|
198
|
-
version: '3.
|
198
|
+
version: '3.8'
|
199
|
+
- !ruby/object:Gem::Dependency
|
200
|
+
name: rspec_junit_formatter
|
201
|
+
requirement: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
type: :development
|
207
|
+
prerelease: false
|
208
|
+
version_requirements: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
199
213
|
- !ruby/object:Gem::Dependency
|
200
214
|
name: salsify_rubocop
|
201
215
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,13 +273,13 @@ executables: []
|
|
259
273
|
extensions: []
|
260
274
|
extra_rdoc_files: []
|
261
275
|
files:
|
276
|
+
- ".circleci/config.yml"
|
262
277
|
- ".gitignore"
|
263
278
|
- ".overcommit.yml"
|
264
279
|
- ".rspec"
|
265
280
|
- ".rubocop.yml"
|
266
281
|
- ".ruby-gemset"
|
267
282
|
- ".ruby-version"
|
268
|
-
- ".travis.yml"
|
269
283
|
- Appraisals
|
270
284
|
- CHANGELOG.md
|
271
285
|
- Gemfile
|
@@ -278,15 +292,15 @@ files:
|
|
278
292
|
- gemfiles/.bundle/config
|
279
293
|
- gemfiles/avro1_10_rails5_2.gemfile
|
280
294
|
- gemfiles/avro1_10_rails6_0.gemfile
|
281
|
-
- gemfiles/
|
295
|
+
- gemfiles/avro1_10_rails6_1.gemfile
|
282
296
|
- gemfiles/avro1_9_rails5_2.gemfile
|
283
297
|
- gemfiles/avro1_9_rails6_0.gemfile
|
284
|
-
- gemfiles/
|
285
|
-
- gemfiles/avro_patches_rails6_0.gemfile
|
298
|
+
- gemfiles/avro1_9_rails6_1.gemfile
|
286
299
|
- lib/avromatic.rb
|
287
300
|
- lib/avromatic/io.rb
|
288
301
|
- lib/avromatic/io/datum_reader.rb
|
289
302
|
- lib/avromatic/io/datum_writer.rb
|
303
|
+
- lib/avromatic/io/union_datum.rb
|
290
304
|
- lib/avromatic/messaging.rb
|
291
305
|
- lib/avromatic/model.rb
|
292
306
|
- lib/avromatic/model/attributes.rb
|
@@ -324,8 +338,6 @@ files:
|
|
324
338
|
- lib/avromatic/model/validation_error.rb
|
325
339
|
- lib/avromatic/model/value_object.rb
|
326
340
|
- lib/avromatic/model_registry.rb
|
327
|
-
- lib/avromatic/patches.rb
|
328
|
-
- lib/avromatic/patches/schema_validator_patch.rb
|
329
341
|
- lib/avromatic/railtie.rb
|
330
342
|
- lib/avromatic/rspec.rb
|
331
343
|
- lib/avromatic/version.rb
|
@@ -342,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
342
354
|
requirements:
|
343
355
|
- - ">="
|
344
356
|
- !ruby/object:Gem::Version
|
345
|
-
version: '2.
|
357
|
+
version: '2.5'
|
346
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
347
359
|
requirements:
|
348
360
|
- - ">="
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.5.8
|
4
|
-
- 2.6.6
|
5
|
-
- 2.7.1
|
6
|
-
before_script:
|
7
|
-
- bundle exec rubocop
|
8
|
-
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
|
14
|
-
- gemfiles/avro_patches_rails5_2.gemfile
|
15
|
-
- gemfiles/avro_patches_rails6_0.gemfile
|
16
|
-
script: bundle exec rspec
|
data/lib/avromatic/patches.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
loaded_avro_patches = begin
|
4
|
-
require 'avro-patches'
|
5
|
-
true
|
6
|
-
rescue LoadError
|
7
|
-
false
|
8
|
-
end
|
9
|
-
|
10
|
-
if loaded_avro_patches
|
11
|
-
require 'avromatic/patches/schema_validator_patch'
|
12
|
-
avro_patches_version = Gem::Version.new(AvroPatches::VERSION)
|
13
|
-
if avro_patches_version < Gem::Version.new('0.4.0')
|
14
|
-
Avro::SchemaValidator.singleton_class.prepend(Avromatic::Patches::SchemaValidatorPatch)
|
15
|
-
else
|
16
|
-
Avro::SchemaValidator.singleton_class.prepend(Avromatic::Patches::SchemaValidatorPatchV040)
|
17
|
-
end
|
18
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avromatic
|
4
|
-
module Patches
|
5
|
-
module SchemaValidatorPatch
|
6
|
-
# This method replaces validate_recursive in AvroPatches::LogicalTypes::SchemaValidatorPatch
|
7
|
-
# to enable validating datums that contain an encoding provider.
|
8
|
-
def validate_recursive(expected_schema, logical_datum, path, result, encoded = false)
|
9
|
-
datum = resolve_datum(expected_schema, logical_datum, encoded)
|
10
|
-
case expected_schema.type_sym
|
11
|
-
when :record, :error, :request
|
12
|
-
if datum.is_a?(Hash) && datum.key?(Avromatic::IO::ENCODING_PROVIDER)
|
13
|
-
return if expected_schema.sha256_resolution_fingerprint ==
|
14
|
-
datum[Avromatic::IO::ENCODING_PROVIDER].value_avro_schema.sha256_resolution_fingerprint
|
15
|
-
raise Avro::SchemaValidator::ValidationError
|
16
|
-
end
|
17
|
-
end
|
18
|
-
super(expected_schema, logical_datum, path, result, encoded)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module SchemaValidatorPatchV040
|
23
|
-
# This method replaces validate_recursive in AvroPatches::LogicalTypes::SchemaValidatorPatch
|
24
|
-
# to enable validating datums that contain an encoding provider.
|
25
|
-
def validate_recursive(expected_schema, logical_datum, path, result, options = {})
|
26
|
-
datum = resolve_datum(expected_schema, logical_datum, options[:encoded])
|
27
|
-
case expected_schema.type_sym
|
28
|
-
when :record, :error, :request
|
29
|
-
if datum.is_a?(Hash) && datum.key?(Avromatic::IO::ENCODING_PROVIDER)
|
30
|
-
return if expected_schema.sha256_resolution_fingerprint ==
|
31
|
-
datum[Avromatic::IO::ENCODING_PROVIDER].value_avro_schema.sha256_resolution_fingerprint
|
32
|
-
raise Avro::SchemaValidator::ValidationError
|
33
|
-
end
|
34
|
-
end
|
35
|
-
super(expected_schema, logical_datum, path, result, options)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|