evva 0.1.4.2 → 0.1.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
  SHA1:
3
- metadata.gz: 90dd43b0fdd3169aa137cf665a8c592693b9d686
4
- data.tar.gz: 12649831ed616d714b7357c3fdff9d1cd7cf41ea
3
+ metadata.gz: 87f47c713fe2f646dc5302d44a06e739976bfd6f
4
+ data.tar.gz: ed72f81ccb086f03fc21426dee5332260a38aa6b
5
5
  SHA512:
6
- metadata.gz: 9d043c714969d7d188026015fe15d0ef3a6d0be113d05593c53624e4af1a63f755800bcfab407d35b4512fd00045791ea59085cc6cc918163faae540222dbd5c
7
- data.tar.gz: ec753ef63337efd78777711e1e2b62b46956a3c44ef699d50d2f9761ff54a9f82cec7124527cf774ca5c95fbae6a3a90785d2d9702bcf0396525dabfc692b2aa
6
+ metadata.gz: dda81be8b9ea3b174d0d20b8e68846681521574eee808318778ccd7265ec7ae27c185b5f615a010c8d544bf62ef5f3fd47382252476d7e46e8a80dc829c4f997
7
+ data.tar.gz: cede59eb52f5858775c0fce0d6ca35621dc0365ace4171bd69f1961d9ea10fcdda4b2139f1fb4bfdb93a2462dafaa3ef0e980fb130eed78fa07bd2b3eb5a8adb
data/README.md CHANGED
@@ -24,4 +24,5 @@ Evva
24
24
  event_file_name: /file/with/tracking/functions
25
25
  event_enum_file_name: /file/with/event/names
26
26
  people_file_name: /file/with/people/properties
