evva 0.12.0 → 0.13.0

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: 945fb4d07c2dc210b99bf3c55d982c11d4c1c1c7307c7490d205149cc86dc831
4
- data.tar.gz: '0781922206107e696a41f94cd15382af80be989c29f03f72dc6b65a5a6453645'
3
+ metadata.gz: 11a3e62f36773bd96ad485577a172c40d85649b43d632963de7b187128b8254c
4
+ data.tar.gz: 7e632bd6eb6255aa380e31059c2ae58d5e74a3eeb1a92d86e854fe5d3730855b
5
5
  SHA512:
6
- metadata.gz: 0e9b3fff1aec327f2444a1d6b989bc84b38d96aa0a7d691702b3cc81a2eb7b177ba059ab12aa9c620d54c4488cdf11acda28afa4779c415bc6791cf36ff8f0d4
7
- data.tar.gz: 7bfb6cf627c14722c27f77339c6211116a73cc67edd28a28baef17f1f802a99c2ded603d5e4ddd6a9939c742feb77262e1445f926026eb332e7edf79f4219f6b
6
+ metadata.gz: fc83e148bae17eb161a64eeaba2a3ddad170646b9ea3d1cfeba4a040ad43eec48aae7742f92cc57c988b129076f127901994bc685e538dcb254f1af1f49ac915
7
+ data.tar.gz: d055fb0cfbbd46cebd1ec6db45781a8c5cb2b81bb74d01e677aa9d2155da850d184b25daef2602aa2310326cfcd22e75021d268d6280c1118ca964a279871ac3
@@ -15,7 +15,7 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby-version: ['3.2', '3.3', '3.4']
18
+ ruby-version: ['3.2', '3.3', '3.4', '4.0']
19
19
 
20
20
  steps:
21
21
  - uses: actions/checkout@v4
data/.rubocop_todo.yml CHANGED
@@ -43,7 +43,7 @@ Layout/DotPosition:
43
43
  # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
44
44
  Layout/ExtraSpacing:
45
45
  Exclude:
46
- - 'spec/lib/evva/google_sheet_spec.rb'
46
+ - 'spec/lib/evva/csv_source_spec.rb'
47
47
 
48
48
  # Offense count: 1
49
49
  # This cop supports safe autocorrection (--autocorrect).
@@ -98,7 +98,7 @@ Layout/SpaceAfterComma:
98
98
  Exclude:
99
99
  - 'lib/evva/kotlin_generator.rb'
100
100
  - 'lib/evva/swift_generator.rb'
101
- - 'spec/lib/evva/google_sheet_spec.rb'
101
+ - 'spec/lib/evva/csv_source_spec.rb'
102
102
 
103
103
  # Offense count: 94
104
104
  # This cop supports safe autocorrection (--autocorrect).
@@ -111,7 +111,7 @@ Layout/SpaceInsideHashLiteralBraces:
111
111
  - 'lib/evva/logger.rb'
112
112
  - 'spec/evva_spec.rb'
113
113
  - 'spec/lib/evva/config_spec.rb'
114
- - 'spec/lib/evva/google_sheet_spec.rb'
114
+ - 'spec/lib/evva/csv_source_spec.rb'
115
115
  - 'spec/lib/evva/kotlin_generator_spec.rb'
116
116
  - 'spec/lib/evva/object_extension_spec.rb'
117
117
  - 'spec/lib/evva/swift_generator_spec.rb'
@@ -128,7 +128,7 @@ Lint/AmbiguousBlockAssociation:
128
128
  Lint/AmbiguousRegexpLiteral:
129
129
  Exclude:
130
130
  - 'spec/lib/evva/config_spec.rb'
131
- - 'spec/lib/evva/google_sheet_spec.rb'
131
+ - 'spec/lib/evva/csv_source_spec.rb'
132
132
  - 'spec/lib/evva/object_extension_spec.rb'
133
133
 
134
134
  # Offense count: 3
@@ -257,12 +257,12 @@ Style/HashSyntax:
257
257
  - 'spec/evva_spec.rb'
258
258
  - 'spec/platform_filter_spec.rb'
259
259
  - 'lib/evva/config.rb'
260
- - 'lib/evva/google_sheet.rb'
260
+ - 'lib/evva/csv_source.rb'
261
261
  - 'lib/evva/kotlin_generator.rb'
262
262
  - 'lib/evva/logger.rb'
263
263
  - 'lib/evva/swift_generator.rb'
264
264
  - 'spec/lib/evva/config_spec.rb'
265
- - 'spec/lib/evva/google_sheet_spec.rb'
265
+ - 'spec/lib/evva/csv_source_spec.rb'
266
266
  - 'spec/lib/evva/kotlin_generator_spec.rb'
267
267
  - 'spec/lib/evva/object_extension_spec.rb'
268
268
  - 'spec/lib/evva/swift_generator_spec.rb'
