deimos-ruby 1.16.0 → 1.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +17 -0
  4. data/lib/deimos/active_record_producer.rb +7 -0
  5. data/lib/deimos/schema_class/base.rb +1 -1
  6. data/lib/deimos/schema_class/enum.rb +5 -0
  7. data/lib/deimos/schema_class/record.rb +7 -1
  8. data/lib/deimos/version.rb +1 -1
  9. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +13 -5
  10. data/lib/generators/deimos/schema_class_generator.rb +40 -22
  11. data/regenerate_test_schema_classes.rb +68 -0
  12. data/spec/active_record_producer_spec.rb +24 -0
  13. data/spec/generators/schema_class/my_schema_spec.rb +16 -0
  14. data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +1 -1
  15. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +32 -24
  16. data/spec/producer_spec.rb +11 -11
  17. data/spec/schemas/{generated.rb → my_namespace/generated.rb} +28 -32
  18. data/spec/schemas/{my_nested_schema.rb → my_namespace/my_nested_schema.rb} +23 -16
  19. data/spec/schemas/{my_schema.rb → my_namespace/my_schema.rb} +12 -5
  20. data/spec/schemas/my_namespace/my_schema_compound_key.rb +41 -0
  21. data/spec/schemas/my_namespace/my_schema_id_key.rb +36 -0
  22. data/spec/schemas/{my_schema_key.rb → my_namespace/my_schema_key.rb} +3 -3
  23. data/spec/schemas/my_namespace/my_schema_with_boolean.rb +41 -0
  24. data/spec/schemas/{my_schema_with_circular_reference.rb → my_namespace/my_schema_with_circular_reference.rb} +15 -10
  25. data/spec/schemas/{my_schema_with_complex_type.rb → my_namespace/my_schema_with_complex_type.rb} +34 -49
  26. data/spec/schemas/my_namespace/my_schema_with_date_time.rb +56 -0
  27. data/spec/schemas/my_namespace/my_schema_with_id.rb +51 -0
  28. data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +56 -0
  29. data/spec/schemas/my_namespace/wibble.rb +76 -0
  30. data/spec/schemas/my_namespace/widget.rb +56 -0
  31. data/spec/schemas/my_namespace/widget_the_second.rb +56 -0
  32. data/spec/schemas/request/create_topic.rb +36 -0
  33. data/spec/schemas/request/index.rb +36 -0
  34. data/spec/schemas/request/update_request.rb +36 -0
  35. data/spec/schemas/response/create_topic.rb +36 -0
  36. data/spec/schemas/response/index.rb +36 -0
  37. data/spec/schemas/response/update_response.rb +36 -0
  38. data/spec/snapshots/consumers-no-nest.snap +93 -86
  39. data/spec/snapshots/consumers.snap +94 -87
  40. data/spec/snapshots/consumers_and_producers-no-nest.snap +108 -87
  41. data/spec/snapshots/consumers_and_producers.snap +109 -88
  42. data/spec/snapshots/consumers_circular-no-nest.snap +93 -86
  43. data/spec/snapshots/consumers_circular.snap +94 -87
  44. data/spec/snapshots/consumers_complex_types-no-nest.snap +93 -86
  45. data/spec/snapshots/consumers_complex_types.snap +94 -87
  46. data/spec/snapshots/consumers_nested-no-nest.snap +93 -86
  47. data/spec/snapshots/consumers_nested.snap +94 -87
  48. data/spec/snapshots/namespace_folders.snap +111 -90
  49. data/spec/snapshots/producers_with_key-no-nest.snap +94 -87
  50. data/spec/snapshots/producers_with_key.snap +95 -88
  51. data/spec/spec_helper.rb +2 -1
  52. metadata +48 -15
@@ -12,7 +12,7 @@ module Schemas; module MyNamespace
12
12
  class ARecord < Deimos::SchemaClass::Record
13
13
 
14
14
  ### Attribute Accessors ###
15
- # @param value [String]
15
+ # @return [String]
16
16
  attr_accessor :a_record_field
17
17
 
18
18
  # @override
@@ -58,34 +58,34 @@ module Schemas; module MyNamespace
58
58
  attr_reader :a_record
59
59
 
60
60
  ### Attribute Accessors ###
61
- # @param value [String]
61
+ # @return [String]
62
62
  attr_accessor :a_string
63
- # @param value [Integer]
63
+ # @return [Integer]
64
64
  attr_accessor :a_int
