deimos-ruby 1.16.0 → 1.16.3

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.
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
@@ -8,7 +8,7 @@ module Schemas
8
8
  class ARecord < Deimos::SchemaClass::Record
9
9
 
10
10
  ### Attribute Accessors ###
11
- # @param value [String]
11
+ # @return [String]
12
12
  attr_accessor :a_record_field
13
13
 
14
14
  # @override
@@ -85,7 +85,7 @@ module Schemas
85
85
  class CreateTopic < Deimos::SchemaClass::Record
86
86
 
87
87
  ### Attribute Accessors ###
88
- # @param value [String]
88
+ # @return [String]
89
89
  attr_accessor :response_id
90
90
 
91
91
  # @override
@@ -130,34 +130,34 @@ module Schemas
130
130
  attr_reader :a_record
131
131
 
132
132
  ### Attribute Accessors ###
133
- # @param value [String]
133
+ # @return [String]
134
134
  attr_accessor :a_string
135
- # @param value [Integer]
135
+ # @return [Integer]
136
136
  attr_accessor :a_int
137
- # @param value [Integer]
137
+ # @return [Integer]
138
138
  attr_accessor :a_long
139
- # @param value [Float]
139
+ # @return [Float]
140
140
  attr_accessor :a_float
141
- # @param value [Float]
141
+ # @return [Float]
142
142
  attr_accessor :a_double
143
- # @param value [nil, Integer]
143
+ # @return [nil, Integer]
144
144
  attr_accessor :an_optional_int
145
- # @param values [Array<Integer>]
145
+ # @return [Array<Integer>]
146
146
  attr_accessor :an_array
147
- # @param values [Hash<String, String>]
147
+ # @return [Hash<String, String>]
148
148
  attr_accessor :a_map
149
- # @param value [String]
149
+ # @return [String]
150
150
  attr_accessor :timestamp
151
- # @param value [String]
151
+ # @return [String]
152
152
  attr_accessor :message_id
153
153
 
154
154
  ### Attribute Writers ###
155
- # @param value [AnEnum]
155
+ # @return [AnEnum]
156
156
  def an_enum=(value)
157
157
  @an_enum = AnEnum.initialize_from_value(value)
158
158
  end
159
159
 
160
- # @param value [ARecord]
160
+ # @return [ARecord]
161
161
  def a_record=(value)
162
162
  @a_record = ARecord.initialize_from_value(value)
163
163
  end
@@ -200,6 +200,13 @@ module Schemas
200
200
  'com.my-namespace'
201
201
  end
202
202
 
203
+ def self.tombstone(key)
204
+ record = self.new
205
+ record.tombstone_key = key
206
+ record.a_string = key
207
+ record
208
+ end
209
+
203
210
  # @override
204
211
  def as_json(_opts={})
