evva 0.4.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4038f23c86f1051786de3a9a9407a9b9656fc6b449d2e1f62be66f0081fa054
4
- data.tar.gz: 6fc90e80a8a4ac97d935df0fa90cc410d582270845f8a7083081f85bf5069b93
3
+ metadata.gz: e3f1cd09cc493a75e644d51edd737562bf55155de573db968b198820c1b1cad8
4
+ data.tar.gz: 4bd7cd7e846fde8df4a38fc30bdf00f4f836fa201516fa42209fc32b099f6eef
5
5
  SHA512:
6
- metadata.gz: 87a050829faed5ec1792fcca19e064adb17009ddcdf0b19366cab4aedc251816363665d5577cbe8e5c0e9206e30b8eaafb06546b5fdc72adc3243db90cde9d1e
7
- data.tar.gz: ca0d51be95a1f5f0dd4e3e6a224dfb5aa734258be9a1b5e8b1d45386d87174d473268ceec6973147b47aa9ef726d9d8c246a7941365f753d606d9d24769c66da
6
+ metadata.gz: 005373a4fd6e7d93a7f866b8b0d4f84b27e57eb3040d7b268195ef89f6721de34cacfd16d700a234954182fbee1f4b50281f508c623966b6d73d67a96695ebd7
7
+ data.tar.gz: 178a841a3bfc177a24722701f8c5531abce5cc5fd1e48f30908443d055851220b2f2cdddc082c8b1bbe31a9ea77bd15c451a219af8cf83fab483c8d41f95bfe9
data/changelog.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## Unreleased
4
+
5
+ ## [0.4.3] - 2023-09-14
6
+ - Put class properties in newline for Kotlin
7
+
8
+ ## [0.4.2] - 2022-01-05
9
+ - Fix kotlin generation changes in 0.4.0
10
+
3
11
  ## [0.4.1] - 2021-12-23
4
12
  - Changes swift implementation so that destinations belong to EventType/PropertyType instead of Event/Property
5
13
 
@@ -26,6 +26,8 @@ module Evva
26
26
 
27
27
  events = bundle.map do |event|
28
28
  properties = event.properties.map do |name, type|
29
+ type = native_type(type)
30
+
29
31
  param_name = camelize(name.to_s, false)
30
32
  value_fetcher = param_name
31
33
 
@@ -51,8 +53,7 @@ module Evva
51
53
  class_name: camelize(event.event_name),
52
54
  event_name: constantize(event.event_name),
53
55
  properties: properties,
54
- destinations: destinations,
55
- is_object: properties.count == 0 && destinations.count == 0,
56
+ destinations: destinations
56
57
  }
57
58
  end
58
59
 
@@ -82,10 +83,11 @@ module Evva
82
83
  destinations_class_name = destinations_file_name
83
84
 
84
85
  properties = people_bundle.map do |property|
86
+ type = native_type(property.type)
85
87
  {
86
88
  class_name: camelize(property.property_name),
87
89
  property_name: constantize(property.property_name),
88
- type: property.type,
90
+ type: type,
89
91
  is_special_property: is_special_property?(property.type),
90
92
  destinations: property.destinations.map { |p| constantize(p) },
91
93
  }
@@ -175,6 +177,11 @@ module Evva
175
177
  string.tr(' ', '_').upcase
176
178
  end
177
179
 
180
+ def native_type(type)
181
+ type
182
+ .gsub('Date','String')
183
+ end
184
+
178
185
  def is_special_property?(type)
179
186
  !NATIVE_TYPES.include?(type.chomp('?'))
180
187
  end