65
- # @param value [Integer]
65
+ # @return [Integer]
66
66
  attr_accessor :a_long
67
- # @param value [Float]
67
+ # @return [Float]
68
68
  attr_accessor :a_float
69
- # @param value [Float]
69
+ # @return [Float]
70
70
  attr_accessor :a_double
71
- # @param value [nil, Integer]
71
+ # @return [nil, Integer]
72
72
  attr_accessor :an_optional_int
73
- # @param values [Array<Integer>]
73
+ # @return [Array<Integer>]
74
74
  attr_accessor :an_array
75
- # @param values [Hash<String, String>]
75
+ # @return [Hash<String, String>]
76
76
  attr_accessor :a_map
77
- # @param value [String]
77
+ # @return [String]
78
78
  attr_accessor :timestamp
79
- # @param value [String]
79
+ # @return [String]
80
80
  attr_accessor :message_id
81
81
 
82
82
  ### Attribute Writers ###
83
- # @param value [AnEnum]
83
+ # @return [AnEnum]
84
84
  def an_enum=(value)
85
85
  @an_enum = AnEnum.initialize_from_value(value)
86
86
  end
87
87
 
88
- # @param value [ARecord]
88
+ # @return [ARecord]
89
89
  def a_record=(value)
90
90
  @a_record = ARecord.initialize_from_value(value)
91
91
  end
@@ -128,6 +128,13 @@ module Schemas; module MyNamespace
128
128
  'com.my-namespace'
129
129
  end
130
130
 
131
+ def self.tombstone(key)
132
+ record = self.new
133
+ record.tombstone_key = key
134
+ record.a_string = key
135
+ record
136
+ end
137
+
131
138
  # @override
132
139
  def as_json(_opts={})