@@ -288,7 +288,7 @@ Style/ModuleFunction:
288
288
  # SupportedStyles: literals, strict
289
289
  Style/MutableConstant:
290
290
  Exclude:
291
- - 'lib/evva/google_sheet.rb'
291
+ - 'lib/evva/csv_source.rb'
292
292
  - 'lib/evva/kotlin_generator.rb'
293
293
  - 'lib/evva/swift_generator.rb'
294
294
 
@@ -363,7 +363,7 @@ Style/SymbolProc:
363
363
  Style/TrailingCommaInArrayLiteral:
364
364
  Exclude:
365
365
  - 'spec/evva_spec.rb'
366
- - 'spec/lib/evva/google_sheet_spec.rb'
366
+ - 'spec/lib/evva/csv_source_spec.rb'
367
367
  - 'spec/lib/evva/kotlin_generator_spec.rb'
368
368
  - 'spec/lib/evva/swift_generator_spec.rb'
369
369
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- evva (0.12.0)
4
+ evva (0.13.0)
5
5
  colorize (~> 1.0)
6
6
  csv (~> 3.0)
7
7
  safe_yaml (~> 1.0)
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.9.0)
12
+ addressable (2.9.1)
13
13
  public_suffix (>= 2.0.2, < 8.0)
14
14
  ast (2.4.3)
15
15
  bigdecimal (3.3.1)
@@ -77,7 +77,7 @@ GEM
77
77
  simplecov_json_formatter (0.1.4)
78
78
  unicode-display_width (3.2.0)
79
79
  unicode-emoji (~> 4.1)
80
- unicode-emoji (4.1.0)
80
+ unicode-emoji (4.3.0)
81
81
  webmock (3.25.1)
82
82
  addressable (>= 2.8.0)