@@ -1,32 +1,36 @@
1
- sealed class <%= class_name %>(event: <%= enums_class_name %>) {
1
+ sealed class <%= class_name %>(
2
+ event: <%= enums_class_name %>,
3
+ val properties: Map<String, Any?>? = null,
4
+ val destinations: Array<<%= destinations_class_name %>> = emptyArray()
5
+ ) {
2
6
  val name = event.key
3
7
 
4
- open val properties: Map<String, Any?>? = null
5
- open val destinations: Array<<%= destinations_class_name %>> = []
6
-
7
8
  <%- events.each_with_index do |e, index| -%>
8
- <%- if e[:is_object] -%>
9
- object <%= e[:class_name] %> : <%= class_name %>(<%= enums_class_name %>.<%= e[:event_name] %>)
9
+ <%- if e[:properties].count == 0 -%>
10
+ object <%= e[:class_name] %> : <%= class_name %>(
10
11
  <%- else -%>
11
- data class <%= e[:class_name] %><% if e[:properties].count > 0 %>(
12
- <%= e[:properties].map { |p| "val #{p[:param_name]}: #{p[:type]}" }.join(", ") %>
13
- )<% end %> : <%= class_name %>(<%= enums_class_name %>.<%= e[:event_name] %>) {
12
+ data class <%= e[:class_name] %>(
13
+ <%- e[:properties].each_with_index do |p, index| -%>
14
+ <%= "val #{p[:param_name]}: #{p[:type]}" %><% if index < e[:properties].count - 1 %>,<% end %>
15
+ <%- end -%>
16
+ ) : <%= class_name %>(
17
+ <%- end -%>
18
+ event = <%= enums_class_name %>.<%= e[:event_name] %>,
14
19
  <%- if e[:properties].count > 0 -%>
15
- override val properties = mapOf(
20
+ properties = mapOf(
16
21
  <%- e[:properties].each_with_index do |p, index| -%>
17
22
  "<%= p[:name] %>" to <%= p[:value_fetcher] %><% if index < e[:properties].count - 1 %>,<% end %>
18
23
  <%- end -%>
19
- )
24
+ ),
20
25
  <%- end -%>
21
26
  <%- if e[:destinations].count > 0 -%>
22
- override val destinations = [
27
+ destinations = arrayOf(
23
28
  <%- e[:destinations].each_with_index do |d, index| -%>
24
29
  <%= destinations_class_name %>.<%= d %><% if index < e[:destinations].count - 1 %>,<% end %>
25
30
  <%- end -%>
26
- ]
31
+ )
27
32
  <%- end -%>
28
- }
29
- <%- end -%>
33
+ )
30
34
  <%- unless index == events.count - 1 -%>
31
35
 
32
36
  <%- end -%>
@@ -1,22 +1,24 @@
1
- sealed class <%= class_name %>(property: <%= enums_class_name %>) {
1
+ sealed class <%= class_name %>(
2
+ property: <%= enums_class_name %>,
3
+ val innerValue: Any,
4
+ val destinations: Array<<%= destinations_class_name %>> = emptyArray()
5
+ ) {
2
6
  val name = property.key
3
7
 
4
- open val value: Any = ""
5
- open val destinations: Array<<%= destinations_class_name %>> = []
6
-
7
8
  <%- properties.each_with_index do |property, index| -%>
8
9
  data class <%= property[:class_name] %>(
9
10
  val value: <%= property[:type] %>
10
- ) : <%= class_name %>(<%= enums_class_name %>.<%= property[:property_name] %>) {
11
- override val value = value<% if property[:is_special_property] %>.key<% end %>
11
+ ) : <%= class_name %>(
12
+ property = <%= enums_class_name %>.<%= property[:property_name] %>,
13
+ innerValue = value<% if property[:is_special_property] %>.key<% end %>,
12
14
  <%- if property[:destinations].count > 0 -%>
13
- override val destinations = [
15
+ destinations = arrayOf(
14
16
  <%- property[:destinations].each_with_index do |d, index| -%>
15
17
  <%= destinations_class_name %>.<%= d %><% if index < property[:destinations].count - 1 %>,<% end %>
16
18
  <%- end -%>
17
- ]
19
+ )
18
20
  <%- end -%>
19
- }
21
+ )
20
22
  <%- unless index == properties.count - 1 -%>
21
23
 
22
24
  <%- end -%>
data/lib/evva/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Evva
2
- VERSION = '0.4.1'.freeze
3
- VERSION_UPDATED_AT = '2021-12-23'.freeze
2
+ VERSION = '0.4.3'.freeze
3
+ VERSION_UPDATED_AT = '2023-09-14'.freeze
4
4
  end
@@ -10,7 +10,7 @@ describe Evva::AndroidGenerator do
10
10
  Evva::AnalyticsEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }, ["firebase", "custom destination"]),
11
11
  Evva::AnalyticsEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }, ["firebase"]),