133
140
  {
@@ -163,13 +170,13 @@ module Schemas; module MyNamespace
163
170
  class MyNestedRecord < Deimos::SchemaClass::Record
164
171
 
165
172
  ### Attribute Accessors ###
166
- # @param value [Integer]
173
+ # @return [Integer]
167
174
  attr_accessor :some_int
168
- # @param value [Float]
175
+ # @return [Float]
169
176
  attr_accessor :some_float
170
- # @param value [String]
177
+ # @return [String]
171
178
  attr_accessor :some_string
172
- # @param value [nil, Integer]
179
+ # @return [nil, Integer]
173
180
  attr_accessor :some_optional_int
174
181
 
175
182
  # @override
@@ -213,20 +220,20 @@ module Schemas; module MyNamespace
213
220
  attr_reader :some_optional_record
214
221
 
215
222
  ### Attribute Accessors ###
216
- # @param value [String]
223
+ # @return [String]
217
224
  attr_accessor :test_id
218
- # @param value [Float]
225
+ # @return [Float]
219
226
  attr_accessor :test_float
220
- # @param values [Array<String>]
227
+ # @return [Array<String>]
221
228
  attr_accessor :test_array
222
229
 
223
230
  ### Attribute Writers ###
224
- # @param value [MyNestedRecord]
231
+ # @return [MyNestedRecord]
225
232
  def some_nested_record=(value)
226
233
  @some_nested_record = MyNestedRecord.initialize_from_value(value)
227
234
  end
228
235
 
229
- # @param value [nil, MyNestedRecord]
236
+ # @return [nil, MyNestedRecord]
230
237
  def some_optional_record=(value)
231
238
  @some_optional_record = MyNestedRecord.initialize_from_value(value)
232
239
  end
@@ -255,6 +262,13 @@ module Schemas; module MyNamespace
255
262
  'com.my-namespace'
256
263
  end
257
264
 
265
+ def self.tombstone(key)
266
+ record = self.new
267
+ record.tombstone_key = key
268
+ record.test_id = key
269
+ record
270
+ end
271
+
258
272
  # @override
259
273
  def as_json(_opts={})
260
274
  {
@@ -283,13 +297,13 @@ module Schemas; module MyNamespace
283
297
  attr_reader :payload_key
284
298
 
285
299
  ### Attribute Accessors ###
286
- # @param value [String]
300
+ # @return [String]
287
301
  attr_accessor :test_id
288
- # @param value [Integer]
302
+ # @return [Integer]
289
303
  attr_accessor :some_int
290
304
 
291
305
  ### Attribute Writers ###
292
- # @param value [MySchemaKey]
306
+ # @return [MySchemaKey]
293
307
  def payload_key=(value)
294
308
  @payload_key = MySchemaKey.initialize_from_value(value)
295
309
  end
@@ -314,6 +328,13 @@ module Schemas; module MyNamespace
314
328
  'com.my-namespace'
315
329
  end
316
330
 
331
+ def self.tombstone(key)
332
+ record = self.new
333
+ record.tombstone_key = MySchemaKey.initialize_from_value(key)
334
+ record.payload_key = key
335
+ record
336
+ end
337
+
317
338
  # @override
318
339
  def as_json(_opts={})
319
340
  {
@@ -336,9 +357,9 @@ module Schemas; module MyNamespace
336
357
  class MySchemaCompoundKey < Deimos::SchemaClass::Record
337
358
 
338
359
  ### Attribute Accessors ###
339
- # @param value [String]
360
+ # @return [String]
340
361
  attr_accessor :part_one
341
- # @param value [String]
362
+ # @return [String]
342
363
  attr_accessor :part_two
343
364
 
344
365
  # @override
@@ -380,7 +401,7 @@ module Schemas; module MyNamespace
380
401
  class MySchemaIdKey < Deimos::SchemaClass::Record
381
402
 
382
403
  ### Attribute Accessors ###
383
- # @param value [Integer]
404
+ # @return [Integer]
384
405
  attr_accessor :id
385
406
 
386
407
  # @override
@@ -419,7 +440,7 @@ module Schemas; module MyNamespace
419
440
  class MySchemaKey < Deimos::SchemaClass::Record
420
441
 
421
442
  ### Attribute Accessors ###
422
- # @param value [String]
443
+ # @return [String]
423
444
  attr_accessor :test_id
424
445
 
425
446
  # @override
@@ -458,9 +479,9 @@ module Schemas; module MyNamespace
458
479
  class MySchemaWithBoolean < Deimos::SchemaClass::Record
459
480
 
460
481
  ### Attribute Accessors ###
461
- # @param value [String]
482
+ # @return [String]
462
483
  attr_accessor :test_id
463
- # @param value [Boolean]
484
+ # @return [Boolean]
464
485
  attr_accessor :some_bool
465
486
 
466
487
  # @override
@@ -506,7 +527,7 @@ module Schemas; module MyNamespace
506
527
  class Property < Deimos::SchemaClass::Record
507
528
 
508
529
  ### Attribute Accessors ###
509
- # @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
530
+ # @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
510
531
  attr_accessor :property
511
532
 
512
533
  # @override
@@ -539,9 +560,9 @@ module Schemas; module MyNamespace
539
560
  attr_reader :properties
540
561
 
541
562
  ### Attribute Writers ###
542
- # @param values [Hash<String, Property>]
563
+ # @return [Hash<String, Property>]
543
564
  def properties=(values)
544
- @properties = values.transform_values do |value|
565
+ @properties = values&.transform_values do |value|
545
566
  Property.initialize_from_value(value)
546
567
  end
547
568
  end
@@ -586,7 +607,7 @@ module Schemas; module MyNamespace
586
607
  class ARecord < Deimos::SchemaClass::Record
587
608
 
588
609
  ### Attribute Accessors ###
589
- # @param value [String]
610
+ # @return [String]
590
611
  attr_accessor :a_record_field
591
612
 
592
613
  # @override
@@ -664,57 +685,57 @@ module Schemas; module MyNamespace
664
685
  attr_reader :some_enum_with_default
665
686
 
666
687
  ### Attribute Accessors ###
667
- # @param value [String]
688
+ # @return [String]
668
689
  attr_accessor :test_id
669
- # @param value [Float]
690
+ # @return [Float]
670
691
  attr_accessor :test_float
671
- # @param values [Array<String>]
692
+ # @return [Array<String>]
672
693
  attr_accessor :test_string_array
673
- # @param values [Array<Integer>]
694
+ # @return [Array<Integer>]
674
695
  attr_accessor :test_int_array
675
- # @param value [Integer, nil]
696
+ # @return [Integer, nil]
676
697
  attr_accessor :test_optional_int
677
- # @param values [Hash<String, Integer>]
698
+ # @return [Hash<String, Integer>]
678
699
  attr_accessor :some_integer_map
679
700
 
680
701
  ### Attribute Writers ###
681
- # @param value [ARecord]
702
+ # @return [ARecord]
682
703
  def some_record=(value)
683
704
  @some_record = ARecord.initialize_from_value(value)
684
705
  end
685
706
 
686
- # @param value [nil, ARecord]
707
+ # @return [nil, ARecord]
687
708
  def some_optional_record=(value)
688
709
  @some_optional_record = ARecord.initialize_from_value(value)
689
710
  end
690
711
 
691
- # @param values [Array<ARecord>]
712
+ # @return [Array<ARecord>]
692
713
  def some_record_array=(values)
693
- @some_record_array = values.map do |value|
714
+ @some_record_array = values&.map do |value|
694
715
  ARecord.initialize_from_value(value)
695
716
  end
696
717
  end
697
718
 
698
- # @param values [Hash<String, ARecord>]
719
+ # @return [Hash<String, ARecord>]
699
720
  def some_record_map=(values)
700
- @some_record_map = values.transform_values do |value|
721
+ @some_record_map = values&.transform_values do |value|
701
722
  ARecord.initialize_from_value(value)
702
723
  end
703
724
  end
704
725
 
705
- # @param values [Array<AnEnum>]
726
+ # @return [Array<AnEnum>]
706
727
  def some_enum_array=(values)
707
- @some_enum_array = values.map do |value|
728
+ @some_enum_array = values&.map do |value|
708
729
  AnEnum.initialize_from_value(value)
709
730
  end
710
731
  end
711
732
 
712
- # @param value [nil, AnotherEnum]
733
+ # @return [nil, AnotherEnum]
713
734
  def some_optional_enum=(value)
714
735
  @some_optional_enum = AnotherEnum.initialize_from_value(value)
715
736
  end
716
737
 
717
- # @param value [YetAnotherEnum]
738
+ # @return [YetAnotherEnum]
718
739
  def some_enum_with_default=(value)
719
740
  @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
720
741
  end
@@ -791,15 +812,15 @@ module Schemas; module MyNamespace
791
812
  class MySchemaWithDateTime < Deimos::SchemaClass::Record
792
813
 
793
814
  ### Attribute Accessors ###
794
- # @param value [String]
815
+ # @return [String]
795
816
  attr_accessor :test_id
796
- # @param value [Integer, nil]
817
+ # @return [Integer, nil]
797
818
  attr_accessor :updated_at
798
- # @param value [nil, Integer]
819
+ # @return [nil, Integer]
799
820
  attr_accessor :some_int
800
- # @param value [nil, Integer]
821
+ # @return [nil, Integer]
801
822
  attr_accessor :some_datetime_int
802
- # @param value [String]
823
+ # @return [String]
803
824
  attr_accessor :timestamp
804
825
 
805
826
  # @override
@@ -850,13 +871,13 @@ module Schemas; module MyNamespace
850
871
  class MySchemaWithId < Deimos::SchemaClass::Record
851
872
 
852
873
  ### Attribute Accessors ###
853
- # @param value [String]
874
+ # @return [String]
854
875
  attr_accessor :test_id
855
- # @param value [Integer]
876
+ # @return [Integer]
856
877
  attr_accessor :some_int
857
- # @param value [String]
878
+ # @return [String]
858
879
  attr_accessor :message_id
859
- # @param value [String]
880
+ # @return [String]
860
881
  attr_accessor :timestamp
861
882
 
862
883
  # @override
@@ -904,15 +925,15 @@ module Schemas; module MyNamespace
904
925
  class MySchemaWithUniqueId < Deimos::SchemaClass::Record
905
926
 
906
927
  ### Attribute Accessors ###
907
- # @param value [Integer]
928
+ # @return [Integer]
908
929
  attr_accessor :id
909
- # @param value [String]
930
+ # @return [String]
910
931
  attr_accessor :test_id
911
- # @param value [Integer]
932
+ # @return [Integer]
912
933
  attr_accessor :some_int
913
- # @param value [String]
934
+ # @return [String]
914
935
  attr_accessor :message_id
915
- # @param value [String]
936
+ # @return [String]
916
937
  attr_accessor :timestamp
917
938
 
918
939
  # @override
@@ -963,23 +984,23 @@ module Schemas; module MyNamespace
963
984
  class Wibble < Deimos::SchemaClass::Record
964
985
 
965
986
  ### Attribute Accessors ###
966
- # @param value [Integer]
987
+ # @return [Integer]
967
988
  attr_accessor :id
968
- # @param value [Integer]
989
+ # @return [Integer]
969
990
  attr_accessor :wibble_id
970
- # @param value [String]
991
+ # @return [String]
971
992
  attr_accessor :name
972
- # @param value [String]
993
+ # @return [String]
973
994
  attr_accessor :floop
974
- # @param value [Integer]
995
+ # @return [Integer]
975
996
  attr_accessor :birthday_int
976
- # @param value [Integer]
997
+ # @return [Integer]
977
998
  attr_accessor :birthday_long
978
- # @param value [nil, Integer]
999
+ # @return [nil, Integer]
979
1000
  attr_accessor :birthday_optional
980
- # @param value [Integer]
1001
+ # @return [Integer]
981
1002
  attr_accessor :updated_at
982
- # @param value [Integer]
1003
+ # @return [Integer]
983
1004
  attr_accessor :created_at
984
1005
 
985
1006
  # @override
@@ -1042,15 +1063,15 @@ module Schemas; module MyNamespace
1042
1063
  class Widget < Deimos::SchemaClass::Record
1043
1064
 
1044
1065
  ### Attribute Accessors ###
1045
- # @param value [Integer]
1066
+ # @return [Integer]
1046
1067
  attr_accessor :id
1047
- # @param value [Integer]
1068
+ # @return [Integer]
1048
1069
  attr_accessor :widget_id
1049
- # @param value [String]
1070
+ # @return [String]
1050
1071
  attr_accessor :name
1051
- # @param value [Integer]
1072
+ # @return [Integer]
1052
1073
  attr_accessor :updated_at
1053
- # @param value [Integer]
1074
+ # @return [Integer]
1054
1075
  attr_accessor :created_at
1055
1076
 
1056
1077
  # @override
@@ -1101,15 +1122,15 @@ module Schemas; module MyNamespace
1101
1122
  class WidgetTheSecond < Deimos::SchemaClass::Record
1102
1123
 
1103
1124
  ### Attribute Accessors ###
1104
- # @param value [Integer]
1125
+ # @return [Integer]
1105
1126
  attr_accessor :id
1106
- # @param value [Integer]
1127
+ # @return [Integer]
1107
1128
  attr_accessor :widget_id
1108
- # @param value [String]
1129
+ # @return [String]
1109
1130
  attr_accessor :model_id
1110
- # @param value [Integer]
1131
+ # @return [Integer]
1111
1132
  attr_accessor :updated_at
1112
- # @param value [Integer]
1133
+ # @return [Integer]
1113
1134
  attr_accessor :created_at
1114
1135
 
1115
1136
  # @override
@@ -1160,7 +1181,7 @@ module Schemas; module Request
1160
1181
  class CreateTopic < Deimos::SchemaClass::Record
1161
1182
 
1162
1183
  ### Attribute Accessors ###
1163
- # @param value [String]
1184
+ # @return [String]
1164
1185
  attr_accessor :request_id
1165
1186
 
1166
1187
  # @override
@@ -1199,7 +1220,7 @@ module Schemas; module Request
1199
1220
  class Index < Deimos::SchemaClass::Record
1200
1221
 
1201
1222
  ### Attribute Accessors ###
1202
- # @param value [String]
1223
+ # @return [String]
1203
1224
  attr_accessor :request_id
1204
1225
 
1205
1226
  # @override
@@ -1238,7 +1259,7 @@ module Schemas; module Request
1238
1259
  class UpdateRequest < Deimos::SchemaClass::Record
1239
1260
 
1240
1261
  ### Attribute Accessors ###
1241
- # @param value [String]
1262
+ # @return [String]
1242
1263
  attr_accessor :update_request_id
1243
1264
 
1244
1265
  # @override
@@ -1277,7 +1298,7 @@ module Schemas; module Response
1277
1298
  class CreateTopic < Deimos::SchemaClass::Record
1278
1299
 
1279
1300
  ### Attribute Accessors ###
1280
- # @param value [String]
1301
+ # @return [String]
1281
1302
  attr_accessor :response_id
1282
1303
 
1283
1304
  # @override
@@ -1316,7 +1337,7 @@ module Schemas; module Response
1316
1337
  class Index < Deimos::SchemaClass::Record
1317
1338
 
1318
1339
  ### Attribute Accessors ###
1319
- # @param value [String]
1340
+ # @return [String]
1320
1341
  attr_accessor :response_id
1321
1342
 
1322
1343
  # @override
@@ -1355,7 +1376,7 @@ module Schemas; module Response
1355
1376
  class UpdateResponse < Deimos::SchemaClass::Record
1356
1377
 
1357
1378
  ### Attribute Accessors ###
1358
- # @param value [String]
1379
+ # @return [String]
1359
1380
  attr_accessor :update_response_id
1360
1381
 
1361
1382
  # @override