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
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module MyNamespace
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.MySchemaWithDateTimes
7
+ class MySchemaWithDateTime < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :test_id
12
+ # @return [Integer, nil]
13
+ attr_accessor :updated_at
14
+ # @return [nil, Integer]
15
+ attr_accessor :some_int
16
+ # @return [nil, Integer]
17
+ attr_accessor :some_datetime_int
18
+ # @return [String]
19
+ attr_accessor :timestamp
20
+
21
+ # @override
22
+ def initialize(test_id: nil,
23
+ updated_at: nil,
24
+ some_int: nil,
25
+ some_datetime_int: nil,
26
+ timestamp: nil)
27
+ super
28
+ self.test_id = test_id
29
+ self.updated_at = updated_at
30
+ self.some_int = some_int
31
+ self.some_datetime_int = some_datetime_int
32
+ self.timestamp = timestamp
33
+ end
34
+
35
+ # @override
36
+ def schema
37
+ 'MySchemaWithDateTimes'
38
+ end
39
+
40
+ # @override
41
+ def namespace
42
+ 'com.my-namespace'
43
+ end
44
+
45
+ # @override
46
+ def as_json(_opts={})
47
+ {
48
+ 'test_id' => @test_id,
49
+ 'updated_at' => @updated_at,
50
+ 'some_int' => @some_int,
51
+ 'some_datetime_int' => @some_datetime_int,
52
+ 'timestamp' => @timestamp
53
+ }
54
+ end
55
+ end
56
+ end; end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module MyNamespace
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.MySchemaWithId
7
+ class MySchemaWithId < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :test_id
12
+ # @return [Integer]
13
+ attr_accessor :some_int
14
+ # @return [String]
15
+ attr_accessor :message_id
16
+ # @return [String]
17
+ attr_accessor :timestamp
18
+
19
+ # @override
20
+ def initialize(test_id: nil,
21
+ some_int: nil,
22
+ message_id: nil,
23
+ timestamp: nil)
24
+ super
25
+ self.test_id = test_id
26
+ self.some_int = some_int
27
+ self.message_id = message_id
28
+ self.timestamp = timestamp
29
+ end
30
+
31
+ # @override
32
+ def schema
33
+ 'MySchemaWithId'
34
+ end
35
+
36
+ # @override
37
+ def namespace
38
+ 'com.my-namespace'
39
+ end
40
+
41
+ # @override
42
+ def as_json(_opts={})
43
+ {
44
+ 'test_id' => @test_id,
45
+ 'some_int' => @some_int,
46
+ 'message_id' => @message_id,
47
+ 'timestamp' => @timestamp
48
+ }
49
+ end
50
+ end
51
+ end; end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module MyNamespace
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.MySchemaWithUniqueId
7
+ class MySchemaWithUniqueId < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [Integer]
11
+ attr_accessor :id
12
+ # @return [String]
13
+ attr_accessor :test_id
14
+ # @return [Integer]
15
+ attr_accessor :some_int
16
+ # @return [String]
17
+ attr_accessor :message_id
18
+ # @return [String]
19
+ attr_accessor :timestamp
20
+
21
+ # @override
22
+ def initialize(id: nil,
23
+ test_id: nil,
24
+ some_int: nil,
25
+ message_id: nil,
26
+ timestamp: nil)
27
+ super
28
+ self.id = id
29
+ self.test_id = test_id
30
+ self.some_int = some_int
31
+ self.message_id = message_id
32
+ self.timestamp = timestamp
33
+ end
34
+
35
+ # @override
36
+ def schema
37
+ 'MySchemaWithUniqueId'
38
+ end
39
+
40
+ # @override
41
+ def namespace
42
+ 'com.my-namespace'
43
+ end
44
+
45
+ # @override
46
+ def as_json(_opts={})
47
+ {
48
+ 'id' => @id,
49
+ 'test_id' => @test_id,
50
+ 'some_int' => @some_int,
51
+ 'message_id' => @message_id,
52
+ 'timestamp' => @timestamp
53
+ }
54
+ end
55
+ end
56
+ end; end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module MyNamespace
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.Wibble
7
+ class Wibble < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [Integer]
11
+ attr_accessor :id
12
+ # @return [Integer]
13
+ attr_accessor :wibble_id
14
+ # @return [String]
15
+ attr_accessor :name
16
+ # @return [String]
17
+ attr_accessor :floop
18
+ # @return [Integer]
19
+ attr_accessor :birthday_int
20
+ # @return [Integer]
21
+ attr_accessor :birthday_long
22
+ # @return [nil, Integer]
23
+ attr_accessor :birthday_optional
24
+ # @return [Integer]
25
+ attr_accessor :updated_at
26
+ # @return [Integer]
27
+ attr_accessor :created_at
28
+
29
+ # @override
30
+ def initialize(id: nil,
31
+ wibble_id: nil,
32
+ name: nil,
33
+ floop: nil,
34
+ birthday_int: nil,
35
+ birthday_long: nil,
36
+ birthday_optional: nil,
37
+ updated_at: nil,
38
+ created_at: nil)
39
+ super
40
+ self.id = id
41
+ self.wibble_id = wibble_id
42
+ self.name = name
43
+ self.floop = floop
44
+ self.birthday_int = birthday_int
45
+ self.birthday_long = birthday_long
46
+ self.birthday_optional = birthday_optional
47
+ self.updated_at = updated_at
48
+ self.created_at = created_at
49
+ end
50
+
51
+ # @override
52
+ def schema
53
+ 'Wibble'
54
+ end
55
+
56
+ # @override
57
+ def namespace
58
+ 'com.my-namespace'
59
+ end
60
+
61
+ # @override
62
+ def as_json(_opts={})
63
+ {
64
+ 'id' => @id,
65
+ 'wibble_id' => @wibble_id,
66
+ 'name' => @name,
67
+ 'floop' => @floop,
68
+ 'birthday_int' => @birthday_int,
69
+ 'birthday_long' => @birthday_long,
70
+ 'birthday_optional' => @birthday_optional,
71
+ 'updated_at' => @updated_at,
72
+ 'created_at' => @created_at
73
+ }
74
+ end
75
+ end
76
+ end; end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module MyNamespace
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.Widget
7
+ class Widget < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [Integer]
11
+ attr_accessor :id
12
+ # @return [Integer]
13
+ attr_accessor :widget_id
14
+ # @return [String]
15
+ attr_accessor :name
16
+ # @return [Integer]
17
+ attr_accessor :updated_at
18
+ # @return [Integer]
19
+ attr_accessor :created_at
20
+
21
+ # @override
22
+ def initialize(id: nil,
23
+ widget_id: nil,
24
+ name: nil,
25
+ updated_at: nil,
26
+ created_at: nil)
27
+ super
28
+ self.id = id
29
+ self.widget_id = widget_id
30
+ self.name = name
31
+ self.updated_at = updated_at
32
+ self.created_at = created_at
33
+ end
34
+
35
+ # @override
36
+ def schema
37
+ 'Widget'
38
+ end
39
+
40
+ # @override
41
+ def namespace
42
+ 'com.my-namespace'
43
+ end
44
+
45
+ # @override
46
+ def as_json(_opts={})
47
+ {
48
+ 'id' => @id,
49
+ 'widget_id' => @widget_id,
50
+ 'name' => @name,
51
+ 'updated_at' => @updated_at,
52
+ 'created_at' => @created_at
53
+ }
54
+ end
55
+ end
56
+ end; end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module MyNamespace
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.WidgetTheSecond
7
+ class WidgetTheSecond < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [Integer]
11
+ attr_accessor :id
12
+ # @return [Integer]
13
+ attr_accessor :widget_id
14
+ # @return [String]
15
+ attr_accessor :model_id
16
+ # @return [Integer]
17
+ attr_accessor :updated_at
18
+ # @return [Integer]
19
+ attr_accessor :created_at
20
+
21
+ # @override
22
+ def initialize(id: nil,
23
+ widget_id: nil,
24
+ model_id: nil,
25
+ updated_at: nil,
26
+ created_at: nil)
27
+ super
28
+ self.id = id
29
+ self.widget_id = widget_id
30
+ self.model_id = model_id
31
+ self.updated_at = updated_at
32
+ self.created_at = created_at
33
+ end
34
+
35
+ # @override
36
+ def schema
37
+ 'WidgetTheSecond'
38
+ end
39
+
40
+ # @override
41
+ def namespace
42
+ 'com.my-namespace'
43
+ end
44
+
45
+ # @override
46
+ def as_json(_opts={})
47
+ {
48
+ 'id' => @id,
49
+ 'widget_id' => @widget_id,
50
+ 'model_id' => @model_id,
51
+ 'updated_at' => @updated_at,
52
+ 'created_at' => @created_at
53
+ }
54
+ end
55
+ end
56
+ end; end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module Request
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.request.CreateTopic
7
+ class CreateTopic < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :request_id
12
+
13
+ # @override
14
+ def initialize(request_id: nil)
15
+ super
16
+ self.request_id = request_id
17
+ end
18
+
19
+ # @override
20
+ def schema
21
+ 'CreateTopic'
22
+ end
23
+
24
+ # @override
25
+ def namespace
26
+ 'com.my-namespace.request'
27
+ end
28
+
29
+ # @override
30
+ def as_json(_opts={})
31
+ {
32
+ 'request_id' => @request_id
33
+ }
34
+ end
35
+ end
36
+ end; end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module Request
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.request.Index
7
+ class Index < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :request_id
12
+
13
+ # @override
14
+ def initialize(request_id: nil)
15
+ super
16
+ self.request_id = request_id
17
+ end
18
+
19
+ # @override
20
+ def schema
21
+ 'Index'
22
+ end
23
+
24
+ # @override
25
+ def namespace
26
+ 'com.my-namespace.request'
27
+ end
28
+
29
+ # @override
30
+ def as_json(_opts={})
31
+ {
32
+ 'request_id' => @request_id
33
+ }
34
+ end
35
+ end
36
+ end; end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module Request
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.request.UpdateRequest
7
+ class UpdateRequest < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :update_request_id
12
+
13
+ # @override
14
+ def initialize(update_request_id: nil)
15
+ super
16
+ self.update_request_id = update_request_id
17
+ end
18
+
19
+ # @override
20
+ def schema
21
+ 'UpdateRequest'
22
+ end
23
+
24
+ # @override
25
+ def namespace
26
+ 'com.my-namespace.request'
27
+ end
28
+
29
+ # @override
30
+ def as_json(_opts={})
31
+ {
32
+ 'update_request_id' => @update_request_id
33
+ }
34
+ end
35
+ end
36
+ end; end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module Response
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.response.CreateTopic
7
+ class CreateTopic < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :response_id
12
+
13
+ # @override
14
+ def initialize(response_id: nil)
15
+ super
16
+ self.response_id = response_id
17
+ end
18
+
19
+ # @override
20
+ def schema
21
+ 'CreateTopic'
22
+ end
23
+
24
+ # @override
25
+ def namespace
26
+ 'com.my-namespace.response'
27
+ end
28
+
29
+ # @override
30
+ def as_json(_opts={})
31
+ {
32
+ 'response_id' => @response_id
33
+ }
34
+ end
35
+ end
36
+ end; end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module Response
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.response.Index
7
+ class Index < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :response_id
12
+
13
+ # @override
14
+ def initialize(response_id: nil)
15
+ super
16
+ self.response_id = response_id
17
+ end
18
+
19
+ # @override
20
+ def schema
21
+ 'Index'
22
+ end
23
+
24
+ # @override
25
+ def namespace
26
+ 'com.my-namespace.response'
27
+ end
28
+
29
+ # @override
30
+ def as_json(_opts={})
31
+ {
32
+ 'response_id' => @response_id
33
+ }
34
+ end
35
+ end
36
+ end; end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is autogenerated by Deimos, Do NOT modify
4
+ module Schemas; module Response
5
+ ### Primary Schema Class ###
6
+ # Autogenerated Schema for Record at com.my-namespace.response.UpdateResponse
7
+ class UpdateResponse < Deimos::SchemaClass::Record
8
+
9
+ ### Attribute Accessors ###
10
+ # @return [String]
11
+ attr_accessor :update_response_id
12
+
13
+ # @override
14
+ def initialize(update_response_id: nil)
15
+ super
16
+ self.update_response_id = update_response_id
17
+ end
18
+
19
+ # @override
20
+ def schema
21
+ 'UpdateResponse'
22
+ end
23
+
24
+ # @override
25
+ def namespace
26
+ 'com.my-namespace.response'
27
+ end
28
+
29
+ # @override
30
+ def as_json(_opts={})
31
+ {
32
+ 'update_response_id' => @update_response_id
33
+ }
34
+ end
35
+ end
36
+ end; end