12
12
  Evva::AnalyticsEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }, []),
13
- Evva::AnalyticsEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' }, []),
13
+ Evva::AnalyticsEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String', viewed_at: 'Date' }, []),
14
14
  ] }
15
15
 
16
16
  let(:expected) {
@@ -21,64 +21,80 @@ package com.hole19golf.hole19.analytics
21
21
  * This file was automatically generated by evva: https://github.com/hole19/evva
22
22
  */
23
23
 
24
- sealed class AnalyticsEvent(event: AnalyticsEvents) {
24
+ sealed class AnalyticsEvent(
25
+ event: AnalyticsEvents,
26
+ val properties: Map<String, Any?>? = null,
27
+ val destinations: Array<AnalyticsDestinations> = emptyArray()
28
+ ) {
25
29
  val name = event.key
26
30
 
27
- open val properties: Map<String, Any?>? = null
28
- open val destinations: Array<AnalyticsDestinations> = []
31
+ object CpPageView : AnalyticsEvent(
32
+ event = AnalyticsEvents.CP_PAGE_VIEW,
33
+ )
29
34
 
30
- object CpPageView : AnalyticsEvent(AnalyticsEvents.CP_PAGE_VIEW)
31
-
32
- data class CpPageView2 : AnalyticsEvent(AnalyticsEvents.CP_PAGE_VIEW_2) {
33
- override val destinations = [
35
+ object CpPageView2 : AnalyticsEvent(
36
+ event = AnalyticsEvents.CP_PAGE_VIEW_2,
37
+ destinations = arrayOf(
34
38
  AnalyticsDestinations.FIREBASE
35
- ]
36
- }
39
+ )
40
+ )
37
41
 
38
42
  data class CpPageViewA(
39
- val courseId: Long, val courseName: String
40
- ) : AnalyticsEvent(AnalyticsEvents.CP_PAGE_VIEW_A) {
41
- override val properties = mapOf(
43
+ val courseId: Long,
44
+ val courseName: String
45
+ ) : AnalyticsEvent(
46
+ event = AnalyticsEvents.CP_PAGE_VIEW_A,
47
+ properties = mapOf(
42
48
  "course_id" to courseId,
43
49
  "course_name" to courseName
44
- )
45
- override val destinations = [
50
+ ),
51
+ destinations = arrayOf(
46
52
  AnalyticsDestinations.FIREBASE,
47
53
  AnalyticsDestinations.CUSTOM_DESTINATION
48
- ]
49
- }
54
+ )
55
+ )
50
56
 
51
57
  data class CpPageViewB(
52
- val courseId: Long, val courseName: String, val fromScreen: CourseProfileSource
53
- ) : AnalyticsEvent(AnalyticsEvents.CP_PAGE_VIEW_B) {
54
- override val properties = mapOf(
58
+ val courseId: Long,
59
+ val courseName: String,
60
+ val fromScreen: CourseProfileSource
61
+ ) : AnalyticsEvent(
62
+ event = AnalyticsEvents.CP_PAGE_VIEW_B,
63
+ properties = mapOf(
55
64
  "course_id" to courseId,
56
65
  "course_name" to courseName,
57
66
  "from_screen" to fromScreen.key
58
- )
59
- override val destinations = [
67
+ ),
68
+ destinations = arrayOf(
60
69
  AnalyticsDestinations.FIREBASE
61
- ]
62
- }
70
+ )
71
+ )
63
72
 
64
73
  data class CpPageViewC(
65
- val courseId: Long, val courseName: String, val fromScreen: CourseProfileSource?
66
- ) : AnalyticsEvent(AnalyticsEvents.CP_PAGE_VIEW_C) {
67
- override val properties = mapOf(
74
+ val courseId: Long,
75
+ val courseName: String,
76
+ val fromScreen: CourseProfileSource?
77
+ ) : AnalyticsEvent(
78
+ event = AnalyticsEvents.CP_PAGE_VIEW_C,
79
+ properties = mapOf(
68
80
  "course_id" to courseId,
69
81
  "course_name" to courseName,
70
82
  "from_screen" to fromScreen?.key
71
- )
72
- }
83
+ ),
84
+ )
73
85
 
