deimos-ruby 1.13.3 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +6 -0
  4. data/deimos-ruby.gemspec +1 -0
  5. data/lib/deimos/config/configuration.rb +4 -0
  6. data/lib/deimos/schema_backends/avro_base.rb +1 -1
  7. data/lib/deimos/version.rb +1 -1
  8. data/lib/generators/deimos/schema_class/templates/schema_class.rb.tt +0 -7
  9. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +10 -1
  10. data/lib/generators/deimos/schema_class_generator.rb +19 -7
  11. data/spec/generators/active_record_generator_spec.rb +4 -2
  12. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +37 -24
  13. data/spec/generators/schema_class_generator_spec.rb +93 -55
  14. data/spec/producer_spec.rb +1 -1
  15. data/spec/schemas/generated.rb +159 -0
  16. data/spec/schemas/my_nested_schema.rb +117 -0
  17. data/spec/{schema_classes → schemas}/my_schema.rb +1 -0
  18. data/spec/{schema_classes → schemas}/my_schema_key.rb +1 -0
  19. data/spec/schemas/my_schema_with_circular_reference.rb +77 -0
  20. data/spec/schemas/my_schema_with_complex_type.rb +239 -0
  21. data/spec/{schema_classes/generated.rb → snapshots/consumers-no-nest.snap} +20 -1
  22. data/spec/snapshots/consumers.snap +161 -0
  23. data/spec/snapshots/consumers_and_producers-no-nest.snap +397 -0
  24. data/spec/snapshots/consumers_and_producers.snap +377 -0
  25. data/spec/{schema_classes/my_schema_with_circular_reference.rb → snapshots/consumers_circular-no-nest.snap} +37 -26
  26. data/spec/snapshots/consumers_circular.snap +79 -0
  27. data/spec/{schema_classes/my_schema_with_complex_types.rb → snapshots/consumers_complex_types-no-nest.snap} +57 -22
  28. data/spec/snapshots/consumers_complex_types.snap +241 -0
  29. data/spec/{schema_classes/my_nested_schema.rb → snapshots/consumers_nested-no-nest.snap} +12 -1
  30. data/spec/snapshots/consumers_nested.snap +119 -0
  31. data/spec/snapshots/producers_with_key-no-nest.snap +95 -0
  32. data/spec/snapshots/producers_with_key.snap +95 -0
  33. data/spec/spec_helper.rb +4 -1
  34. metadata +52 -14