205
212
  {
@@ -231,7 +238,7 @@ module Schemas
231
238
  class Index < Deimos::SchemaClass::Record
232
239
 
233
240
  ### Attribute Accessors ###
234
- # @param value [String]
241
+ # @return [String]
235
242
  attr_accessor :response_id
236
243
 
237
244
  # @override
@@ -270,13 +277,13 @@ module Schemas
270
277
  class MyNestedRecord < Deimos::SchemaClass::Record
271
278
 
272
279
  ### Attribute Accessors ###
273
- # @param value [Integer]
280
+ # @return [Integer]
274
281
  attr_accessor :some_int
275
- # @param value [Float]
282
+ # @return [Float]
276
283
  attr_accessor :some_float
277
- # @param value [String]
284
+ # @return [String]
278
285
  attr_accessor :some_string
279
- # @param value [nil, Integer]
286
+ # @return [nil, Integer]
280
287
  attr_accessor :some_optional_int
281
288
 
282
289
  # @override
@@ -330,20 +337,20 @@ module Schemas
330
337
  attr_reader :some_optional_record
331
338
 
332
339
  ### Attribute Accessors ###
333
- # @param value [String]
340
+ # @return [String]
334
341
  attr_accessor :test_id
335
- # @param value [Float]
342
+ # @return [Float]
336
343
  attr_accessor :test_float
337
- # @param values [Array<String>]
344
+ # @return [Array<String>]
338
345
  attr_accessor :test_array
339
346
 
340
347
  ### Attribute Writers ###
341
- # @param value [MyNestedRecord]
348
+ # @return [MyNestedRecord]
342
349
  def some_nested_record=(value)
343
350
  @some_nested_record = MyNestedRecord.initialize_from_value(value)
344
351
  end
345
352
 
346
- # @param value [nil, MyNestedRecord]
353
+ # @return [nil, MyNestedRecord]
347
354
  def some_optional_record=(value)
348
355
  @some_optional_record = MyNestedRecord.initialize_from_value(value)
349
356
  end
@@ -372,6 +379,13 @@ module Schemas
372
379
  'com.my-namespace'
373
380
  end
374
381
 
382
+ def self.tombstone(key)
383
+ record = self.new
384
+ record.tombstone_key = key
385
+ record.test_id = key
386
+ record
387
+ end
388
+
375
389
  # @override
376
390
  def as_json(_opts={})
377
391
  {
@@ -400,13 +414,13 @@ module Schemas
400
414
  attr_reader :payload_key
401
415
 
402
416
  ### Attribute Accessors ###
403
- # @param value [String]
417
+ # @return [String]
404
418
  attr_accessor :test_id
405
- # @param value [Integer]
419
+ # @return [Integer]
406
420
  attr_accessor :some_int
407
421
 
408
422
  ### Attribute Writers ###
409
- # @param value [MySchemaKey]
423
+ # @return [MySchemaKey]
410
424
  def payload_key=(value)
411
425
  @payload_key = MySchemaKey.initialize_from_value(value)
412
426
  end
@@ -431,6 +445,13 @@ module Schemas
431
445
  'com.my-namespace'
432
446
  end
433
447
 
448
+ def self.tombstone(key)
449
+ record = self.new
450
+ record.tombstone_key = MySchemaKey.initialize_from_value(key)
451
+ record.payload_key = key
452
+ record
453
+ end
454
+
434
455
  # @override
435
456
  def as_json(_opts={})
436
457
  {
@@ -453,9 +474,9 @@ module Schemas
453
474
  class MySchemaCompoundKey < Deimos::SchemaClass::Record
454
475
 
455
476
  ### Attribute Accessors ###
456
- # @param value [String]
477
+ # @return [String]
457
478
  attr_accessor :part_one
458
- # @param value [String]
479
+ # @return [String]
459
480
  attr_accessor :part_two
460
481
 
461
482
  # @override
@@ -497,7 +518,7 @@ module Schemas
497
518
  class MySchemaIdKey < Deimos::SchemaClass::Record
498
519
 
499
520
  ### Attribute Accessors ###
500
- # @param value [Integer]
521
+ # @return [Integer]
501
522
  attr_accessor :id
502
523
 
503
524
  # @override
@@ -536,7 +557,7 @@ module Schemas
536
557
  class MySchemaKey < Deimos::SchemaClass::Record
537
558
 
538
559
  ### Attribute Accessors ###
539
- # @param value [String]
560
+ # @return [String]
540
561
  attr_accessor :test_id
541
562
 
542
563
  # @override
@@ -575,9 +596,9 @@ module Schemas
575
596
  class MySchemaWithBoolean < Deimos::SchemaClass::Record
576
597
 
577
598
  ### Attribute Accessors ###
578
- # @param value [String]
599
+ # @return [String]
579
600
  attr_accessor :test_id
580
- # @param value [Boolean]
601
+ # @return [Boolean]
581
602
  attr_accessor :some_bool
582
603
 
583
604
  # @override
@@ -623,9 +644,9 @@ module Schemas
623
644
  attr_reader :properties
624
645
 
625
646
  ### Attribute Writers ###
626
- # @param values [Hash<String, Property>]
647
+ # @return [Hash<String, Property>]
627
648
  def properties=(values)
628
- @properties = values.transform_values do |value|
649
+ @properties = values&.transform_values do |value|
629
650
  Property.initialize_from_value(value)
630
651
  end
631
652
  end
@@ -682,57 +703,57 @@ module Schemas
682
703
  attr_reader :some_enum_with_default
683
704
 
684
705
  ### Attribute Accessors ###
685
- # @param value [String]
706
+ # @return [String]
686
707
  attr_accessor :test_id
687
- # @param value [Float]
708
+ # @return [Float]
688
709
  attr_accessor :test_float
689
- # @param values [Array<String>]
710
+ # @return [Array<String>]
690
711
  attr_accessor :test_string_array
691
- # @param values [Array<Integer>]
712
+ # @return [Array<Integer>]
692
713
  attr_accessor :test_int_array
693
- # @param value [Integer, nil]
714
+ # @return [Integer, nil]
694
715
  attr_accessor :test_optional_int
695
- # @param values [Hash<String, Integer>]
716
+ # @return [Hash<String, Integer>]
696
717
  attr_accessor :some_integer_map
697
718
 
698
719
  ### Attribute Writers ###
699
- # @param value [ARecord]
720
+ # @return [ARecord]
700
721
  def some_record=(value)
701
722
  @some_record = ARecord.initialize_from_value(value)
702
723
  end
703
724
 
704
- # @param value [nil, ARecord]
725
+ # @return [nil, ARecord]
705
726
  def some_optional_record=(value)
706
727
  @some_optional_record = ARecord.initialize_from_value(value)
707
728
  end
708
729
 
709
- # @param values [Array<ARecord>]
730
+ # @return [Array<ARecord>]
710
731
  def some_record_array=(values)
711
- @some_record_array = values.map do |value|
732
+ @some_record_array = values&.map do |value|
712
733
  ARecord.initialize_from_value(value)
713
734
  end
714
735
  end
715
736
 
716
- # @param values [Hash<String, ARecord>]
737
+ # @return [Hash<String, ARecord>]
717
738
  def some_record_map=(values)
718
- @some_record_map = values.transform_values do |value|
739
+ @some_record_map = values&.transform_values do |value|
719
740
  ARecord.initialize_from_value(value)
720
741
  end
721
742
  end
722
743
 
723
- # @param values [Array<AnEnum>]
744
+ # @return [Array<AnEnum>]
724
745
  def some_enum_array=(values)
725
- @some_enum_array = values.map do |value|
746
+ @some_enum_array = values&.map do |value|
726
747
  AnEnum.initialize_from_value(value)
727
748
  end
728
749
  end
729
750
 
730
- # @param value [nil, AnotherEnum]
751
+ # @return [nil, AnotherEnum]
731
752
  def some_optional_enum=(value)
732
753
  @some_optional_enum = AnotherEnum.initialize_from_value(value)
733
754
  end
734
755
 
735
- # @param value [YetAnotherEnum]
756
+ # @return [YetAnotherEnum]
736
757
  def some_enum_with_default=(value)
737
758
  @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
738
759
  end
@@ -809,15 +830,15 @@ module Schemas
809
830
  class MySchemaWithDateTime < Deimos::SchemaClass::Record
810
831
 
811
832
  ### Attribute Accessors ###
812
- # @param value [String]
833
+ # @return [String]
813
834
  attr_accessor :test_id
814
- # @param value [Integer, nil]
835
+ # @return [Integer, nil]
815
836
  attr_accessor :updated_at
816
- # @param value [nil, Integer]
837
+ # @return [nil, Integer]
817
838
  attr_accessor :some_int
818
- # @param value [nil, Integer]
839
+ # @return [nil, Integer]
819
840
  attr_accessor :some_datetime_int
820
- # @param value [String]
841
+ # @return [String]
821
842
  attr_accessor :timestamp
822
843
 
823
844
  # @override
@@ -868,13 +889,13 @@ module Schemas
868
889
  class MySchemaWithId < Deimos::SchemaClass::Record
869
890
 
870
891
  ### Attribute Accessors ###
871
- # @param value [String]
892
+ # @return [String]
872
893
  attr_accessor :test_id
873
- # @param value [Integer]
894
+ # @return [Integer]
874
895
  attr_accessor :some_int
875
- # @param value [String]
896
+ # @return [String]
876
897
  attr_accessor :message_id
877
- # @param value [String]
898
+ # @return [String]
878
899
  attr_accessor :timestamp
879
900
 
880
901
  # @override
@@ -922,15 +943,15 @@ module Schemas
922
943
  class MySchemaWithUniqueId < Deimos::SchemaClass::Record
923
944
 
924
945
  ### Attribute Accessors ###
925
- # @param value [Integer]
946
+ # @return [Integer]
926
947
  attr_accessor :id
927
- # @param value [String]
948
+ # @return [String]
928
949
  attr_accessor :test_id
929
- # @param value [Integer]
950
+ # @return [Integer]
930
951
  attr_accessor :some_int
931
- # @param value [String]
952
+ # @return [String]
932
953
  attr_accessor :message_id
933
- # @param value [String]
954
+ # @return [String]
934
955
  attr_accessor :timestamp
935
956
 
936
957
  # @override
@@ -981,7 +1002,7 @@ module Schemas
981
1002
  class Property < Deimos::SchemaClass::Record
982
1003
 
983
1004
  ### Attribute Accessors ###
984
- # @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
1005
+ # @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
985
1006
  attr_accessor :property
986
1007
 
987
1008
  # @override
@@ -1020,7 +1041,7 @@ module Schemas
1020
1041
  class UpdateRequest < Deimos::SchemaClass::Record
1021
1042
 
1022
1043
  ### Attribute Accessors ###
1023
- # @param value [String]
1044
+ # @return [String]
1024
1045
  attr_accessor :update_request_id
1025
1046
 
1026
1047
  # @override
@@ -1059,7 +1080,7 @@ module Schemas
1059
1080
  class UpdateResponse < Deimos::SchemaClass::Record
1060
1081
 
1061
1082
  ### Attribute Accessors ###
1062
- # @param value [String]
1083
+ # @return [String]
1063
1084
  attr_accessor :update_response_id
1064
1085
 
1065
1086
  # @override
@@ -1098,23 +1119,23 @@ module Schemas
1098
1119
  class Wibble < Deimos::SchemaClass::Record
1099
1120
 
1100
1121
  ### Attribute Accessors ###
1101
- # @param value [Integer]
1122
+ # @return [Integer]
1102
1123
  attr_accessor :id
1103
- # @param value [Integer]
1124
+ # @return [Integer]
1104
1125
  attr_accessor :wibble_id
1105
- # @param value [String]
1126
+ # @return [String]
1106
1127
  attr_accessor :name
1107
- # @param value [String]
1128
+ # @return [String]
1108
1129
  attr_accessor :floop
1109
- # @param value [Integer]
1130
+ # @return [Integer]
1110
1131
  attr_accessor :birthday_int
1111
- # @param value [Integer]
1132
+ # @return [Integer]
1112
1133
  attr_accessor :birthday_long
1113
- # @param value [nil, Integer]
1134
+ # @return [nil, Integer]
1114
1135
  attr_accessor :birthday_optional
1115
- # @param value [Integer]
1136
+ # @return [Integer]
1116
1137
  attr_accessor :updated_at
1117
- # @param value [Integer]
1138
+ # @return [Integer]
1118
1139
  attr_accessor :created_at
1119
1140
 
1120
1141
  # @override
@@ -1177,15 +1198,15 @@ module Schemas
1177
1198
  class Widget < Deimos::SchemaClass::Record
1178
1199
 
1179
1200
  ### Attribute Accessors ###
1180
- # @param value [Integer]
1201
+ # @return [Integer]
1181
1202
  attr_accessor :id
1182
- # @param value [Integer]
1203
+ # @return [Integer]
1183
1204
  attr_accessor :widget_id
1184
- # @param value [String]
1205
+ # @return [String]
1185
1206
  attr_accessor :name
1186
- # @param value [Integer]
1207
+ # @return [Integer]
1187
1208
  attr_accessor :updated_at
1188
- # @param value [Integer]
1209
+ # @return [Integer]
1189
1210
  attr_accessor :created_at
1190
1211
 
1191
1212
  # @override
@@ -1236,15 +1257,15 @@ module Schemas
1236
1257
  class WidgetTheSecond < Deimos::SchemaClass::Record
1237
1258
 
1238
1259
  ### Attribute Accessors ###
1239
- # @param value [Integer]
1260
+ # @return [Integer]
1240
1261
  attr_accessor :id
1241
- # @param value [Integer]
1262
+ # @return [Integer]
1242
1263
  attr_accessor :widget_id
1243
- # @param value [String]
1264
+ # @return [String]
1244
1265
  attr_accessor :model_id
1245
- # @param value [Integer]
1266
+ # @return [Integer]
1246
1267
  attr_accessor :updated_at
1247
- # @param value [Integer]
1268
+ # @return [Integer]
1248
1269
  attr_accessor :created_at
1249
1270
 
1250
1271
  # @override