74
86
  data class CpPageViewD(
75
- val courseId: Long?, val courseName: String
76
- ) : AnalyticsEvent(AnalyticsEvents.CP_PAGE_VIEW_D) {
77
- override val properties = mapOf(
87
+ val courseId: Long?,
88
+ val courseName: String,
89
+ val viewedAt: String
90
+ ) : AnalyticsEvent(
91
+ event = AnalyticsEvents.CP_PAGE_VIEW_D,
92
+ properties = mapOf(
78
93
  "course_id" to courseId,
79
- "course_name" to courseName
80
- )
81
- }
94
+ "course_name" to courseName,
95
+ "viewed_at" to viewedAt
96
+ ),
97
+ )
82
98
  }
83
99
  Kotlin
84
100
  }
@@ -141,6 +157,7 @@ Kotlin
141
157
  subject { generator.people_properties(people_bundle, 'AnalyticsProperty', 'AnalyticsProperties', 'AnalyticsDestinations') }
142
158
  let(:people_bundle) { [
143
159
  Evva::AnalyticsProperty.new('rounds_with_wear', 'String', []),
160
+ Evva::AnalyticsProperty.new('last_active_at', 'Date', []),
144
161
  Evva::AnalyticsProperty.new('wear_platform', 'WearableAppPlatform', ["firebase", "custom destination"]),
145
162
  ] }
146
163
  let(:expected) {
@@ -151,27 +168,37 @@ package com.hole19golf.hole19.analytics
151
168
  * This file was automatically generated by evva: https://github.com/hole19/evva
152
169
  */
153
170
 
154
- sealed class AnalyticsProperty(property: AnalyticsProperties) {
171
+ sealed class AnalyticsProperty(
172
+ property: AnalyticsProperties,
173
+ val innerValue: Any,
174
+ val destinations: Array<AnalyticsDestinations> = emptyArray()
175
+ ) {
155
176
  val name = property.key
156
177
 
157
- open val value: Any = ""
158
- open val destinations: Array<AnalyticsDestinations> = []
159
-
160
178
  data class RoundsWithWear(
161
179
  val value: String
162
- ) : AnalyticsProperty(AnalyticsProperties.ROUNDS_WITH_WEAR) {
163
- override val value = value
164
- }
180
+ ) : AnalyticsProperty(
181
+ property = AnalyticsProperties.ROUNDS_WITH_WEAR,
182
+ innerValue = value,
183
+ )
184
+
185
+ data class LastActiveAt(
186
+ val value: String
187
+ ) : AnalyticsProperty(
188
+ property = AnalyticsProperties.LAST_ACTIVE_AT,
189
+ innerValue = value,
190
+ )
165
191
 
166
192
  data class WearPlatform(
167
193
  val value: WearableAppPlatform
168
- ) : AnalyticsProperty(AnalyticsProperties.WEAR_PLATFORM) {
169
- override val value = value.key
170
- override val destinations = [
194
+ ) : AnalyticsProperty(
195
+ property = AnalyticsProperties.WEAR_PLATFORM,
196
+ innerValue = value.key,
197
+ destinations = arrayOf(
171
198
  AnalyticsDestinations.FIREBASE,
172
199
  AnalyticsDestinations.CUSTOM_DESTINATION
173
- ]
174
- }
200
+ )
201
+ )
175
202
  }
176
203
  Kotlin
177
204
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evva
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - RicardoTrindade
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml