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
@@ -8,7 +8,7 @@ module Schemas
8
8
  class CreateTopic < Deimos::SchemaClass::Record
9
9
 
10
10
  ### Attribute Accessors ###
11
- # @param value [String]
11
+ # @return [String]
12
12
  attr_accessor :response_id
13
13
 
14
14
  # @override
@@ -51,7 +51,7 @@ module Schemas
51
51
  class ARecord < Deimos::SchemaClass::Record
52
52
 
53
53
  ### Attribute Accessors ###
54
- # @param value [String]
54
+ # @return [String]
55
55
  attr_accessor :a_record_field
56
56
 
57
57
  # @override
@@ -97,34 +97,34 @@ module Schemas
97
97
  attr_reader :a_record
98
98
 
99
99
  ### Attribute Accessors ###
100
- # @param value [String]
100
+ # @return [String]
101
101
  attr_accessor :a_string
102
- # @param value [Integer]
102
+ # @return [Integer]
103
103
  attr_accessor :a_int
104
- # @param value [Integer]
104
+ # @return [Integer]
105
105
  attr_accessor :a_long
106
- # @param value [Float]
106
+ # @return [Float]
107
107
  attr_accessor :a_float
108
- # @param value [Float]
108
+ # @return [Float]
109
109
  attr_accessor :a_double
110
- # @param value [nil, Integer]
110
+ # @return [nil, Integer]
111
111
  attr_accessor :an_optional_int
112
- # @param values [Array<Integer>]
112
+ # @return [Array<Integer>]
113
113
  attr_accessor :an_array
114
- # @param values [Hash<String, String>]
114
+ # @return [Hash<String, String>]
115
115
  attr_accessor :a_map
116
- # @param value [String]
116
+ # @return [String]
117
117
  attr_accessor :timestamp
118
- # @param value [String]
118
+ # @return [String]
119
119
  attr_accessor :message_id
120
120
 
121
121
  ### Attribute Writers ###
122
- # @param value [AnEnum]
122
+ # @return [AnEnum]
123
123
  def an_enum=(value)
124
124
  @an_enum = AnEnum.initialize_from_value(value)
125
125
  end
126
126
 
127
- # @param value [ARecord]
127
+ # @return [ARecord]
128
128
  def a_record=(value)
129
129
  @a_record = ARecord.initialize_from_value(value)
130
130
  end
@@ -198,7 +198,7 @@ module Schemas
198
198
  class Index < Deimos::SchemaClass::Record
199
199
 
200
200
  ### Attribute Accessors ###
201
- # @param value [String]
201
+ # @return [String]
202
202
  attr_accessor :response_id
203
203
 
204
204
  # @override
@@ -241,13 +241,13 @@ module Schemas
241
241
  class MyNestedRecord < Deimos::SchemaClass::Record
242
242
 
243
243
  ### Attribute Accessors ###
244
- # @param value [Integer]
244
+ # @return [Integer]
245
245
  attr_accessor :some_int
246
- # @param value [Float]
246
+ # @return [Float]
247
247
  attr_accessor :some_float
248
- # @param value [String]
248
+ # @return [String]
249
249
  attr_accessor :some_string
250
- # @param value [nil, Integer]
250
+ # @return [nil, Integer]
251
251
  attr_accessor :some_optional_int
252
252
 
253
253
  # @override
@@ -291,20 +291,20 @@ module Schemas
291
291
  attr_reader :some_optional_record
292
292
 
293
293
  ### Attribute Accessors ###
294
- # @param value [String]
294
+ # @return [String]
295
295
  attr_accessor :test_id
296
- # @param value [Float]
296
+ # @return [Float]
297
297
  attr_accessor :test_float
298
- # @param values [Array<String>]
298
+ # @return [Array<String>]
299
299
  attr_accessor :test_array
300
300
 
301
301
  ### Attribute Writers ###
302
- # @param value [MyNestedRecord]
302
+ # @return [MyNestedRecord]
303
303
  def some_nested_record=(value)
304
304
  @some_nested_record = MyNestedRecord.initialize_from_value(value)
305
305
  end
306
306
 