27
+ special_enum_file_name: //file/with/special/enum/properties/
27
28
  ```
@@ -1,4 +1,8 @@
1
1
  # Change Log
2
+ ## [0.1.4.3] - 2018-10-12
3
+ - Fixes swift and kotlin tabs, indentation and property names
4
+ - Merges all special enums in a single file
5
+
2
6
  ## [0.1.4.2] - 2018-02-14
3
7
  - Replaces Swift headers
4
8
 
@@ -20,4 +24,4 @@
20
24
  - Fixes mismatch between file name and class name generated.
21
25
 
22
26
  ## [0.1.0] - 2017/10/26
23
- - Initial Release.
27
+ - Initial Release.
@@ -5,7 +5,6 @@ require 'evva/logger'
5
5
  require 'evva/google_sheet'
6
6
  require 'evva/config'
7
7
  require 'evva/file_reader'
8
- require 'evva/data_source'
9
8
  require 'evva/mixpanel_event'
10
9
  require 'evva/mixpanel_enum'
11
10
  require 'evva/object_extension'
@@ -44,13 +43,12 @@ module Evva
44
43
  path = "#{configuration.out_path}/#{configuration.event_enum_file_name}.#{extension}"
45
44
  write_to_file(path, generator.event_enum(bundle[:events], configuration.event_enum_file_name))
46
45
  end
46
+
47
47
  path = "#{configuration.out_path}/#{configuration.people_file_name}.#{extension}"
48
48
  write_to_file(path, generator.people_properties(bundle[:people], configuration.people_file_name))
49
49
 
50
- bundle[:enums].each do |enum|
51
- path = "#{configuration.out_path}/#{enum.enum_name}.#{extension}"
52
- write_to_file(path, generator.special_property_enum(enum))
53
- end
50
+ path = "#{configuration.out_path}/#{configuration.special_enum_file_name}.#{extension}"
51
+ write_to_file(path, generator.special_property_enums(bundle[:enums]))
54
52
  end
55
53
 
56
54
  def analytics_data(config:)
@@ -1,48 +1,72 @@
1
1
  module Evva
2
2
  class AndroidGenerator
3
- KOTLIN_EVENT_HEADER =
4
- "package com.hole19golf.hole19.analytics\n\n"\
5
- "import com.hole19golf.hole19.analytics.Event\n"\
6
- "import com.hole19golf.hole19.analytics.MixpanelAnalyticsMask\n"\
7
- "import org.json.JSONObject\n\n".freeze
8
-
9
- KOTLIN_PEOPLE_HEADER =
10
- "package com.hole19golf.hole19.analytics\n"\
11
- "import com.hole19golf.hole19.analytics.Event\n\n".freeze
12
-
13
- KOTLIN_BUNDLE_HEADER =
14
- "package com.hole19golf.hole19.analytics\n"\
15
- "import com.hole19golf.hole19.analytics.Event\n\n".freeze
16
-
17
- KOTIN_PEOPLE_FUNCTIONS =
18
- "\nopen fun updateProperties(property: MixpanelProperties, value: Any) {\n"\
19
- "\t\tmixpanelMask.updateProperties(property.key, value)"\
20
- "\t\n} \n"\
21
- "\nopen fun incrementCounter(property: MixpanelProperties) {\n"\
22
- "\t\tmixpanelMask.incrementCounter(property.key)"\
23
- "\t\n} \n".freeze
24
-
25
- NATIVE_TYPES = %w[Long Int String Double Float Boolean].freeze
26
3
 
27
4
  def events(bundle, file_name)
28
- event_file = KOTLIN_EVENT_HEADER + "open class #{file_name}(private val mixpanelMask: MixpanelAnalyticsMask) {\n".freeze
29
- bundle.each do |event|
30
- event_file += "\n#{kotlin_function(event)}"
5
+ header_footer_wrapper([IMPORT_EVENT, IMPORT_MASK, IMPORT_JSON]) do
6
+ """open class #{file_name}(private val mask: MixpanelAnalyticsMask) {
7
+
8
+ #{bundle.map { |e| kotlin_function(e) }.join("\n\n")}
9
+
10
+ \topen fun updateProperties(property: MixpanelProperties, value: Any) {
11
+ \t\tmask.updateProperties(property.key, value)
12
+ \t}
13
+
14
+ \topen fun incrementCounter(property: MixpanelProperties) {
15
+ \t\tmask.incrementCounter(property.key)
16
+ \t}
17
+ }"""
31
18
  end
32
- event_file += KOTIN_PEOPLE_FUNCTIONS
33
- event_file += "\n}"
34
19
  end
35
20
 
36
21
  def people_properties(people_bundle, file_name)
37
- properties = KOTLIN_PEOPLE_HEADER + "enum class #{file_name}(val key: String) {\n"
38
- properties += people_bundle.map { |prop| "\t\t#{prop.upcase}(\"#{prop}\")" }.join(",\n")
39
- properties += ";\n}\n"
22
+ header_footer_wrapper do
23
+ body = "enum class MixpanelProperties(val key: String) {\n"
24
+ body << people_bundle.map { |prop| "\t#{prop.upcase}(\"#{prop}\")" }.join(",\n")
25
+ body << ";\n}"
26
+ end
40
27
  end
41
28
 
42
29
  def event_enum(bundle, file_name)
43
- event_file = KOTLIN_BUNDLE_HEADER + "enum class #{file_name}(override val key: String) : Event {\n"
44
- event_file += bundle.map { |event| "\t\t#{event.event_name.upcase}(\"#{event.event_name}\")"}.join(", \n")
45
- event_file += "\n}\n"
30
+ header_footer_wrapper([IMPORT_EVENT]) do
31
+ body = "enum class #{file_name}(override val key: String) : Event {\n"
32
+ body << bundle.map(&:event_name).map { |prop| "\t#{prop.upcase}(\"#{prop}\")" }.join(",\n")
33
+ body << ";\n}"
34
+ end
35
+ end
36
+
37
+ def special_property_enums(enums)
38
+ header_footer_wrapper do
39
+ enums.map do |enum|
40
+ body = "enum class #{enum.enum_name}(val key: String) {\n"
41
+ body << enum.values.map { |vals| "\t#{vals.tr(' ', '_').upcase}(\"#{vals}\")"}.join(",\n")
42
+ body << ";\n}"
43
+ end.join("\n\n")
44
+ end
45
+ end
46
+
47
+ IMPORT_EVENT = "import com.hole19golf.hole19.analytics.Event".freeze
48
+ IMPORT_MASK = "import com.hole19golf.hole19.analytics.MixpanelAnalyticsMask".freeze
49
+ IMPORT_JSON = "import org.json.JSONObject".freeze
50
+
51
+ NATIVE_TYPES = %w[Long Int String Double Float Boolean].freeze
52
+
53
+ private
54
+
55
+ def imports_header(imports = [])
56
+ return unless imports.length > 0
57
+ imports.join("\n") + "\n\n"
58
+ end
59
+
60
+ def header_footer_wrapper(imports = [])
61
+ <<-Kotlin
62
+ package com.hole19golf.hole19.analytics
63
+
64
+ #{imports_header(imports)}/**
65
+ * This file was automatically generated by evva: https://github.com/hole19/evva
66
+ */
67
+
68
+ #{yield.gsub("\t", " ")}
69
+ Kotlin
46
70
  end
47
71
 
48
72
  def kotlin_function(event_data)
@@ -50,27 +74,18 @@ module Evva
50
74
  function_arguments = event_data.properties.map { |name, type| "#{name}: #{type}" }.join(', ')
51
75
  if !function_arguments.empty?
52
76
  props = json_props(event_data.properties)
53
- function_body =
54
- "open fun #{function_name}(#{function_arguments}) {"\
55
- "#{props}"\
56
- "\tmixpanelMask.trackEvent(MixpanelEvent.#{event_data.event_name.upcase}, properties)\n"
77
+ """\topen fun #{function_name}(#{function_arguments}) {
78
+ #{props}
79
+ \t\tmask.trackEvent(MixpanelEvent.#{event_data.event_name.upcase}, properties)
80
+ \t}"""
81
+
57
82
  else
58
- function_body =
59
- "open fun #{function_name}() {\n"\
60
- "\tmixpanelMask.trackEvent(MixpanelEvent.#{event_data.event_name.upcase})\n"
83
+ """\topen fun #{function_name}() {
84
+ \t\tmask.trackEvent(MixpanelEvent.#{event_data.event_name.upcase})
85
+ \t}"""
61
86
  end
62
- function_body += "}\n"
63
- end
64
-
65
- def special_property_enum(enum)
66
- enum_body = "package com.hole19golf.hole19.analytics\n\n"
67
- enum_body += "enum class #{enum.enum_name}(val key: String) {\n"
68
- enum_body += enum.values.map { |vals| "\t#{vals.tr(' ', '_').upcase}(\"#{vals}\")"}.join(",\n")
69
- enum_body += "\n}\n"
70
87
  end
71
88
 
72
- private
73
-
74
89
  def json_props(properties)
75
90
  split_properties =
76
91
  properties
@@ -89,12 +104,10 @@ module Evva
89
104
  end
90
105
  end
91
106
  end
92
- .map { |line| "\t\t#{line}" }
107
+ .map { |line| "\t\t\t#{line}" }
93
108
  .join("\n")
94
109
 
95
- resulting_json = "\n\tval properties = JSONObject().apply {\n" +
96
- +split_properties.to_s
97
- resulting_json += "\n\t}\n"
110
+ "\t\tval properties = JSONObject().apply {\n#{split_properties}\n\t\t}"
98
111
  end
99
112
 
100
113
  def special_property?(type)
@@ -39,6 +39,10 @@ module Evva
39
39
  @hash[:event_enum_file_name]
40
40
  end
41
41
 
42
+ def special_enum_file_name
43
+ @hash[:special_enum_file_name]
44
+ end
45
+
42
46
  CONFIG_STRUCT = {
43
47
  type: Hash,
44
48
  elements: {
@@ -8,45 +8,43 @@ module Evva
8
8
  end
9
9
 
10
10
  def events
11
- raw = raw_data(@sheet_id, 0)
12
- Logger.info('Downloading dictionary from Google Sheet...')
13
- non_language_columns = %w[id updated category
14
- title content link]
15
11
  event_list = []
16
- raw['entry'].each do |entry|
17
- filtered_entry = entry.reject { |c| non_language_columns.include?(c) }
18
- event_name = filtered_entry['eventname'].first
19
- properties = hash_parser(filtered_entry['props'].first)
20
- event_list.push(Evva::MixpanelEvent.new(event_name, properties))
12
+ iterate_entries(raw_data(@sheet_id, 0)) do |entry|
13
+ event_name = entry['eventname'].first
14
+ properties = hash_parser(entry['eventproperties'].first)
15
+ event_list << Evva::MixpanelEvent.new(event_name, properties)
21
16
  end
22
17
  event_list
23
18
  end
24
19
 
25
20
  def people_properties
26
- raw = raw_data(@sheet_id, 1)
27
21
  people_list = []
28
- Logger.info('Downloading dictionary from Google Sheet...')
29
- non_language_columns = %w[id updated category title content link]
30
- raw['entry'].each do |entry|
31
- filtered_entry = entry.reject { |c| non_language_columns.include?(c) }
32
- value = filtered_entry['value'].first
22
+ iterate_entries(raw_data(@sheet_id, 1)) do |entry|
23
+ value = entry['propertyname'].first
33
24
  people_list << value
34
25
  end
35
26
  people_list
36
27
  end
37
28
 
38
29
  def enum_classes
39
- raw = raw_data(@sheet_id, 2)
30
+ enum_list = []
31
+ iterate_entries(raw_data(@sheet_id, 2)) do |entry|
32
+ enum_name = entry['enumname'].first
33
+ values = entry['possiblevalues'].first.split(',')
34
+ enum_list << Evva::MixpanelEnum.new(enum_name, values)
35
+ end
36
+ enum_list
37
+ end
38
+
39
+ private
40
+
41
+ def iterate_entries(data)
40
42
  Logger.info('Downloading dictionary from Google Sheet...')
41
43
  non_language_columns = %w[id updated category title content link]
42
- enum_list = []
43
- raw['entry'].each do |entry|
44
+ data['entry'].each do |entry|
44
45
  filtered_entry = entry.reject { |c| non_language_columns.include?(c) }
45
- enum_name = filtered_entry['enum'].first
46
- values = filtered_entry['values'].first.split(',')
47
- enum_list.push(Evva::MixpanelEnum.new(enum_name, values))
46
+ yield(filtered_entry)
48
47
  end
49
- enum_list
50
48
  end
51
49
 
52
50
  def xml_data(uri, headers = nil)
@@ -56,13 +54,13 @@ module Evva
56
54
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
57
55
  data = http.get(uri.path, headers)
58
56
  unless data.code.to_i == 200
59
- raise 'Cannot access sheet at #{uri} - HTTP #{data.code}'
57
+ raise "Cannot access sheet at #{uri} - HTTP #{data.code}"
60
58
  end
61
59
 
62
60
  begin
63
61
  XmlSimple.xml_in(data.body, 'KeyAttr' => 'name')
64
62
  rescue
65
- raise 'Cannot parse. Expected XML at #{uri}'
63
+ raise "Cannot parse. Expected XML at #{uri}"
66
64
  end
67
65
  end
68
66
 
@@ -73,8 +71,6 @@ module Evva
73
71
  xml_data(url)
74
72
  end
75
73
 
76
- private
77
-
78
74
  def hash_parser(property_array)
79
75
  h = {}
80
76
  unless property_array.empty?
@@ -10,29 +10,26 @@ module Evva
10
10
  NATIVE_TYPES = %w[Int String Double Float Bool].freeze
11
11
 
12
12
  def events(bundle, file_name)
13
- event_file = EXTENSION_HEADER
14
- event_file += "\tenum Event {\n\n"
15
- bundle.each do |event|
16
- event_file += event_case(event)
13
+ header_footer_wrapper do
14
+ """\tenum Event {
15
+ #{bundle.map { |e| event_case(e) }.join("\n")}
16
+
17
+ \t\tvar data: EventData {
18
+ \t\t\tswitch self {
19
+ #{bundle.map { |e| event_data(e) }.join("\n\n")}
20
+ \t\t\t}
21
+ \t\t}
22
+ \t}"""
17
23
  end
18
- event_file += "\n\t\tvar data: EventData {\n"
19
- event_file += "\t\t\tswitch self {\n"
20
- bundle.each do |event|
21
- event_file += event_data(event)
22
- end
23
- event_file += "\t\t\t}\n"
24
- event_file += "\t\t}\n\n"
25
- event_file += "\t}"
26
- event_file += EXTENSION_FOOTER
27
24
  end
28
25
 
29
26
  def event_case(event_data)
30
27
  function_name = camelize(event_data.event_name)
31
28
  if event_data.properties.empty?
32
- "\t\tcase #{function_name}\n"
29
+ "\t\tcase #{function_name}"
33
30
  else
34
31
  trimmed_properties = event_data.properties.map { |k, v| k.to_s + ': ' + native_type(v) }.join(", ")
35
- "\t\tcase #{function_name}(#{trimmed_properties})\n"
32
+ "\t\tcase #{function_name}(#{trimmed_properties})"
36
33
  end
37
34
  end
38
35
 
@@ -40,14 +37,14 @@ module Evva
40
37
  function_name = camelize(event_data.event_name)
41
38
  if event_data.properties.empty?
42
39
  function_body = "\t\t\tcase .#{function_name}:\n" \
43
- "\t\t\t\treturn EventData(name: \"#{event_data.event_name}\")\n\n"
40
+ "\t\t\t\treturn EventData(name: \"#{event_data.event_name}\")"
44
41
  else
45
42
  function_header = prepend_let(event_data.properties)
46
43
  function_arguments = dictionary_pairs(event_data.properties)
47
44
  function_body = "\t\t\tcase .#{function_name}(#{function_header}):\n"\
48
45
  "\t\t\t\treturn EventData(name: \"#{event_data.event_name}\", properties: [\n"\
49
46
  "\t\t\t\t\t#{function_arguments.join(",\n\t\t\t\t\t")} ]\n"\
50
- "\t\t\t\t)\n\n"
47
+ "\t\t\t\t)"
51
48
  end
52
49
  function_body
53
50
  end
@@ -57,23 +54,39 @@ module Evva
57
54
  end
58
55
 
59
56
  def people_properties(people_bundle, file_name)
60
- properties = EXTENSION_HEADER
61
- properties += "\tenum Property: String {\n"
62
- people_bundle.each do |prop|
63
- properties += "\t\tcase #{camelize(prop)} = \"#{prop}\"\n"
57
+ header_footer_wrapper do
58
+ props = "\tenum Property: String {\n"
59
+ people_bundle.each do |prop|
60
+ props << "\t\tcase #{camelize(prop)} = \"#{prop}\"\n"
61
+ end
62
+ props << "\t}"
64
63
  end
65
- properties += "\t}"
66
- properties += EXTENSION_FOOTER
67
64
  end
68
65
 
69
- def special_property_enum(enum)
70
- enum_body = EXTENSION_HEADER
71
- enum_body += "\tenum #{enum.enum_name}: String {\n"
72
- enum.values.map do |val|
73
- enum_body += "\t\tcase #{val.tr(' ', '_')} = \"#{val}\"\n"
66
+ def special_property_enums(enums)
67
+ header_footer_wrapper do
68
+ enums.map do |enum|
69
+ body = "\tenum #{enum.enum_name}: String {\n"
70
+ enum.values.each do |value|
71
+ body << "\t\tcase #{camelize(value)} = \"#{value}\"\n"
72
+ end
73
+ body << "\t}"
74
+ end.join("\n\n")
74
75
  end
75
- enum_body += "\t}"
76
- enum_body += EXTENSION_FOOTER
76
+ end
77
+
78
+ private
79
+
80
+ def header_footer_wrapper
81
+ """// This file was automatically generated by evva: https://github.com/hole19/evva
82
+
83
+ import Foundation
84
+
85
+ extension Analytics {
86
+
87
+ #{yield.gsub("\t", " ")}
88
+ }
89
+ """
77
90
  end
78
91
 
79
92
  def dictionary_pairs(props)
@@ -89,8 +102,6 @@ module Evva
89
102
  end
90
103
  end
91
104
 
92
- private
93
-
94
105
  def is_raw_representable_property?(type)
95
106
  !NATIVE_TYPES.include?(native_type(type).chomp('?'))
96
107
  end
@@ -108,7 +119,7 @@ module Evva
108
119
  end
109
120
 
110
121
  def camelize(term)
111
- string = term.to_s
122
+ string = term.to_s.tr(' ', '_').downcase
112
123
  string = string.sub(/^(?:#{@acronym_regex}(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
113
124
  string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
114
125
  string.gsub!("/".freeze, "::".freeze)
@@ -1,4 +1,4 @@
1
1
  module Evva
2
- VERSION = '0.1.4.2'.freeze
3
- VERSION_UPDATED_AT = '2018-02-14'.freeze
2
+ VERSION = '0.1.4.3'.freeze
3
+ VERSION_UPDATED_AT = '2018-10-12'.freeze
4
4
  end
@@ -1 +1 @@
1
- <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>Enums</title><link rel='alternate' type='application/atom+xml' href='https://docs.google.com/a/hole19golf.com/spreadsheets/d/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/pubhtml'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full'/><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full'/><author><name>ricardo.trindade</name><email>ricardo.trindade@hole19golf.com</email></author><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cokwr</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>PageViewSourceScreen</title><content type='text'>values: course_discovery,synced_courses,nearby,deal</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cokwr'/><gsx:enum>PageViewSourceScreen</gsx:enum><gsx:values>course_discovery,synced_courses,nearby,deal</gsx:values></entry><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cpzh4</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>PremiumClickBuy</title><content type='text'>values: notes,hi_res_maps,whatever</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cpzh4'/><gsx:enum>PremiumClickBuy</gsx:enum><gsx:values>notes,hi_res_maps,whatever</gsx:values></entry></feed>
1
+ <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>Enums</title><link rel='alternate' type='application/atom+xml' href='https://docs.google.com/a/hole19golf.com/spreadsheets/d/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/pubhtml'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full'/><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full'/><author><name>ricardo.trindade</name><email>ricardo.trindade@hole19golf.com</email></author><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cokwr</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>PageViewSourceScreen</title><content type='text'>possiblevalues: course_discovery,synced_courses,nearby,deal</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cokwr'/><gsx:enumname>PageViewSourceScreen</gsx:enumname><gsx:possiblevalues>course_discovery,synced_courses,nearby,deal</gsx:possiblevalues></entry><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cpzh4</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>PremiumClickBuy</title><content type='text'>possiblevalues: notes,hi_res_maps,whatever</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/osju1vh/public/full/cpzh4'/><gsx:enumname>PremiumClickBuy</gsx:enumname><gsx:possiblevalues>notes,hi_res_maps,whatever</gsx:possiblevalues></entry></feed>
@@ -1 +1 @@
1
- <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full</id><updated>2017-09-06T13:27:41.023Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>PeopleProperties</title><link rel='alternate' type='application/atom+xml' href='https://docs.google.com/a/hole19golf.com/spreadsheets/d/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/pubhtml'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full'/><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full'/><author><name>ricardo.trindade</name><email>ricardo.trindade@hole19golf.com</email></author><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cokwr</id><updated>2017-09-06T13:27:41.023Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>roundsWithWear</title><content type='text'>value: rounds_with_wear</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cokwr'/><gsx:properties>roundsWithWear</gsx:properties><gsx:value>rounds_with_wear</gsx:value></entry><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cpzh4</id><updated>2017-09-06T13:27:41.023Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>totalFriends</title><content type='text'>value: total_friends</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cpzh4'/><gsx:properties>totalFriends</gsx:properties><gsx:value>total_friends</gsx:value></entry></feed>
1
+ <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full</id><updated>2017-09-06T13:27:41.023Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>PeopleProperties</title><link rel='alternate' type='application/atom+xml' href='https://docs.google.com/a/hole19golf.com/spreadsheets/d/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/pubhtml'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full'/><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full'/><author><name>ricardo.trindade</name><email>ricardo.trindade@hole19golf.com</email></author><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cokwr</id><updated>2017-09-06T13:27:41.023Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>roundsWithWear</title><content type='text'>propertyname: rounds_with_wear</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cokwr'/><gsx:properties>roundsWithWear</gsx:properties><gsx:propertyname>rounds_with_wear</gsx:propertyname></entry><entry><id>https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cpzh4</id><updated>2017-09-06T13:27:41.023Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>totalFriends</title><content type='text'>propertyname: total_friends</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1LaJd68os3g_GFlerogC64grNIlXb2iukMznOvdml7A4/ojyi830/public/full/cpzh4'/><gsx:properties>totalFriends</gsx:properties><gsx:propertyname>total_friends</gsx:propertyname></entry></feed>
@@ -1 +1 @@
1
- <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>Events</title><link rel='alternate' type='application/atom+xml' href='https://docs.google.com/a/hole19golf.com/spreadsheets/d/abc1234567890/pubhtml'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full'/><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full'/><author><name>ricardo.trindade</name><email>ricardo.trindade@hole19golf.com</email></author><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><entry><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cokwr</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>trackCpPageView</title><content type='text'>eventname: cp_page_view, props: course_id:Long,course_name:String</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cokwr'/><gsx:functionname>trackCpPageView</gsx:functionname><gsx:eventname>cp_page_view</gsx:eventname><gsx:props>course_id:Long,course_name:String</gsx:props></entry><entry><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cpzh4</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>trackNavFeedTap</title><content type='text'>eventname: nav_feed_tap</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cpzh4'/><gsx:functionname>trackNavFeedTap</gsx:functionname><gsx:eventname>nav_feed_tap</gsx:eventname><gsx:props></gsx:props></entry><entry><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cre1l</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>trackCpViewScorecard</title><content type='text'>eventname: cp_view_scorecard, props: course_id:Long,course_name:String</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cre1l'/><gsx:functionname>trackCpViewScorecard</gsx:functionname><gsx:eventname>cp_view_scorecard</gsx:eventname><gsx:props>course_id:Long,course_name:String</gsx:props></entry></feed>
1
+ <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>Events</title><link rel='alternate' type='application/atom+xml' href='https://docs.google.com/a/hole19golf.com/spreadsheets/d/abc1234567890/pubhtml'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full'/><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full'/><author><name>ricardo.trindade</name><email>ricardo.trindade@hole19golf.com</email></author><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><entry><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cokwr</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>trackCpPageView</title><content type='text'>eventname: cp_page_view, eventproperties: course_id:Long,course_name:String</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cokwr'/><gsx:functionname>trackCpPageView</gsx:functionname><gsx:eventname>cp_page_view</gsx:eventname><gsx:eventproperties>course_id:Long,course_name:String</gsx:eventproperties></entry><entry><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cpzh4</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>trackNavFeedTap</title><content type='text'>eventname: nav_feed_tap</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cpzh4'/><gsx:functionname>trackNavFeedTap</gsx:functionname><gsx:eventname>nav_feed_tap</gsx:eventname><gsx:eventproperties></gsx:eventproperties></entry><entry><id>https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cre1l</id><updated>2017-08-22T10:31:52.161Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>trackCpViewScorecard</title><content type='text'>eventname: cp_view_scorecard, eventproperties: course_id:Long,course_name:String</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/abc1234567890/od6/public/full/cre1l'/><gsx:functionname>trackCpViewScorecard</gsx:functionname><gsx:eventname>cp_view_scorecard</gsx:eventname><gsx:eventproperties>course_id:Long,course_name:String</gsx:eventproperties></entry></feed>
@@ -1,135 +1,153 @@
1
1
  describe Evva::AndroidGenerator do
2
2
  let(:generator) { described_class.new }
3
3
 
4
- def trim_spaces(str)
5
- str.gsub(/^[ \t]+/, '')
6
- .gsub(/[ \t]+$/, '')
7
- end
4
+ describe '#events' do
5
+ subject { generator.events(events, "MixpanelAnalytics") }
8
6
 
9
- describe '#kotlin_function' do
10
- subject { trim_spaces(generator.kotlin_function(event)) }
7
+ let(:events) { [
8
+ Evva::MixpanelEvent.new('cp_page_view'),
9
+ Evva::MixpanelEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }),
10
+ Evva::MixpanelEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }),
11
+ Evva::MixpanelEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }),
12
+ Evva::MixpanelEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' })
13
+ ] }
11
14
 
12
- context 'when the event has no properties' do
13
- let(:event) { Evva::MixpanelEvent.new('nav_feed_tap') }
14
- let(:expected) { <<-Kotlin
15
- open fun trackNavFeedTap() {
16
- mixpanelMask.trackEvent(MixpanelEvent.NAV_FEED_TAP)
17
- }
18
- Kotlin
19
- }
20
- it { should eq trim_spaces(expected) }
21
- end
22
-
23
- context 'event has properties' do
24
- let(:event) { Evva::MixpanelEvent.new('cp_page_view', { course_id: 'Long', course_name: 'String' }) }
25
- let(:expected) { <<-Kotlin
26
- open fun trackCpPageView(course_id: Long, course_name: String) {
27
- val properties = JSONObject().apply {
15
+ let(:expected) {
16
+ <<-Kotlin
17
+ package com.hole19golf.hole19.analytics
18
+
19
+ import com.hole19golf.hole19.analytics.Event
20
+ import com.hole19golf.hole19.analytics.MixpanelAnalyticsMask
21
+ import org.json.JSONObject
22
+
23
+ /**
24
+ * This file was automatically generated by evva: https://github.com/hole19/evva
25
+ */
26
+
27
+ open class MixpanelAnalytics(private val mask: MixpanelAnalyticsMask) {
28
+
29
+ open fun trackCpPageView() {
30
+ mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW)
31
+ }
32
+
33
+ open fun trackCpPageViewA(course_id: Long, course_name: String) {
34
+ val properties = JSONObject().apply {
28
35
  put("course_id", course_id)
29
36
  put("course_name", course_name)
30
- }
31
- mixpanelMask.trackEvent(MixpanelEvent.CP_PAGE_VIEW, properties)
32
37
  }
33
- Kotlin
34
- }
35
- it { should eq trim_spaces(expected) }
36
- end
37
-
38
- context 'event has special properties' do
39
- let(:event) { Evva::MixpanelEvent.new('cp_page_view', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }) }
40
- let(:expected) { <<-Kotlin
41
- open fun trackCpPageView(course_id: Long, course_name: String, from_screen: CourseProfileSource) {
42
- val properties = JSONObject().apply {
38
+ mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_A, properties)
39
+ }
40
+
41
+ open fun trackCpPageViewB(course_id: Long, course_name: String, from_screen: CourseProfileSource) {
42
+ val properties = JSONObject().apply {
43
43
  put("course_id", course_id)
44
44
  put("course_name", course_name)
45
45
  put("from_screen", from_screen.key)
46
- }
47
- mixpanelMask.trackEvent(MixpanelEvent.CP_PAGE_VIEW, properties)
48
46
  }
49
- Kotlin
50
- }
51
- it { should eq trim_spaces(expected) }
52
- end
53
-
54
- context 'event has optional properties' do
55
- let(:event) { Evva::MixpanelEvent.new('cp_page_view', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }) }
56
- let(:expected) { <<-Kotlin
57
- open fun trackCpPageView(course_id: Long, course_name: String, from_screen: CourseProfileSource?) {
58
- val properties = JSONObject().apply {
47
+ mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_B, properties)
48
+ }
49
+
50
+ open fun trackCpPageViewC(course_id: Long, course_name: String, from_screen: CourseProfileSource?) {
51
+ val properties = JSONObject().apply {
59
52
  put("course_id", course_id)
60
53
  put("course_name", course_name)
61
54
  from_screen?.let { put("from_screen", it.key) }
62
- }
63
- mixpanelMask.trackEvent(MixpanelEvent.CP_PAGE_VIEW, properties)
64
55
  }
65
- Kotlin
66
- }
67
- it { should eq trim_spaces(expected) }
68
- end
69
-
70
- context 'event has optional but not special properties' do
71
- let(:event) { Evva::MixpanelEvent.new('cp_page_view', { course_id: 'Long?', course_name: 'String' }) }
72
- let(:expected) { <<-Kotlin
73
- open fun trackCpPageView(course_id: Long?, course_name: String) {
74
- val properties = JSONObject().apply {
56
+ mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_C, properties)
57
+ }
58
+
59
+ open fun trackCpPageViewD(course_id: Long?, course_name: String) {
60
+ val properties = JSONObject().apply {
75
61
  course_id?.let { put("course_id", it) }
76
62
  put("course_name", course_name)
77
- }
78
- mixpanelMask.trackEvent(MixpanelEvent.CP_PAGE_VIEW, properties)
79
63
  }
80
- Kotlin
81
- }
82
- it { should eq trim_spaces(expected) }
83
- end
64
+ mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_D, properties)
65
+ }
66
+
67
+ open fun updateProperties(property: MixpanelProperties, value: Any) {
68
+ mask.updateProperties(property.key, value)
69
+ }
70
+
71
+ open fun incrementCounter(property: MixpanelProperties) {
72
+ mask.incrementCounter(property.key)
73
+ }
74
+ }
75
+ Kotlin
76
+ }
77
+
78
+ it { should eq expected }
84
79
  end
85
80
 
86
- describe '#special_property_enum' do
87
- subject { trim_spaces(generator.special_property_enum(enum)) }
88
- let(:enum) { Evva::MixpanelEnum.new('CourseProfileSource', ['course_discovery','synced_courses']) }
89
- let(:expected) { <<-Kotlin
90
- package com.hole19golf.hole19.analytics
91
-
92
- enum class CourseProfileSource(val key: String) {
93
- COURSE_DISCOVERY("course_discovery"),
94
- SYNCED_COURSES("synced_courses")
95
- }
96
- Kotlin
81
+ describe '#special_property_enums' do
82
+ subject { generator.special_property_enums(enums) }
83
+ let(:enums) { [
84
+ Evva::MixpanelEnum.new('CourseProfileSource', ['course_discovery', 'synced_courses']),
85
+ Evva::MixpanelEnum.new('PremiumFrom', ['Course Profile', 'Round Setup'])
86
+ ] }
87
+ let(:expected) {
88
+ <<-Kotlin
89
+ package com.hole19golf.hole19.analytics
90
+
91
+ /**
92
+ * This file was automatically generated by evva: https://github.com/hole19/evva
93
+ */
94
+
95
+ enum class CourseProfileSource(val key: String) {
96
+ COURSE_DISCOVERY("course_discovery"),
97
+ SYNCED_COURSES("synced_courses");
98
+ }
99
+
100
+ enum class PremiumFrom(val key: String) {
101
+ COURSE_PROFILE("Course Profile"),
102
+ ROUND_SETUP("Round Setup");
103
+ }
104
+ Kotlin
97
105
  }
98
- it { should eq trim_spaces(expected) }
106
+ it { should eq expected }
99
107
  end
100
108
 
101
109
  describe '#event_enum' do
102
- subject { trim_spaces(generator.event_enum(event_bundle, 'MixpanelEvent')) }
110
+ subject { generator.event_enum(event_bundle, 'MixpanelEvent') }
103
111
  let(:event_bundle) { [
104
112
  Evva::MixpanelEvent.new('nav_feed_tap', {}),
105
113
  Evva::MixpanelEvent.new('nav_performance_tap', {})
106
114
  ] }
107
- let(:expected) { <<-Kotlin
108
- package com.hole19golf.hole19.analytics
109
- import com.hole19golf.hole19.analytics.Event
110
-
111
- enum class MixpanelEvent(override val key: String) : Event {
112
- NAV_FEED_TAP("nav_feed_tap"),
113
- NAV_PERFORMANCE_TAP("nav_performance_tap")
114
- }
115
- Kotlin
115
+ let(:expected) {
116
+ <<-Kotlin
117
+ package com.hole19golf.hole19.analytics
118
+
119
+ import com.hole19golf.hole19.analytics.Event
120
+
121
+ /**
122
+ * This file was automatically generated by evva: https://github.com/hole19/evva
123
+ */
124
+
125
+ enum class MixpanelEvent(override val key: String) : Event {
126
+ NAV_FEED_TAP("nav_feed_tap"),
127
+ NAV_PERFORMANCE_TAP("nav_performance_tap");
128
+ }
129
+ Kotlin
116
130
  }
117
- it { should eq trim_spaces(expected) }
131
+ it { should eq expected }
118
132
  end
119
133
 
120
134
  describe '#people_properties' do
121
- subject { trim_spaces(generator.people_properties(people_bundle, 'MixpanelProperties')) }
135
+ subject { generator.people_properties(people_bundle, 'MixpanelProperties') }
122
136
  let(:people_bundle) { ['rounds_with_wear', 'friends_from_facebook'] }
123
- let(:expected) { <<-Kotlin
124
- package com.hole19golf.hole19.analytics
125
- import com.hole19golf.hole19.analytics.Event
126
-
127
- enum class MixpanelProperties(val key: String) {
128
- ROUNDS_WITH_WEAR("rounds_with_wear"),
129
- FRIENDS_FROM_FACEBOOK("friends_from_facebook");
130
- }
131
- Kotlin
137
+ let(:expected) {
138
+ <<-Kotlin
139
+ package com.hole19golf.hole19.analytics
140
+
141
+ /**
142
+ * This file was automatically generated by evva: https://github.com/hole19/evva
143
+ */
144
+
145
+ enum class MixpanelProperties(val key: String) {
146
+ ROUNDS_WITH_WEAR("rounds_with_wear"),
147
+ FRIENDS_FROM_FACEBOOK("friends_from_facebook");
148
+ }
149
+ Kotlin
132
150
  }
133
- it { should eq trim_spaces(expected) }
151
+ it { should eq expected }
134
152
  end
135
153
  end
@@ -1,94 +1,125 @@
1
1
  describe Evva::SwiftGenerator do
2
2
  let(:generator) { described_class.new }
3
3
 
4
- def trim_spaces(str)
5
- str.gsub(/^[ \t]+/, '')
6
- .gsub(/[ \t]+$/, '')
7
- end
8
-
9
4
  describe '#events' do
10
- subject { trim_spaces(generator.events(event_bundle, "")) }
11
- let(:event_bundle) {
12
- [Evva::MixpanelEvent.new('nav_feed_tap', []),
13
- Evva::MixpanelEvent.new('cp_page_view', ['course_id:Long'],['course_name:String?'])]
14
- }
15
- let(:expected) { <<-Swift
16
- import CoreLocation
17
- import Foundation
18
- import SharedCode
19
-
20
- class MixpanelHelper: NSObject {
21
- enum Event {
22
- case trackNavFeedTap
23
- case trackCpPageView(course_id: Long, course_name: String?)
24
- }
25
-
26
- private var data: EventData {
27
- switch self {
5
+ subject { generator.events(event_bundle, "") }
6
+
7
+ let(:event_bundle) { [
8
+ Evva::MixpanelEvent.new('cp_page_view'),
9
+ Evva::MixpanelEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }),
10
+ Evva::MixpanelEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }),
11
+ Evva::MixpanelEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }),
12
+ Evva::MixpanelEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' })
13
+ ] }
14
+
15
+ let(:expected) {
16
+ <<-Swift
17
+ // This file was automatically generated by evva: https://github.com/hole19/evva
28
18
 
29
- case .trackNavFeedTap
30
- return EventData(name:"nav_feed_tap")
19
+ import Foundation
31
20
 
32
- case .trackCpPageView(let course_id, let course_name):
33
- return EventData(name:"cp_page_view", properties: ["course_id": course_id, "course_name": course_name])
34
- }
21
+ extension Analytics {
22
+
23
+ enum Event {
24
+ case cpPageView
25
+ case cpPageViewA(course_id: Int, course_name: String)
26
+ case cpPageViewB(course_id: Int, course_name: String, from_screen: CourseProfileSource)
27
+ case cpPageViewC(course_id: Int, course_name: String, from_screen: CourseProfileSource?)
28
+ case cpPageViewD(course_id: Int?, course_name: String)
29
+
30
+ var data: EventData {
31
+ switch self {
32
+ case .cpPageView:
33
+ return EventData(name: "cp_page_view")
34
+
35
+ case .cpPageViewA(let course_id, let course_name):
36
+ return EventData(name: "cp_page_view_a", properties: [
37
+ "course_id": course_id as Any,
38
+ "course_name": course_name as Any ]
39
+ )
40
+
41
+ case .cpPageViewB(let course_id, let course_name, let from_screen):
42
+ return EventData(name: "cp_page_view_b", properties: [
43
+ "course_id": course_id as Any,
44
+ "course_name": course_name as Any,
45
+ "from_screen": from_screen.rawValue as Any ]
46
+ )
47
+
48
+ case .cpPageViewC(let course_id, let course_name, let from_screen):
49
+ return EventData(name: "cp_page_view_c", properties: [
50
+ "course_id": course_id as Any,
51
+ "course_name": course_name as Any,
52
+ "from_screen": from_screen?.rawValue as Any ]
53
+ )
54
+
55
+ case .cpPageViewD(let course_id, let course_name):
56
+ return EventData(name: "cp_page_view_d", properties: [
57
+ "course_id": course_id as Any,
58
+ "course_name": course_name as Any ]
59
+ )
60
+ }
35
61
  }
36
- Swift
37
62
  }
38
- it { should eq trim_spaces(expected) }
63
+ }
64
+ Swift
65
+ }
66
+
67
+ it { should eq expected }
39
68
  end
40
69
 
41
- describe '#process_arguments' do
42
- context "with optional arguments" do
43
- let(:properties) { 'course_id:Long,course_name:String,from_screen: CourseProfileSource?' }
70
+ describe '#special_property_enums' do
71
+ subject { generator.special_property_enums(enums) }
44
72
 
45
- it 'processes the arguments looking for special properties' do
46
- expected = '"course_id": course_id, "course_name": course_name, "from_screen": from_screen.rawValue'
47
- expect(generator.process_arguments(properties)).to eq expected
48
- end
49
- end
73
+ let(:enums) { [
74
+ Evva::MixpanelEnum.new('CourseProfileSource', ['course_discovery', 'synced_courses']),
75
+ Evva::MixpanelEnum.new('PremiumFrom', ['Course Profile', 'Round Setup'])
76
+ ] }
50
77
 
51
- context "without optional arguments" do
52
- let(:properties) { 'course_id:Long,course_name:String,from_screen: CourseProfileSource' }
78
+ let(:expected) {
79
+ <<-Swift
80
+ // This file was automatically generated by evva: https://github.com/hole19/evva
53
81
 
54
- it 'processes the arguments looking for special properties' do
55
- expected = '"course_id": course_id, "course_name": course_name, "from_screen": from_screen.rawValue'
56
- expect(generator.process_arguments(properties)).to eq expected
57
- end
58
- end
59
- end
82
+ import Foundation
60
83
 
61
- describe '#special_property_enum' do
62
- subject { trim_spaces(generator.special_property_enum(enum)) }
63
- let(:enum) { Evva::MixpanelEnum.new('CourseProfileSource', 'course_discovery,synced_courses') }
64
- let(:expected) { <<-Swift
65
- import Foundation
84
+ extension Analytics {
66
85
 
67
- enum CourseProfileSource: String {
68
- case course_discovery = "course_discovery"
69
- case synced_courses = "synced_courses"
70
- }
71
- Swift
72
- }
86
+ enum CourseProfileSource: String {
87
+ case courseDiscovery = "course_discovery"
88
+ case syncedCourses = "synced_courses"
89
+ }
90
+
91
+ enum PremiumFrom: String {
92
+ case courseProfile = "Course Profile"
93
+ case roundSetup = "Round Setup"
94
+ }
95
+ }
96
+ Swift
97
+ }
73
98
 
74
- it { should eq trim_spaces(expected) }
99
+ it { should eq expected }
75
100
  end
76
101
 
77
102
  describe "#people_properties" do
78
- subject { trim_spaces(generator.people_properties(people_bundle)) }
103
+ subject { generator.people_properties(people_bundle, "") }
104
+
79
105
  let(:people_bundle) { ['rounds_with_wear', 'friends_from_facebook'] }
80
- let(:expected) { <<-Swift
81
- fileprivate enum Counter: String {
82
- case RoundsWithWear = "rounds_with_wear"
83
- case FriendsFromFacebook = "friends_from_facebook"
84
106
 
85
- func increment(times: Int = 1) {
86
- MixpanelAPI.instance.incrementCounter(rawValue, times: times)
87
- }
88
- }
89
- Swift
107
+ let(:expected) {
108
+ <<-Swift
109
+ // This file was automatically generated by evva: https://github.com/hole19/evva
110
+
111
+ import Foundation
112
+
113
+ extension Analytics {
114
+
115
+ enum Property: String {
116
+ case roundsWithWear = "rounds_with_wear"
117
+ case friendsFromFacebook = "friends_from_facebook"
118
+ }
119
+ }
120
+ Swift
90
121
  }
91
122
 
92
- it { should eq trim_spaces(expected) }
123
+ it { should eq expected }
93
124
  end
94
125
  end
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.1.4.2
4
+ version: 0.1.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: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -86,7 +86,6 @@ files:
86
86
  - lib/evva.rb
87
87
  - lib/evva/android_generator.rb
88
88
  - lib/evva/config.rb
89
- - lib/evva/data_source.rb
90
89
  - lib/evva/file_reader.rb
91
90
  - lib/evva/google_sheet.rb
92
91
  - lib/evva/logger.rb
@@ -104,7 +103,6 @@ files:
104
103
  - spec/fixtures/test.yml
105
104
  - spec/lib/evva/android_generator_spec.rb
106
105
  - spec/lib/evva/config_spec.rb
107
- - spec/lib/evva/data_source_spec.rb
108
106
  - spec/lib/evva/google_sheet_spec.rb
109
107
  - spec/lib/evva/logger_spec.rb
110
108
  - spec/lib/evva/object_extension_spec.rb
@@ -130,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
128
  version: '0'
131
129
  requirements: []
132
130
  rubyforge_project:
133
- rubygems_version: 2.6.13
131
+ rubygems_version: 2.5.2
134
132
  signing_key:
135
133
  specification_version: 4
136
134
  summary: An event generating service
@@ -1,23 +0,0 @@
1
- module Evva
2
- class DataSource
3
- def initialize(keys)
4
- unless keys.is_a?(Hash)
5
- raise ArgumentError, "keys: expected Hash, got #{keys.class}"
6
- end
7
-
8
- keys.each do |property, v|
9
- unless v.is_a?(Hash)
10
- raise ArgumentError, "keys['#{property}']: expected Hash, got #{v.class}"
11
- end
12
-
13
- v.each do |key, v|
14
- unless v.is_a?(String) || v.nil?
15
- raise ArgumentError, "keys['#{property}']['#{key}']: expected String, got #{v.class}"
16
- end
17
- end
18
- end
19
-
20
- @keys = Hash[keys.map { |k, v| [k.downcase, v] }]
21
- end
22
- end
23
- end
@@ -1,28 +0,0 @@
1
- describe Evva::DataSource do
2
- subject(:dict) { Evva::DataSource.new(keys) }
3
-
4
- describe '.initialize' do
5
- let(:keys) { { 'event' => { 'kNo1' => 'text' } } }
6
- it { expect { subject }.not_to raise_error }
7
-
8
- context 'when created with invalid type parameters' do
9
- let(:keys) { 'cenas' }
10
- it { expect { subject }.to raise_error /expected Hash/ }
11
- end
12
-
13
- context 'when created with an invalid json schema' do
14
- let(:keys) { { 'event' => 'text' } }
15
- it { expect { subject }.to raise_error /event.+expected Hash/ }
16
- end
17
-
18
- context 'when created with an invalid json schema' do
19
- let(:keys) { { 'a-event' => { 'kNo1' => { 'wtvr' => 'text' } } } }
20
- it { expect { subject }.to raise_error /a-event.+kNo1.+expected String/ }
21
- end
22
-
23
- context 'when given empty translations' do
24
- let(:keys) { { 'event' => { 'kNo1' => nil } } }
25
- it { expect { subject }.not_to raise_error }
26
- end
27
- end
28
- end