@@ -0,0 +1,161 @@
1
+ spec/app/lib/schema_classes/generated.rb:
2
+ # frozen_string_literal: true
3
+
4
+ # This file is autogenerated by Deimos, Do NOT modify
5
+ module Schemas
6
+ ### Primary Schema Class ###
7
+ # Autogenerated Schema for Record at com.my-namespace.Generated
8
+ class Generated < Deimos::SchemaClass::Record
9
+
10
+ ### Secondary Schema Classes ###
11
+ # Autogenerated Schema for Record at com.my-namespace.ARecord
12
+ class ARecord < Deimos::SchemaClass::Record
13
+
14
+ ### Attribute Accessors ###
15
+ # @param value [String]
16
+ attr_accessor :a_record_field
17
+
18
+ # @override
19
+ def initialize(a_record_field: nil)
20
+ super
21
+ self.a_record_field = a_record_field
22
+ end
23
+
24
+ # @override
25
+ def schema
26
+ 'ARecord'
27
+ end
28
+
29
+ # @override
30
+ def namespace
31
+ 'com.my-namespace'
32
+ end
33
+
34
+ # @override
35
+ def to_h
36
+ {
37
+ 'a_record_field' => @a_record_field
38
+ }
39
+ end
40
+ end
41
+
42
+ # Autogenerated Schema for Enum at com.my-namespace.AnEnum
43
+ class AnEnum < Deimos::SchemaClass::Enum
44
+ # @return ['sym1', 'sym2']
45
+ attr_accessor :an_enum
46
+
47
+ # :nodoc:
48
+ def initialize(an_enum)
49
+ super
50
+ self.an_enum = an_enum
51
+ end
52
+
53
+ # @override
54
+ def symbols
55
+ %w(sym1 sym2)
56
+ end
57
+
58
+ # @override
59
+ def to_h
60
+ @an_enum
61
+ end
62
+ end
63
+
64
+
65
+ ### Attribute Readers ###
66
+ # @return [AnEnum]
67
+ attr_reader :an_enum
68
+ # @return [ARecord]
69
+ attr_reader :a_record
70
+
71
+ ### Attribute Accessors ###
72
+ # @param value [String]
73
+ attr_accessor :a_string
74
+ # @param value [Integer]
75
+ attr_accessor :a_int
76
+ # @param value [Integer]
77
+ attr_accessor :a_long
78
+ # @param value [Float]
79
+ attr_accessor :a_float
80
+ # @param value [Float]
81
+ attr_accessor :a_double
82
+ # @param value [nil, Integer]
83
+ attr_accessor :an_optional_int
84
+ # @param values [Array<Integer>]
85
+ attr_accessor :an_array
86
+ # @param values [Hash<String, String>]
87
+ attr_accessor :a_map
88
+ # @param value [String]
89
+ attr_accessor :timestamp
90
+ # @param value [String]
91
+ attr_accessor :message_id
92
+
93
+ ### Attribute Writers ###
94
+ # @param value [AnEnum]
95
+ def an_enum=(value)
96
+ @an_enum = AnEnum.initialize_from_value(value)
97
+ end
98
+
99
+ # @param value [ARecord]
100
+ def a_record=(value)
101
+ @a_record = ARecord.initialize_from_value(value)
102
+ end
103
+
104
+ # @override
105
+ def initialize(a_string: nil,
106
+ a_int: nil,
107
+ a_long: nil,
108
+ a_float: nil,
109
+ a_double: nil,
110
+ an_optional_int: nil,
111
+ an_enum: nil,
112
+ an_array: nil,
113
+ a_map: nil,
114
+ timestamp: nil,
115
+ message_id: nil,
116
+ a_record: nil)
117
+ super
118
+ self.a_string = a_string
119
+ self.a_int = a_int
120
+ self.a_long = a_long
121
+ self.a_float = a_float
122
+ self.a_double = a_double
123
+ self.an_optional_int = an_optional_int
124
+ self.an_enum = an_enum
125
+ self.an_array = an_array
126
+ self.a_map = a_map
127
+ self.timestamp = timestamp
128
+ self.message_id = message_id
129
+ self.a_record = a_record
130
+ end
131
+
132
+ # @override
133
+ def schema
134
+ 'Generated'
135
+ end
136
+
137
+ # @override
138
+ def namespace
139
+ 'com.my-namespace'
140
+ end
141
+
142
+ # @override
143
+ def to_h
144
+ {
145
+ 'a_string' => @a_string,
146
+ 'a_int' => @a_int,
147
+ 'a_long' => @a_long,
148
+ 'a_float' => @a_float,
149
+ 'a_double' => @a_double,
150
+ 'an_optional_int' => @an_optional_int,
151
+ 'an_enum' => @an_enum&.to_h,
152
+ 'an_array' => @an_array,
153
+ 'a_map' => @a_map,
154
+ 'timestamp' => @timestamp,
155
+ 'message_id' => @message_id,
156
+ 'a_record' => @a_record&.to_h
157
+ }
158
+ end
159
+ end
160
+ end
161
+
@@ -0,0 +1,397 @@
1
+ spec/app/lib/schema_classes/a_record.rb:
2
+ # frozen_string_literal: true
3
+
4
+ # This file is autogenerated by Deimos, Do NOT modify
5
+ module Schemas
6
+ ### Primary Schema Class ###
7
+ # Autogenerated Schema for Record at com.my-namespace.ARecord
8
+ class ARecord < Deimos::SchemaClass::Record
9
+
10
+ ### Attribute Accessors ###
11
+ # @param value [String]
12
+ attr_accessor :a_record_field
13
+
14
+ # @override
15
+ def initialize(a_record_field: nil)
16
+ super
17
+ self.a_record_field = a_record_field
18
+ end
19
+
20
+ # @override
21
+ def schema
22
+ 'ARecord'
23
+ end
24
+
25
+ # @override
26
+ def namespace
27
+ 'com.my-namespace'
28
+ end
29
+
30
+ # @override
31
+ def to_h
32
+ {
33
+ 'a_record_field' => @a_record_field
34
+ }
35
+ end
36
+ end
37
+ end
38
+
39
+
40
+ spec/app/lib/schema_classes/an_enum.rb:
41
+ # frozen_string_literal: true
42
+
43
+ # This file is autogenerated by Deimos, Do NOT modify
44
+ module Schemas
45
+ ### Primary Schema Class ###
46
+ # Autogenerated Schema for Enum at com.my-namespace.AnEnum
47
+ class AnEnum < Deimos::SchemaClass::Enum
48
+ # @return ['sym1', 'sym2']
49
+ attr_accessor :an_enum
50
+
51
+ # :nodoc:
52
+ def initialize(an_enum)
53
+ super
54
+ self.an_enum = an_enum
55
+ end
56
+
57
+ # @override
58
+ def symbols
59
+ %w(sym1 sym2)
60
+ end
61
+
62
+ # @override
63
+ def to_h
64
+ @an_enum
65
+ end
66
+ end
67
+ end
68
+
69
+
70
+ spec/app/lib/schema_classes/generated.rb:
71
+ # frozen_string_literal: true
72
+
73
+ # This file is autogenerated by Deimos, Do NOT modify
74
+ module Schemas
75
+ ### Primary Schema Class ###
76
+ # Autogenerated Schema for Record at com.my-namespace.Generated
77
+ class Generated < Deimos::SchemaClass::Record
78
+
79
+ ### Attribute Readers ###
80
+ # @return [AnEnum]
81
+ attr_reader :an_enum
82
+ # @return [ARecord]
83
+ attr_reader :a_record
84
+
85
+ ### Attribute Accessors ###
86
+ # @param value [String]
87
+ attr_accessor :a_string
88
+ # @param value [Integer]
89
+ attr_accessor :a_int
90
+ # @param value [Integer]
91
+ attr_accessor :a_long
92
+ # @param value [Float]
93
+ attr_accessor :a_float
94
+ # @param value [Float]
95
+ attr_accessor :a_double
96
+ # @param value [nil, Integer]
97
+ attr_accessor :an_optional_int
98
+ # @param values [Array<Integer>]
99
+ attr_accessor :an_array
100
+ # @param values [Hash<String, String>]
101
+ attr_accessor :a_map
102
+ # @param value [String]
103
+ attr_accessor :timestamp
104
+ # @param value [String]
105
+ attr_accessor :message_id
106
+
107
+ ### Attribute Writers ###
108
+ # @param value [AnEnum]
109
+ def an_enum=(value)
110
+ @an_enum = AnEnum.initialize_from_value(value)
111
+ end
112
+
113
+ # @param value [ARecord]
114
+ def a_record=(value)
115
+ @a_record = ARecord.initialize_from_value(value)
116
+ end
117
+
118
+ # @override
119
+ def initialize(a_string: nil,
120
+ a_int: nil,
121
+ a_long: nil,
122
+ a_float: nil,
123
+ a_double: nil,
124
+ an_optional_int: nil,
125
+ an_enum: nil,
126
+ an_array: nil,
127
+ a_map: nil,
128
+ timestamp: nil,
129
+ message_id: nil,
130
+ a_record: nil)
131
+ super
132
+ self.a_string = a_string
133
+ self.a_int = a_int
134
+ self.a_long = a_long
135
+ self.a_float = a_float
136
+ self.a_double = a_double
137
+ self.an_optional_int = an_optional_int
138
+ self.an_enum = an_enum
139
+ self.an_array = an_array
140
+ self.a_map = a_map
141
+ self.timestamp = timestamp
142
+ self.message_id = message_id
143
+ self.a_record = a_record
144
+ end
145
+
146
+ # @override
147
+ def schema
148
+ 'Generated'
149
+ end
150
+
151
+ # @override
152
+ def namespace
153
+ 'com.my-namespace'
154
+ end
155
+
156
+ # @override
157
+ def to_h
158
+ {
159
+ 'a_string' => @a_string,
160
+ 'a_int' => @a_int,
161
+ 'a_long' => @a_long,
162
+ 'a_float' => @a_float,
163
+ 'a_double' => @a_double,
164
+ 'an_optional_int' => @an_optional_int,
165
+ 'an_enum' => @an_enum&.to_h,
166
+ 'an_array' => @an_array,
167
+ 'a_map' => @a_map,
168
+ 'timestamp' => @timestamp,
169
+ 'message_id' => @message_id,
170
+ 'a_record' => @a_record&.to_h
171
+ }
172
+ end
173
+ end
174
+ end
175
+
176
+
177
+ spec/app/lib/schema_classes/my_nested_record.rb:
178
+ # frozen_string_literal: true
179
+
180
+ # This file is autogenerated by Deimos, Do NOT modify
181
+ module Schemas
182
+ ### Primary Schema Class ###
183
+ # Autogenerated Schema for Record at com.my-namespace.MyNestedRecord
184
+ class MyNestedRecord < Deimos::SchemaClass::Record
185
+
186
+ ### Attribute Accessors ###
187
+ # @param value [Integer]
188
+ attr_accessor :some_int
189
+ # @param value [Float]
190
+ attr_accessor :some_float
191
+ # @param value [String]
192
+ attr_accessor :some_string
193
+ # @param value [nil, Integer]
194
+ attr_accessor :some_optional_int
195
+
196
+ # @override
197
+ def initialize(some_int: nil,
198
+ some_float: nil,
199
+ some_string: nil,
200
+ some_optional_int: nil)
201
+ super
202
+ self.some_int = some_int
203
+ self.some_float = some_float
204
+ self.some_string = some_string
205
+ self.some_optional_int = some_optional_int
206
+ end
207
+
208
+ # @override
209
+ def schema
210
+ 'MyNestedRecord'
211
+ end
212
+
213
+ # @override
214
+ def namespace
215
+ 'com.my-namespace'
216
+ end
217
+
218
+ # @override
219
+ def to_h
220
+ {
221
+ 'some_int' => @some_int,
222
+ 'some_float' => @some_float,
223
+ 'some_string' => @some_string,
224
+ 'some_optional_int' => @some_optional_int
225
+ }
226
+ end
227
+ end
228
+ end
229
+
230
+
231
+ spec/app/lib/schema_classes/my_nested_schema.rb:
232
+ # frozen_string_literal: true
233
+
234
+ # This file is autogenerated by Deimos, Do NOT modify
235
+ module Schemas
236
+ ### Primary Schema Class ###
237
+ # Autogenerated Schema for Record at com.my-namespace.MyNestedSchema
238
+ class MyNestedSchema < Deimos::SchemaClass::Record
239
+
240
+ ### Attribute Readers ###
241
+ # @return [MyNestedRecord]
242
+ attr_reader :some_nested_record
243
+ # @return [nil, MyNestedRecord]
244
+ attr_reader :some_optional_record
245
+
246
+ ### Attribute Accessors ###
247
+ # @param value [String]
248
+ attr_accessor :test_id
249
+ # @param value [Float]
250
+ attr_accessor :test_float
251
+ # @param values [Array<String>]
252
+ attr_accessor :test_array
253
+
254
+ ### Attribute Writers ###
255
+ # @param value [MyNestedRecord]
256
+ def some_nested_record=(value)
257
+ @some_nested_record = MyNestedRecord.initialize_from_value(value)
258
+ end
259
+
260
+ # @param value [nil, MyNestedRecord]
261
+ def some_optional_record=(value)
262
+ @some_optional_record = MyNestedRecord.initialize_from_value(value)
263
+ end
264
+
265
+ # @override
266
+ def initialize(test_id: nil,
267
+ test_float: nil,
268
+ test_array: nil,
269
+ some_nested_record: nil,
270
+ some_optional_record: nil)
271
+ super
272
+ self.test_id = test_id
273
+ self.test_float = test_float
274
+ self.test_array = test_array
275
+ self.some_nested_record = some_nested_record
276
+ self.some_optional_record = some_optional_record
277
+ end
278
+
279
+ # @override
280
+ def schema
281
+ 'MyNestedSchema'
282
+ end
283
+
284
+ # @override
285
+ def namespace
286
+ 'com.my-namespace'
287
+ end
288
+
289
+ # @override
290
+ def to_h
291
+ {
292
+ 'test_id' => @test_id,
293
+ 'test_float' => @test_float,
294
+ 'test_array' => @test_array,
295
+ 'some_nested_record' => @some_nested_record&.to_h,
296
+ 'some_optional_record' => @some_optional_record&.to_h
297
+ }
298
+ end
299
+ end
300
+ end
301
+
302
+
303
+ spec/app/lib/schema_classes/my_schema.rb:
304
+ # frozen_string_literal: true
305
+
306
+ # This file is autogenerated by Deimos, Do NOT modify
307
+ module Schemas
308
+ ### Primary Schema Class ###
309
+ # Autogenerated Schema for Record at com.my-namespace.MySchema
310
+ class MySchema < Deimos::SchemaClass::Record
311
+
312
+ ### Attribute Readers ###
313
+ # @return [MySchemaKey]
314
+ attr_reader :payload_key
315
+
316
+ ### Attribute Accessors ###
317
+ # @param value [String]
318
+ attr_accessor :test_id
319
+ # @param value [Integer]
320
+ attr_accessor :some_int
321
+
322
+ ### Attribute Writers ###
323
+ # @param value [MySchemaKey]
324
+ def payload_key=(value)
325
+ @payload_key = MySchemaKey.initialize_from_value(value)
326
+ end
327
+
328
+ # @override
329
+ def initialize(test_id: nil,
330
+ some_int: nil,
331
+ payload_key: nil)
332
+ super
333
+ self.test_id = test_id
334
+ self.some_int = some_int
335
+ self.payload_key = payload_key
336
+ end
337
+
338
+ # @override
339
+ def schema
340
+ 'MySchema'
341
+ end
342
+
343
+ # @override
344
+ def namespace
345
+ 'com.my-namespace'
346
+ end
347
+
348
+ # @override
349
+ def to_h
350
+ {
351
+ 'test_id' => @test_id,
352
+ 'some_int' => @some_int,
353
+ 'payload_key' => @payload_key&.to_h
354
+ }
355
+ end
356
+ end
357
+ end
358
+
359
+
360
+ spec/app/lib/schema_classes/my_schema_key.rb:
361
+ # frozen_string_literal: true
362
+
363
+ # This file is autogenerated by Deimos, Do NOT modify
364
+ module Schemas
365
+ ### Primary Schema Class ###
366
+ # Autogenerated Schema for Record at com.my-namespace.MySchema_key
367
+ class MySchemaKey < Deimos::SchemaClass::Record
368
+
369
+ ### Attribute Accessors ###
370
+ # @param value [String]
371
+ attr_accessor :test_id
372
+
373
+ # @override
374
+ def initialize(test_id: nil)
375
+ super
376
+ self.test_id = test_id
377
+ end
378
+
379
+ # @override
380
+ def schema
381
+ 'MySchema_key'
382
+ end
383
+
384
+ # @override
385
+ def namespace
386
+ 'com.my-namespace'
387
+ end
388
+
389
+ # @override
390
+ def to_h
391
+ {
392
+ 'test_id' => @test_id
393
+ }
394
+ end
395
+ end
396
+ end
397
+