307
- # @param value [nil, MyNestedRecord]
307
+ # @return [nil, MyNestedRecord]
308
308
  def some_optional_record=(value)
309
309
  @some_optional_record = MyNestedRecord.initialize_from_value(value)
310
310
  end
@@ -333,6 +333,13 @@ module Schemas
333
333
  'com.my-namespace'
334
334
  end
335
335
 
336
+ def self.tombstone(key)
337
+ record = self.new
338
+ record.tombstone_key = key
339
+ record.test_id = key
340
+ record
341
+ end
342
+
336
343
  # @override
337
344
  def as_json(_opts={})
338
345
  {
@@ -357,9 +364,9 @@ module Schemas
357
364
  class MySchema < Deimos::SchemaClass::Record
358
365
 
359
366
  ### Attribute Accessors ###
360
- # @param value [String]
367
+ # @return [String]
361
368
  attr_accessor :test_id
362
- # @param value [Integer]
369
+ # @return [Integer]
363
370
  attr_accessor :some_int
364
371
 
365
372
  # @override
@@ -401,9 +408,9 @@ module Schemas
401
408
  class MySchemaCompoundKey < Deimos::SchemaClass::Record
402
409
 
403
410
  ### Attribute Accessors ###
404
- # @param value [String]
411
+ # @return [String]
405
412
  attr_accessor :part_one
406
- # @param value [String]
413
+ # @return [String]
407
414
  attr_accessor :part_two
408
415
 
409
416
  # @override
@@ -445,7 +452,7 @@ module Schemas
445
452
  class MySchemaIdKey < Deimos::SchemaClass::Record
446
453
 
447
454
  ### Attribute Accessors ###
448
- # @param value [Integer]
455
+ # @return [Integer]
449
456
  attr_accessor :id
450
457
 
451
458
  # @override
@@ -484,7 +491,7 @@ module Schemas
484
491
  class MySchemaKey < Deimos::SchemaClass::Record
485
492
 
486
493
  ### Attribute Accessors ###
487
- # @param value [String]
494
+ # @return [String]
488
495
  attr_accessor :test_id
489
496
 
490
497
  # @override
@@ -523,9 +530,9 @@ module Schemas
523
530
  class MySchemaWithBoolean < Deimos::SchemaClass::Record
524
531
 
525
532
  ### Attribute Accessors ###
526
- # @param value [String]
533
+ # @return [String]
527
534
  attr_accessor :test_id
528
- # @param value [Boolean]
535
+ # @return [Boolean]
529
536
  attr_accessor :some_bool
530
537
 
531
538
  # @override
@@ -571,7 +578,7 @@ module Schemas
571
578
  class Property < Deimos::SchemaClass::Record
572
579
 
573
580
  ### Attribute Accessors ###
574
- # @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
581
+ # @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
575
582
  attr_accessor :property
576
583
 
577
584
  # @override
@@ -604,9 +611,9 @@ module Schemas
604
611
  attr_reader :properties
605
612
 
606
613
  ### Attribute Writers ###
607
- # @param values [Hash<String, Property>]
614
+ # @return [Hash<String, Property>]
608
615
  def properties=(values)
609
- @properties = values.transform_values do |value|
616
+ @properties = values&.transform_values do |value|
610
617
  Property.initialize_from_value(value)
611
618
  end
612
619
  end
@@ -651,7 +658,7 @@ module Schemas
651
658
  class ARecord < Deimos::SchemaClass::Record
652
659
 
653
660
  ### Attribute Accessors ###
654
- # @param value [String]
661
+ # @return [String]
655
662
  attr_accessor :a_record_field
656
663
 
657
664
  # @override
@@ -729,57 +736,57 @@ module Schemas
729
736
  attr_reader :some_enum_with_default
730
737
 
731
738
  ### Attribute Accessors ###
732
- # @param value [String]
739
+ # @return [String]
733
740
  attr_accessor :test_id
734
- # @param value [Float]
741
+ # @return [Float]
735
742
  attr_accessor :test_float
736
- # @param values [Array<String>]
743
+ # @return [Array<String>]
737
744
  attr_accessor :test_string_array
738
- # @param values [Array<Integer>]
745
+ # @return [Array<Integer>]
739
746
  attr_accessor :test_int_array
740
- # @param value [Integer, nil]
747
+ # @return [Integer, nil]
741
748
  attr_accessor :test_optional_int
742
- # @param values [Hash<String, Integer>]
749
+ # @return [Hash<String, Integer>]
743
750
  attr_accessor :some_integer_map
744
751
 
745
752
  ### Attribute Writers ###
746
- # @param value [ARecord]
753
+ # @return [ARecord]
747
754
  def some_record=(value)
748
755
  @some_record = ARecord.initialize_from_value(value)
749
756
  end
750
757
 
751
- # @param value [nil, ARecord]
758
+ # @return [nil, ARecord]
752
759
  def some_optional_record=(value)
753
760
  @some_optional_record = ARecord.initialize_from_value(value)
754
761
  end
755
762
 
756
- # @param values [Array<ARecord>]
763
+ # @return [Array<ARecord>]
757
764
  def some_record_array=(values)
758
- @some_record_array = values.map do |value|
765
+ @some_record_array = values&.map do |value|
759
766
  ARecord.initialize_from_value(value)
760
767
  end
761
768
  end
762
769
 
763
- # @param values [Hash<String, ARecord>]
770
+ # @return [Hash<String, ARecord>]
764
771
  def some_record_map=(values)
765
- @some_record_map = values.transform_values do |value|
772
+ @some_record_map = values&.transform_values do |value|
766
773
  ARecord.initialize_from_value(value)
767
774
  end
768
775
  end
769
776
 
770
- # @param values [Array<AnEnum>]
777
+ # @return [Array<AnEnum>]
771
778
  def some_enum_array=(values)
772
- @some_enum_array = values.map do |value|
779
+ @some_enum_array = values&.map do |value|
773
780
  AnEnum.initialize_from_value(value)
774
781
  end
775
782
  end
776
783
 
777
- # @param value [nil, AnotherEnum]
784
+ # @return [nil, AnotherEnum]
778
785
  def some_optional_enum=(value)
779
786
  @some_optional_enum = AnotherEnum.initialize_from_value(value)
780
787
  end
781
788
 
782
- # @param value [YetAnotherEnum]
789
+ # @return [YetAnotherEnum]
783
790
  def some_enum_with_default=(value)
784
791
  @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
785
792
  end
@@ -856,15 +863,15 @@ module Schemas
856
863
  class MySchemaWithDateTime < Deimos::SchemaClass::Record
857
864
 
858
865
  ### Attribute Accessors ###
859
- # @param value [String]
866
+ # @return [String]
860
867
  attr_accessor :test_id
861
- # @param value [Integer, nil]
868
+ # @return [Integer, nil]
862
869
  attr_accessor :updated_at
863
- # @param value [nil, Integer]
870
+ # @return [nil, Integer]
864
871
  attr_accessor :some_int
865
- # @param value [nil, Integer]
872
+ # @return [nil, Integer]
866
873
  attr_accessor :some_datetime_int
867
- # @param value [String]
874
+ # @return [String]
868
875
  attr_accessor :timestamp
869
876
 
870
877
  # @override
@@ -915,13 +922,13 @@ module Schemas
915
922
  class MySchemaWithId < Deimos::SchemaClass::Record
916
923
 
917
924
  ### Attribute Accessors ###
918
- # @param value [String]
925
+ # @return [String]
919
926
  attr_accessor :test_id
920
- # @param value [Integer]
927
+ # @return [Integer]
921
928
  attr_accessor :some_int
922
- # @param value [String]
929
+ # @return [String]
923
930
  attr_accessor :message_id
924
- # @param value [String]
931
+ # @return [String]
925
932
  attr_accessor :timestamp
926
933
 
927
934
  # @override
@@ -969,15 +976,15 @@ module Schemas
969
976
  class MySchemaWithUniqueId < Deimos::SchemaClass::Record
970
977
 
971
978
  ### Attribute Accessors ###
972
- # @param value [Integer]
979
+ # @return [Integer]
973
980
  attr_accessor :id
974
- # @param value [String]
981
+ # @return [String]
975
982
  attr_accessor :test_id
976
- # @param value [Integer]
983
+ # @return [Integer]
977
984
  attr_accessor :some_int
978
- # @param value [String]
985
+ # @return [String]
979
986
  attr_accessor :message_id
980
- # @param value [String]
987
+ # @return [String]
981
988
  attr_accessor :timestamp
982
989
 
983
990
  # @override
@@ -1028,7 +1035,7 @@ module Schemas
1028
1035
  class UpdateRequest < Deimos::SchemaClass::Record
1029
1036
 
1030
1037
  ### Attribute Accessors ###
1031
- # @param value [String]
1038
+ # @return [String]
1032
1039
  attr_accessor :update_request_id
1033
1040
 
1034
1041
  # @override
@@ -1067,7 +1074,7 @@ module Schemas
1067
1074
  class UpdateResponse < Deimos::SchemaClass::Record
1068
1075
 
1069
1076
  ### Attribute Accessors ###
1070
- # @param value [String]
1077
+ # @return [String]
1071
1078
  attr_accessor :update_response_id
1072
1079
 
1073
1080
  # @override
@@ -1106,23 +1113,23 @@ module Schemas
1106
1113
  class Wibble < Deimos::SchemaClass::Record
1107
1114
 
1108
1115
  ### Attribute Accessors ###
1109
- # @param value [Integer]
1116
+ # @return [Integer]
1110
1117
  attr_accessor :id
1111
- # @param value [Integer]
1118
+ # @return [Integer]
1112
1119
  attr_accessor :wibble_id
1113
- # @param value [String]
1120
+ # @return [String]
1114
1121
  attr_accessor :name
1115
- # @param value [String]
1122
+ # @return [String]
1116
1123
  attr_accessor :floop
1117
- # @param value [Integer]
1124
+ # @return [Integer]
1118
1125
  attr_accessor :birthday_int
1119
- # @param value [Integer]
1126
+ # @return [Integer]
1120
1127
  attr_accessor :birthday_long
1121
- # @param value [nil, Integer]
1128
+ # @return [nil, Integer]
1122
1129
  attr_accessor :birthday_optional
1123
- # @param value [Integer]
1130
+ # @return [Integer]
1124
1131
  attr_accessor :updated_at
1125
- # @param value [Integer]
1132
+ # @return [Integer]
1126
1133
  attr_accessor :created_at
1127
1134
 
1128
1135
  # @override
@@ -1185,15 +1192,15 @@ module Schemas
1185
1192
  class Widget < Deimos::SchemaClass::Record
1186
1193
 
1187
1194
  ### Attribute Accessors ###
1188
- # @param value [Integer]
1195
+ # @return [Integer]
1189
1196
  attr_accessor :id
1190
- # @param value [Integer]
1197
+ # @return [Integer]
1191
1198
  attr_accessor :widget_id
1192
- # @param value [String]
1199
+ # @return [String]
1193
1200
  attr_accessor :name
1194
- # @param value [Integer]
1201
+ # @return [Integer]
1195
1202
  attr_accessor :updated_at
1196
- # @param value [Integer]
1203
+ # @return [Integer]
1197
1204
  attr_accessor :created_at
1198
1205
 
1199
1206
  # @override
@@ -1244,15 +1251,15 @@ module Schemas
1244
1251
  class WidgetTheSecond < Deimos::SchemaClass::Record
1245
1252
 
1246
1253
  ### Attribute Accessors ###
1247
- # @param value [Integer]
1254
+ # @return [Integer]
1248
1255
  attr_accessor :id
1249
- # @param value [Integer]
1256
+ # @return [Integer]
1250
1257
  attr_accessor :widget_id
1251
- # @param value [String]
1258
+ # @return [String]
1252
1259
  attr_accessor :model_id
1253
- # @param value [Integer]
1260
+ # @return [Integer]
1254
1261
  attr_accessor :updated_at
1255
- # @param value [Integer]
1262
+ # @return [Integer]
1256
1263
  attr_accessor :created_at
1257
1264
 
1258
1265
  # @override