83
83
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -4,7 +4,7 @@ Evva
4
4
  [![Status](https://travis-ci.org/hole19/evva.svg?branch=master)](https://travis-ci.org/hole19/evva?branch=master)
5
5
  [![Gem](https://img.shields.io/gem/v/evva.svg?style=flat)](http://rubygems.org/gems/evva "View this project in Rubygems")
6
6
 
7
- Evva automatically generates code for triggering events based on a Google Sheets specification. It generates code for both Swift (iOS) and Kotlin (Android).
7
+ Evva automatically generates code for triggering events based on a CSV specification, such as a Google Sheets CSV export or an Evva Hub export. It generates code for both Swift (iOS) and Kotlin (Android).
8
8
 
9
9
  # Instalation
10
10
 
@@ -23,10 +23,10 @@ Evva automatically generates code for triggering events based on a Google Sheets
23
23
  type: Android|iOS
24
24
 
25
25
  data_source:
26
- type: google_sheet
27
- events_url: <GOOGLE-DRIVE-EVENTS-SHEET-URL>
28
- people_properties_url: <GOOGLE-DRIVE-PEOPLE-PROPERTIES-SHEET-URL>
29
- enum_classes_url: <GOOGLE-DRIVE-ENUM-CLASSES-SHEET-URL>
26
+ type: csv
27
+ events_url: <EVENTS-CSV-URL>
28
+ people_properties_url: <PEOPLE-PROPERTIES-CSV-URL>
29
+ enum_classes_url: <ENUM-CLASSES-CSV-URL>
30
30
 
31
31
  out_path: /folder/where/analytics/classes/are
32
32
  event_file_name: /file/with/tracking/functions
@@ -40,6 +40,10 @@ Evva automatically generates code for triggering events based on a Google Sheets
40
40
  - ios
41
41
  ```
42
42
 
43
+ `data_source.type: csv` reads each URL as a CSV with a header row. Google Sheets
44
+ (File → Share → Publish to web → CSV) and Evva Hub exports both produce it.
45
+ `google_sheet` is the former name of `csv` and is still accepted.
46
+
43
47
  ## The events sheet
44
48
 
45
49
  The events sheet is read by column header, so column order does not matter and
@@ -66,15 +70,19 @@ Evva automatically generates code for triggering events based on a Google Sheets
66
70
 
67
71
  Blank lines, trailing commas and spaces around items or around `:` are ignored.
68
72
 
69
- Multi-line cells need evva 0.12.0 or newer. Older versions read the whole cell as
70
- a single broken property, so only convert rows once every app generating from
71
- the sheet has been updated.
72
-
73
73
  ### Destinations
74
74
 
75
75
  `Event Destination` (and `Property Destination` in the people properties sheet)
76
- accepts the same separators, and spaces around each destination are ignored, so
77
- the cell can be a multi-select dropdown, which writes values as `mixpanel, braze`.
76
+ accepts the same separators, and spaces around each destination are ignored.
77
+ A multi-select dropdown works too: Google's CSV export joins its values with a
78
+ plain comma (`mixpanel,braze`).
79
+
80
+ ### Enum values
81
+
82
+ `Possible Values` in the enum classes sheet accepts the same separators: commas,
83
+ one value per line, or both. Spaces around each value are ignored, spaces inside a
84
+ value (`main app`) are kept. Each value is the exact string sent to analytics.
85
+ An enum with no values stops the run with an error naming it.
78
86
 
79
87
  ### Platform
80
88
 
data/changelog.md CHANGED
@@ -2,9 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.13.0] - 2026-11-19
6
+
7
+ - `data_source.type` is now `csv`, the format both Google Sheets and Evva Hub exports produce. `google_sheet` is still accepted, and `Evva::GoogleSheet` remains as an alias of the renamed `Evva::CsvSource`
8
+ - Tested on Ruby 4.0 in CI. The development lockfile moves `unicode-emoji` to 4.3.0, since 4.1.0 doesn't install on Ruby 4
9
+
10
+ ## [0.12.1] - 2026-11-17
11
+
12
+ - Enum `Possible Values` accept the same separators as `Event Properties` (commas and/or one value per line) and trim spaces around each value; an enum with no values stops the run with an error naming it
13
+
5
14
  ## [0.12.0] - 2026-11-11
6
15
 
7
- - `Event Properties` can be written one property per line (and mixed with commas); `Event Destination` and `Property Destination` trim spaces around each destination, so a multi-select dropdown (`mixpanel, braze`) works
16
+ - `Event Properties` can be written one property per line (and mixed with commas); `Event Destination` and `Property Destination` accept the same separators and trim spaces around each destination
8
17
 
9
18
  ## [0.11.0] - 2026-11-09
10
19
 
data/lib/evva/config.rb CHANGED
@@ -92,7 +92,7 @@ module Evva
92
92
  }
93
93
  }.freeze
94
94
 
95
- GOOGLE_SHEET_STRUCT = {
95
+ CSV_STRUCT = {
96
96
  type: Hash,
97
97
  elements: {
98
98
  type: { type: String },
@@ -103,7 +103,9 @@ module Evva
103
103
  }.freeze
104
104
 
105
105
  DICTIONARY_STRUCT = {
106
- "google_sheet" => GOOGLE_SHEET_STRUCT
106
+ "csv" => CSV_STRUCT,
107
+ # Former name of "csv", still accepted so existing configs keep working.
108
+ "google_sheet" => CSV_STRUCT
107
109
  }.freeze
108
110
  end
109
111
  end
@@ -0,0 +1,155 @@
1
+ require "net/https"
2
+ require "csv"
3
+
4
+ module Evva
5
+ # Reads the analytics dictionary from CSV files fetched over HTTP. Both the
6
+ # Google Sheets CSV export and the Evva Hub export produce this format.
7
+ class CsvSource
8
+ EVENT_NAME = "Event Name"
9
+ EVENT_PROPERTIES = "Event Properties"
10
+ EVENT_DESTINATION = "Event Destination"
11
+ EVENT_PLATFORM = "Platform"
12
+
13
+ PROPERTY_NAME = "Property Name"
14
+ PROPERTY_TYPE = "Property Type"
15
+ PROPERTY_DESTINATION = "Property Destination"
16
+
17
+ ENUM_NAME = "Enum Name"
18
+ ENUM_VALUES = "Possible Values"
19
+
20
+ def initialize(events_url, people_properties_url, enum_classes_url)
21
+ @events_url = events_url
22
+ @people_properties_url = people_properties_url
23
+ @enum_classes_url = enum_classes_url
24
+ end
25
+
26
+ def events
27
+ @events_csv ||= begin
28
+ Logger.info("Downloading events sheet from #{redact(@events_url)}")
29
+ get_csv(@events_url)
30
+ end
31
+
32
+ @events ||= begin
33
+ platform_header = header_matching(@events_csv, EVENT_PLATFORM)
34
+ Logger.info("No #{EVENT_PLATFORM} column in the events sheet, every event will be generated for every platform") if platform_header.nil?
35
+
36
+ @events_csv.map do |row|
37
+ event_name = row[EVENT_NAME]
38
+ properties = hash_parser(row[EVENT_PROPERTIES])
39
+ destinations = list_parser(row[EVENT_DESTINATION])
40
+ platforms = platform_parser(platform_header && row[platform_header])
41
+ Evva::AnalyticsEvent.new(event_name, properties, destinations, platforms)
42
+ end
43
+ end
44
+ end
45
+
46
+ def people_properties
47
+ @people_properties_csv ||= begin
48
+ Logger.info("Downloading people properties sheet from #{redact(@people_properties_url)}")
49
+ get_csv(@people_properties_url)
50
+ end
51
+
52
+ @people_properties ||= @people_properties_csv.map do |row|
53
+ property_name = row[PROPERTY_NAME]
54
+ property_type = row[PROPERTY_TYPE]
55
+ destinations = list_parser(row[PROPERTY_DESTINATION])
56
+ Evva::AnalyticsProperty.new(property_name, property_type, destinations)
57
+ end
58
+ end
59
+
60
+ def enum_classes
61
+ @enum_classes_csv ||= begin
62
+ Logger.info("Downloading enums sheet from #{redact(@enum_classes_url)}")
63
+ get_csv(@enum_classes_url)
64
+ end
65
+
66
+ @enum_classes ||= @enum_classes_csv.map do |row|
67
+ enum_name = row[ENUM_NAME]
68
+ values = list_parser(row[ENUM_VALUES])
69
+ # An enum with no cases is not valid Swift with a String raw type.
70
+ raise "Enum #{enum_name} has no #{ENUM_VALUES}" if values.empty?
71
+
72
+ Evva::AnalyticsEnum.new(enum_name, values)
73
+ end
74
+ end
75
+
76
+ def destinations
77
+ @destinations ||= events.map(&:destinations).flatten.uniq
78
+ end
79
+
80
+ private
81
+
82
+ # Sheet URLs can carry an auth token in the query string or userinfo, so
83
+ # only scheme, host and path are ever printed.
84
+ def redact(url)
85
+ uri = URI(url.to_s)
86
+ "#{uri.scheme}://#{uri.host}#{uri.path}"
87
+ rescue URI::InvalidURIError
88
+ "<invalid url>"
89
+ end
90
+
91
+ def get_csv(url)
92
+ data = get(url)
93
+
94
+ begin
95
+ CSV.parse(data, headers: true)
96
+ rescue StandardError => e
97
+ raise "Cannot parse. Expected CSV at #{redact(url)}: #{e}"
98
+ end
99
+ end
100
+
101
+ def get(url, max_redirects = 1)
102
+ raise "Too may redirects" if max_redirects == -1
103
+
104
+ uri = URI(url)
105
+
106
+ http = Net::HTTP.new(uri.host, uri.port)
107
+ http.use_ssl = true
108
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
109
+
110
+ request = Net::HTTP::Get.new(uri.request_uri)
111
+ response = http.request(request)
112
+
113
+ return get(response["location"], max_redirects - 1) if response.is_a? Net::HTTPRedirection
114
+
115
+ raise "Http Error #{response.body}" if response.code.to_i >= 400
116
+
117
+ response.body
118
+ end
119
+
120
+ # Matched ignoring case and surrounding whitespace, because a header of
121
+ # "platform" or "Platform " means what it plainly means.
122
+ def header_matching(csv, name)
123
+ csv.headers.compact.find { |header| header.to_s.strip.casecmp?(name) }
124
+ end
125
+
126
+ # nil (no Platform column or empty cell) means unrestricted (never filtered out).
127
+ # Concrete platform tokens are stored lowercased and deduplicated.
128
+ def platform_parser(platform_list)
129
+ tokens = platform_list.to_s.split(",").map(&:strip).reject(&:empty?)
130
+ return nil if tokens.empty?
131
+
132
+ tokens.map(&:downcase).uniq
133
+ end
134
+
135
+ # Items may be separated by commas, line breaks, or both, so a long list can
136
+ # be written one item per line in the cell.
137
+ def list_parser(list)
138
+ list.to_s.split(/,|\r\n|\r|\n/).map(&:strip).reject(&:empty?)
139
+ end
140
+
141
+ def hash_parser(property_array)
142
+ h = {}
143
+ list_parser(property_array).each do |prop|
144
+ split_prop = prop.split(":")
145
+ prop_name = split_prop[0].strip.to_sym
146
+ prop_type = split_prop[1].to_s.strip
147
+ h[prop_name] = prop_type
148
+ end
149
+ h
150
+ end
151
+ end
152
+
153
+ # Kept so code that referenced the old name still loads.
154
+ GoogleSheet = CsvSource
155
+ end
@@ -1,139 +1,3 @@
1
- require "net/https"
2
- require "csv"
3
-
4
- module Evva
5
- class GoogleSheet
6
- EVENT_NAME = "Event Name"
7
- EVENT_PROPERTIES = "Event Properties"
8
- EVENT_DESTINATION = "Event Destination"
9
- EVENT_PLATFORM = "Platform"
10
-
11
- PROPERTY_NAME = "Property Name"
12
- PROPERTY_TYPE = "Property Type"
13
- PROPERTY_DESTINATION = "Property Destination"
14
-
15
- ENUM_NAME = "Enum Name"
16
- ENUM_VALUES = "Possible Values"
17
-
18
- def initialize(events_url, people_properties_url, enum_classes_url)
19
- @events_url = events_url
20
- @people_properties_url = people_properties_url
21
- @enum_classes_url = enum_classes_url
22
- end
23
-
24
- def events
25
- @events_csv ||= begin
26
- Logger.info("Downloading data from Google Sheet at #{@events_url}")
27
- get_csv(@events_url)
28
- end
29
-
30
- @events ||= begin
31
- platform_header = header_matching(@events_csv, EVENT_PLATFORM)
32
- Logger.info("No #{EVENT_PLATFORM} column in the events sheet, every event will be generated for every platform") if platform_header.nil?
33
-
34
- @events_csv.map do |row|
35
- event_name = row[EVENT_NAME]
36
- properties = hash_parser(row[EVENT_PROPERTIES])
37
- destinations = list_parser(row[EVENT_DESTINATION])
38
- platforms = platform_parser(platform_header && row[platform_header])
39
- Evva::AnalyticsEvent.new(event_name, properties, destinations, platforms)
40
- end
41
- end
42
- end
43
-
44
- def people_properties
45
- @people_properties_csv ||= begin
46
- Logger.info("Downloading data from Google Sheet at #{@people_properties_url}")
47
- get_csv(@people_properties_url)
48
- end
49
-
50
- @people_properties ||= @people_properties_csv.map do |row|
51
- property_name = row[PROPERTY_NAME]
52
- property_type = row[PROPERTY_TYPE]
53
- destinations = list_parser(row[PROPERTY_DESTINATION])
54
- Evva::AnalyticsProperty.new(property_name, property_type, destinations)
55
- end
56
- end
57
-
58
- def enum_classes
59
- @enum_classes_csv ||= begin
60
- Logger.info("Downloading data from Google Sheet at #{@enum_classes_url}")
61
- get_csv(@enum_classes_url)
62
- end
63
-
64
- @enum_classes ||= @enum_classes_csv.map do |row|
65
- enum_name = row[ENUM_NAME]
66
- values = row[ENUM_VALUES].split(",")
67
- Evva::AnalyticsEnum.new(enum_name, values)
68
- end
69
- end
70
-
71
- def destinations
72
- @destinations ||= events.map(&:destinations).flatten.uniq
73
- end
74
-
75
- private
76
-
77
- def get_csv(url)
78
- data = get(url)
79
-
80
- begin
81
- CSV.parse(data, headers: true)
82
- rescue StandardError => e
83
- raise "Cannot parse. Expected CSV at #{url}: #{e}"
84
- end
85
- end
86
-
87
- def get(url, max_redirects = 1)
88
- raise "Too may redirects" if max_redirects == -1
89
-
90
- uri = URI(url)
91
-
92
- http = Net::HTTP.new(uri.host, uri.port)
93
- http.use_ssl = true
94
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
95
-
96
- request = Net::HTTP::Get.new(uri.request_uri)
97
- response = http.request(request)
98
-
99
- return get(response["location"], max_redirects - 1) if response.is_a? Net::HTTPRedirection
100
-
101
- raise "Http Error #{response.body}" if response.code.to_i >= 400
102
-
103
- response.body
104
- end
105
-
106
- # Matched ignoring case and surrounding whitespace, because a header of
107
- # "platform" or "Platform " means what it plainly means.
108
- def header_matching(csv, name)
109
- csv.headers.compact.find { |header| header.to_s.strip.casecmp?(name) }
110
- end
111
-
112
- # nil (no Platform column or empty cell) means unrestricted (never filtered out).
113
- # Concrete platform tokens are stored lowercased and deduplicated.
114
- def platform_parser(platform_list)
115
- tokens = platform_list.to_s.split(",").map(&:strip).reject(&:empty?)
116
- return nil if tokens.empty?
117
-
118
- tokens.map(&:downcase).uniq
119
- end
120
-
121
- # Items may be separated by commas, line breaks, or both, so a long list can
122
- # be written one item per line in the cell. A multi-select dropdown joins its
123
- # values with ", ", hence the strip.
124
- def list_parser(list)
125
- list.to_s.split(/,|\r\n|\r|\n/).map(&:strip).reject(&:empty?)
126
- end
127
-
128
- def hash_parser(property_array)
129
- h = {}
130
- list_parser(property_array).each do |prop|
131
- split_prop = prop.split(":")
132
- prop_name = split_prop[0].strip.to_sym
133
- prop_type = split_prop[1].to_s.strip
134
- h[prop_name] = prop_type
135
- end
136
- h
137
- end
138
- end
139
- end
1
+ # Former location of Evva::CsvSource, kept so `require "evva/google_sheet"`
2
+ # still loads. Evva::GoogleSheet is defined as an alias in csv_source.rb.
3
+ require "evva/csv_source"
data/lib/evva/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Evva
2
- VERSION = "0.12.0".freeze
3
- VERSION_UPDATED_AT = "2026-11-11".freeze
2
+ VERSION = "0.13.0".freeze
3
+ VERSION_UPDATED_AT = "2026-11-19".freeze
4
4
  end
data/lib/evva.rb CHANGED
@@ -2,7 +2,7 @@ require "optparse"
2
2
  require "yaml"
3
3
 
4
4
  require "evva/logger"
5
- require "evva/google_sheet"
5
+ require "evva/csv_source"
6
6
  require "evva/config"
7
7
  require "evva/file_reader"
8
8
  require "evva/analytics_event"
@@ -65,8 +65,8 @@ module Evva
65
65
  def analytics_data(config:)
66
66
  source =
67
67
  case config[:type]
68
- when "google_sheet"
69
- Evva::GoogleSheet.new(config[:events_url], config[:people_properties_url], config[:enum_classes_url])
68
+ when "csv", "google_sheet"
69
+ Evva::CsvSource.new(config[:events_url], config[:people_properties_url], config[:enum_classes_url])
70
70
  end
71
71
  events_bundle = {}
72
72
  events_bundle[:events] = source.events
data/spec/evva_spec.rb CHANGED
@@ -6,10 +6,10 @@ describe Evva do
6
6
 
7
7
  before do
8
8
  allow_any_instance_of(Evva::FileReader).to receive(:open_file).and_return(file)
9
- allow_any_instance_of(Evva::GoogleSheet).to receive(:events).and_return([])
10
- allow_any_instance_of(Evva::GoogleSheet).to receive(:people_properties).and_return([])
11
- allow_any_instance_of(Evva::GoogleSheet).to receive(:enum_classes).and_return([])
12
- allow_any_instance_of(Evva::GoogleSheet).to receive(:destinations).and_return([])
9
+ allow_any_instance_of(Evva::CsvSource).to receive(:events).and_return([])
10
+ allow_any_instance_of(Evva::CsvSource).to receive(:people_properties).and_return([])
11
+ allow_any_instance_of(Evva::CsvSource).to receive(:enum_classes).and_return([])
12
+ allow_any_instance_of(Evva::CsvSource).to receive(:destinations).and_return([])
13
13
  allow(Evva).to receive(:write_to_file)
14
14
  end
15
15
 
@@ -0,0 +1,10 @@
1
+ Enum Name,Possible Values
2
+ PageViewSourceScreen,"course_discovery
3
+ synced_courses,
4
+ nearby
5
+
6
+ deal
7
+ "
8
+ PremiumClickBuy,"notes
9
+ hi_res_maps
10
+ whatever"
@@ -1,7 +1,7 @@
1
1
  type: Android
2
2
 
3
3
  data_source:
4
- type: google_sheet
4
+ type: csv
5
5
  events_url: https://path-to-csv
6
6
  people_properties_url: https://path-to-csv
7
7
  enum_classes_url: https://path-to-csv
@@ -5,7 +5,7 @@ describe Evva::Config do
5
5
  {
6
6
  type: "EvvaOS",
7
7
  data_source: {
8
- type: "google_sheet",
8
+ type: "csv",
9
9
  events_url: "https://events.csv",
10
10
  people_properties_url: "https://people_properties.csv",
11
11
  enum_classes_url: "https://enum_classes.csv",
@@ -39,7 +39,12 @@ describe Evva::Config do
39
39
  describe "#data_source" do
40
40
  subject(:data_source) { config.data_source }
41
41
 
42
- it { should eq(type: "google_sheet", events_url: "https://events.csv", people_properties_url: "https://people_properties.csv", enum_classes_url: "https://enum_classes.csv") }
42
+ it { should eq(type: "csv", events_url: "https://events.csv", people_properties_url: "https://people_properties.csv", enum_classes_url: "https://enum_classes.csv") }
43
+
44
+ context "when given the legacy google_sheet type" do
45
+ before { hash[:data_source][:type] = "google_sheet" }
46
+ it { should include(type: "google_sheet", events_url: "https://events.csv") }
47
+ end
43
48
 
44
49
  context "when given an unknown type data source" do
45
50
  before { hash[:data_source] = { type: "i_dunno" } }
@@ -1,5 +1,7 @@
1
- describe Evva::GoogleSheet do
2
- let(:sheet) { Evva::GoogleSheet.new(events_sheet, people_sheet, enum_sheet) }
1
+ require "open3"
2
+
3
+ describe Evva::CsvSource do
4
+ let(:sheet) { Evva::CsvSource.new(events_sheet, people_sheet, enum_sheet) }
3
5
 
4
6
  let(:events_sheet) { "https://wtvr1" }
5
7
  let(:people_sheet) { "https://wtvr2" }
@@ -14,6 +16,37 @@ describe Evva::GoogleSheet do
14
16
  stub_request(:get, enum_sheet).to_return(status: 200, body: enum_file, headers: {})
15
17
  end
16
18
 
19
+ describe "auth token in sheet URLs" do
20
+ let(:events_sheet) { "https://example.com/export/events.csv?token=evv_secret" }
21
+ let(:people_sheet) { "https://example.com/export/people.csv?token=evv_secret" }
22
+ let(:enum_sheet) { "https://example.com/export/enums.csv?token=evv_secret" }
23
+ let(:logged) { [] }
24
+
25
+ before do
26
+ allow(Evva::Logger).to receive(:info) { |msg| logged << msg }
27
+ end
28
+
29
+ it "does not log the token or credentials when downloading" do
30
+ sheet.events
31
+ sheet.people_properties
32
+ sheet.enum_classes
33
+
34
+ expect(logged).to include("Downloading events sheet from https://example.com/export/events.csv")
35
+ expect(logged.join("\n")).not_to match(/evv_secret|token=/)
36
+ end
37
+
38
+ context "when the response is not valid CSV" do
39
+ let(:events_file) { "\"unterminated" }
40
+
41
+ it "does not include the token in the error" do
42
+ expect { sheet.events }.to raise_error(RuntimeError) { |e|
43
+ expect(e.message).to include("https://example.com/export/events.csv")
44
+ expect(e.message).not_to match(/evv_secret|token=/)
45
+ }
46
+ end
47
+ end
48
+ end
49
+
17
50
  describe "#events" do
18
51
  subject(:events) { sheet.events }
19
52
 
@@ -35,7 +68,7 @@ describe Evva::GoogleSheet do
35
68
  let(:events_file) { File.read("spec/fixtures/sample_public_events_multiline.csv") }
36
69
 
37
70
  it "reads each multi-line cell as one field and parses it like the comma separated sheet" do
38
- comma_separated = Evva::GoogleSheet.new(events_sheet, people_sheet, enum_sheet)
71
+ comma_separated = Evva::CsvSource.new(events_sheet, people_sheet, enum_sheet)
39
72
  stub_request(:get, events_sheet).to_return(status: 200, body: File.read("spec/fixtures/sample_public_events.csv"))
40
73
  expected = comma_separated.events
41
74
 
@@ -71,7 +104,7 @@ describe Evva::GoogleSheet do
71
104
 
72
105
  {
73
106
  "comma separated" => "mixpanel,braze",
74
- "as a multi-select dropdown (comma and space)" => "mixpanel, braze",
107
+ "with a space after each comma" => "mixpanel, braze",
75
108
  "one per line" => "mixpanel\nbraze",
76
109
  "a trailing comma" => "mixpanel,braze,",
77
110
  }.each do |description, cell|
@@ -233,10 +266,10 @@ describe Evva::GoogleSheet do
233
266
  end
234
267
  end
235
268
 
236
- describe "#people_properties with a multi-select destination dropdown" do
237
- let(:people_file) { File.read("spec/fixtures/sample_public_people_properties_multiselect.csv") }
269
+ describe "#people_properties with spaces in the destination cell" do
270
+ let(:people_file) { File.read("spec/fixtures/sample_public_people_properties_spaced.csv") }
238
271
 
239
- it "trims the space the dropdown puts after each comma" do
272
+ it "trims the space after each comma" do
240
273
  expect(sheet.people_properties.first.destinations).to eq(["firebase", "custom destination"])
241
274
  end
242
275
  end
@@ -254,6 +287,58 @@ describe Evva::GoogleSheet do
254
287
  Evva::AnalyticsEnum.new("PremiumClickBuy", ["notes","hi_res_maps","whatever"])
255
288
  ]
256
289
  end
290
+
291
+ context "when values are written one per line, as exported by Google Sheets" do
292
+ let(:enum_file) { File.read("spec/fixtures/sample_public_enums_multiline.csv") }
293
+
294
+ it "parses the same values as the comma separated sheet" do
295
+ expect(enum_classes.map(&:values)).to eq [
296
+ ["course_discovery", "synced_courses", "nearby", "deal"],
297
+ ["notes", "hi_res_maps", "whatever"],
298
+ ]
299
+ end
300
+ end
301
+
302
+ describe "a Possible Values cell" do
303
+ let(:enum_file) { %(Enum Name,Possible Values\nSomeEnum,"#{values}"\n) }
304
+
305
+ {
306
+ "comma separated" => "a,b",
307
+ "one per line" => "a\nb",
308
+ "one per line with CRLF" => "a\r\nb",
309
+ "mixed commas and line breaks" => "a,\nb",
310
+ "a trailing comma" => "a,b,",
311
+ "a trailing line break" => "a\nb\n",
312
+ "blank lines between values" => "a\n\nb",
313
+ "spaces around separators" => " a ,\n b ",
314
+ }.each do |description, cell|
315
+ context "written #{description}" do
316
+ let(:values) { cell }
317
+
318
+ it "parses the same values" do
319
+ expect(enum_classes.first.values).to eq(["a", "b"])
320
+ end
321
+ end
322
+ end
323
+
324
+ context "with spaces inside a value" do
325
+ let(:values) { "main app,No Scoring" }
326
+
327
+ it "keeps them" do
328
+ expect(enum_classes.first.values).to eq(["main app", "No Scoring"])
329
+ end
330
+ end
331
+
332
+ ["", ",", "\n\n", " , "].each do |cell|
333
+ context "with no values (#{cell.inspect})" do
334
+ let(:values) { cell }
335
+
336
+ it "stops with an error naming the enum, instead of generating an enum Swift cannot compile" do
337
+ expect { enum_classes }.to raise_error("Enum SomeEnum has no Possible Values")
338
+ end
339
+ end
340
+ end
341
+ end
257
342
  end
258
343
 
259
344
  describe "#destinations" do
@@ -271,3 +356,32 @@ describe Evva::GoogleSheet do
271
356
  end
272
357
  end
273
358
  end
359
+
360
+ describe "CSV data source compatibility" do
361
+ let(:urls) { { events_url: "https://wtvr1", people_properties_url: "https://wtvr2", enum_classes_url: "https://wtvr3" } }
362
+
363
+ before do
364
+ stub_request(:get, urls[:events_url]).to_return(status: 200, body: File.read("spec/fixtures/sample_public_events.csv"))
365
+ stub_request(:get, urls[:people_properties_url]).to_return(status: 200, body: File.read("spec/fixtures/sample_public_people_properties.csv"))
366
+ stub_request(:get, urls[:enum_classes_url]).to_return(status: 200, body: File.read("spec/fixtures/sample_public_enums.csv"))
367
+ end
368
+
369
+ it "keeps Evva::GoogleSheet as an alias of Evva::CsvSource" do
370
+ expect(Evva::GoogleSheet).to equal(Evva::CsvSource)
371
+ end
372
+
373
+ # Run in a fresh process so nothing the suite already loaded can hide a
374
+ # missing file.
375
+ it "still loads through the former require path" do
376
+ script = 'require "evva/google_sheet"; exit(Evva::GoogleSheet.equal?(Evva::CsvSource) ? 0 : 1)'
377
+ output, status = Open3.capture2e(RbConfig.ruby, "-Ilib", "-e", script)
378
+ expect(status).to be_success, output
379
+ end
380
+
381
+ it "reads the same data for the legacy 'google_sheet' type as for 'csv'" do
382
+ csv = Evva.analytics_data(config: urls.merge(type: "csv"))
383
+ legacy = Evva.analytics_data(config: urls.merge(type: "google_sheet"))
384
+ expect(legacy[:events]).to eq(csv[:events])
385
+ expect(csv[:events]).not_to be_empty
386
+ end
387
+ end
@@ -18,7 +18,7 @@ describe "filtering by platform end to end" do
18
18
 
19
19
  def unfiltered_bundle
20
20
  source = {
21
- type: "google_sheet",
21
+ type: "csv",
22
22
  events_url: events_url,
23
23
  people_properties_url: people_url,
24
24
  enum_classes_url: enum_url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evva
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Andrade
@@ -9,7 +9,7 @@ authors:
9
9
  - Ricardo Trindade
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-11-11 00:00:00.000000000 Z
12
+ date: 2026-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -77,6 +77,7 @@ files:
77
77
  - lib/evva/analytics_event.rb
78
78
  - lib/evva/analytics_property.rb
79
79
  - lib/evva/config.rb
80
+ - lib/evva/csv_source.rb
80
81
  - lib/evva/file_reader.rb
81
82
  - lib/evva/google_sheet.rb
82
83
  - lib/evva/kotlin_generator.rb
@@ -98,15 +99,16 @@ files:
98
99
  - lib/evva/version.rb
99
100
  - spec/evva_spec.rb
100
101
  - spec/fixtures/sample_public_enums.csv
102
+ - spec/fixtures/sample_public_enums_multiline.csv
101
103
  - spec/fixtures/sample_public_enums_with_platform.csv
102
104
  - spec/fixtures/sample_public_events.csv
103
105
  - spec/fixtures/sample_public_events_multiline.csv
104
106
  - spec/fixtures/sample_public_events_with_platform.csv
105
107
  - spec/fixtures/sample_public_people_properties.csv
106
- - spec/fixtures/sample_public_people_properties_multiselect.csv
108
+ - spec/fixtures/sample_public_people_properties_spaced.csv
107
109
  - spec/fixtures/test.yml
108
110
  - spec/lib/evva/config_spec.rb
109
- - spec/lib/evva/google_sheet_spec.rb
111
+ - spec/lib/evva/csv_source_spec.rb
110
112
  - spec/lib/evva/kotlin_generator_spec.rb
111
113
  - spec/lib/evva/logger_spec.rb
112
114
  - spec/lib/evva/object_extension_spec.rb