evva 0.6.0 → 0.8.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 +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +2 -1
- data/changelog.md +8 -0
- data/lib/evva/config.rb +16 -1
- data/lib/evva/swift_generator.rb +4 -0
- data/lib/evva/templates/swift/base.swift +1 -1
- data/lib/evva/templates/swift/destinations.swift +1 -1
- data/lib/evva/templates/swift/events.swift +2 -2
- data/lib/evva/templates/swift/people_properties.swift +2 -2
- data/lib/evva/version.rb +2 -2
- data/lib/evva.rb +10 -1
- data/spec/evva_spec.rb +34 -0
- data/spec/lib/evva/config_spec.rb +39 -0
- data/spec/lib/evva/swift_generator_spec.rb +21 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 285fa85e8d2a969dadead5a4bfd94bb021a88ed3ff535feaa6b77cba9af4c9dc
|
|
4
|
+
data.tar.gz: 4da0378727c38003b4dde074b8f50e6e9bc5203632eebbe47872e88ebb47d993
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4442aea2c03bd25decf75970b860561a4efd5217c0f2fcafadf43bef1e508747ce159c178566a4ba4662f7799edeb21bbe2385788d2c05ac8a33e9d001eda3fc
|
|
7
|
+
data.tar.gz: 1a8a8bf25a185da286ca30c29c6eaf5619849cbd60e777f489ba8e33c029be783a30c17286f3c31e9f3aabde2b4efbcc6342dfc8ac708985889c5285b40f2186
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
evva (0.
|
|
4
|
+
evva (0.7.0)
|
|
5
5
|
colorize (~> 1.0)
|
|
6
6
|
csv (>= 3.0)
|
|
7
7
|
safe_yaml (~> 1.0)
|
|
@@ -9,8 +9,8 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
addressable (2.
|
|
13
|
-
public_suffix (>= 2.0.2, <
|
|
12
|
+
addressable (2.9.0)
|
|
13
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
14
14
|
ast (2.4.3)
|
|
15
15
|
bigdecimal (3.3.1)
|
|
16
16
|
colorize (1.1.0)
|
|
@@ -21,7 +21,7 @@ GEM
|
|
|
21
21
|
diff-lcs (1.6.2)
|
|
22
22
|
docile (1.4.1)
|
|
23
23
|
hashdiff (1.2.1)
|
|
24
|
-
json (2.15.1)
|
|
24
|
+
json (2.15.2.1)
|
|
25
25
|
language_server-protocol (3.17.0.5)
|
|
26
26
|
lint_roller (1.1.0)
|
|
27
27
|
parallel (1.27.0)
|
|
@@ -29,7 +29,7 @@ GEM
|
|
|
29
29
|
ast (~> 2.4.1)
|
|
30
30
|
racc
|
|
31
31
|
prism (1.5.2)
|
|
32
|
-
public_suffix (
|
|
32
|
+
public_suffix (7.0.5)
|
|
33
33
|
racc (1.8.1)
|
|
34
34
|
rainbow (3.1.1)
|
|
35
35
|
rake (13.3.0)
|
data/README.md
CHANGED
|
@@ -32,7 +32,8 @@ Evva automatically generates code for triggering events based on a Google Sheets
|
|
|
32
32
|
event_file_name: /file/with/tracking/functions
|
|
33
33
|
event_enum_file_name: /file/with/event/names
|
|
34
34
|
people_file_name: /file/with/people/properties
|
|
35
|
-
|
|
35
|
+
people_enum_file_name: /file/with/people/property/names
|
|
36
36
|
destinations_file_name: /file/with/destinations
|
|
37
37
|
special_enum_file_name: /file/with/special/enum/properties/
|
|
38
|
+
swift_public: false # optional; when true (iOS), generated Swift uses the public access modifier for generated extensions
|
|
38
39
|
```
|
data/changelog.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## [0.8.0] - 2026-05-26
|
|
6
|
+
|
|
7
|
+
- Add `exclude_destinations` configuration to filter out specific destinations from generated code
|
|
8
|
+
|
|
9
|
+
## [0.7.0] - 2026-04-07
|
|
10
|
+
|
|
11
|
+
- Add `swift_public` configuration which modifies the accessibility of all the Swift code extensions to `public`
|
|
12
|
+
|
|
5
13
|
## [0.6.0] - 2025-10-13
|
|
6
14
|
|
|
7
15
|
- Add support for ruby 3.4
|
data/lib/evva/config.rb
CHANGED
|
@@ -9,6 +9,11 @@ module Evva
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
@hash[:data_source].validate_structure!(dict_struct)
|
|
12
|
+
|
|
13
|
+
if @hash.key?(:swift_public) && ![true, false].include?(@hash[:swift_public])
|
|
14
|
+
raise ArgumentError, "swift_public must be true or false"
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
end
|
|
13
18
|
|
|
14
19
|
def to_h
|
|
@@ -55,6 +60,14 @@ module Evva
|
|
|
55
60
|
@hash[:package_name]
|
|
56
61
|
end
|
|
57
62
|
|
|
63
|
+
def swift_public?
|
|
64
|
+
@hash[:swift_public] == true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def exclude_destinations
|
|
68
|
+
@hash[:exclude_destinations] || []
|
|
69
|
+
end
|
|
70
|
+
|
|
58
71
|
CONFIG_STRUCT = {
|
|
59
72
|
type: Hash,
|
|
60
73
|
elements: {
|
|
@@ -68,7 +81,9 @@ module Evva
|
|
|
68
81
|
people_file_name: { type: String },
|
|
69
82
|
people_enum_file_name: { type: String },
|
|
70
83
|
destinations_file_name: { type: String },
|
|
71
|
-
package_name: { type: String }
|
|
84
|
+
package_name: { type: String },
|
|
85
|
+
swift_public: { type: Object, optional: true },
|
|
86
|
+
exclude_destinations: { type: Array, optional: true }
|
|
72
87
|
}
|
|
73
88
|
}.freeze
|
|
74
89
|
|
data/lib/evva/swift_generator.rb
CHANGED
|
@@ -12,6 +12,10 @@ module Evva
|
|
|
12
12
|
|
|
13
13
|
NATIVE_TYPES = %w[Int String Double Float Bool Date].freeze
|
|
14
14
|
|
|
15
|
+
def initialize(swift_public: false)
|
|
16
|
+
@swift_public_modifier = swift_public ? "public " : ""
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def events(bundle, _file_name, _enums_file_name, _destinations_file_name)
|
|
16
20
|
header_footer_wrapper do
|
|
17
21
|
events = bundle.map do |event|
|
|
@@ -3,13 +3,13 @@ struct EventData {
|
|
|
3
3
|
var properties: [String: Any]?
|
|
4
4
|
let destinations: [Destination]
|
|
5
5
|
|
|
6
|
-
init(name: String, properties: [String: Any]?, destinations: [Destination]) {
|
|
6
|
+
<%= @swift_public_modifier %>init(name: String, properties: [String: Any]?, destinations: [Destination]) {
|
|
7
7
|
self.name = name
|
|
8
8
|
self.properties = properties
|
|
9
9
|
self.destinations = destinations
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
init(type: EventType, properties: [String: Any]?) {
|
|
12
|
+
<%= @swift_public_modifier %>init(type: EventType, properties: [String: Any]?) {
|
|
13
13
|
self.init(name: type.name, properties: properties, destinations: type.destinations)
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -3,13 +3,13 @@ struct PropertyData {
|
|
|
3
3
|
let value: Any
|
|
4
4
|
let destinations: [Destination]
|
|
5
5
|
|
|
6
|
-
init(name: String, value: Any, destinations: [Destination]) {
|
|
6
|
+
<%= @swift_public_modifier %>init(name: String, value: Any, destinations: [Destination]) {
|
|
7
7
|
self.name = name
|
|
8
8
|
self.value = value
|
|
9
9
|
self.destinations = destinations
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
init(type: PropertyType, value: Any) {
|
|
12
|
+
<%= @swift_public_modifier %>init(type: PropertyType, value: Any) {
|
|
13
13
|
self.init(name: type.name, value: value, destinations: type.destinations)
|
|
14
14
|
}
|
|
15
15
|
}
|
data/lib/evva/version.rb
CHANGED
data/lib/evva.rb
CHANGED
|
@@ -25,12 +25,13 @@ module Evva
|
|
|
25
25
|
|
|
26
26
|
config = Evva::Config.new(hash: YAML.safe_load(config_file))
|
|
27
27
|
bundle = analytics_data(config: config.data_source)
|
|
28
|
+
filter_destinations!(bundle, config.exclude_destinations)
|
|
28
29
|
case config.type.downcase
|
|
29
30
|
when "android"
|
|
30
31
|
generator = Evva::KotlinGenerator.new(config.package_name)
|
|
31
32
|
evva_write(bundle, generator, config, "kt")
|
|
32
33
|
when "ios"
|
|
33
|
-
generator = Evva::SwiftGenerator.new
|
|
34
|
+
generator = Evva::SwiftGenerator.new(swift_public: config.swift_public?)
|
|
34
35
|
evva_write(bundle, generator, config, "swift")
|
|
35
36
|
end
|
|
36
37
|
Evva::Logger.print_summary
|
|
@@ -93,6 +94,14 @@ module Evva
|
|
|
93
94
|
opts_hash
|
|
94
95
|
end
|
|
95
96
|
|
|
97
|
+
def filter_destinations!(bundle, excluded)
|
|
98
|
+
return if excluded.empty?
|
|
99
|
+
|
|
100
|
+
bundle[:destinations].reject! { |d| excluded.include?(d) }
|
|
101
|
+
bundle[:events].each { |e| e.destinations.reject! { |d| excluded.include?(d) } }
|
|
102
|
+
bundle[:people].each { |p| p.destinations.reject! { |d| excluded.include?(d) } }
|
|
103
|
+
end
|
|
104
|
+
|
|
96
105
|
def write_to_file(path, data)
|
|
97
106
|
file_reader = Evva::FileReader.new
|
|
98
107
|
if file = file_reader.open_file(path, "w", false)
|
data/spec/evva_spec.rb
CHANGED
|
@@ -23,6 +23,40 @@ describe Evva do
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
describe ".filter_destinations!" do
|
|
27
|
+
let(:bundle) do
|
|
28
|
+
{
|
|
29
|
+
destinations: ["firebase", "mixpanel"],
|
|
30
|
+
events: [Evva::AnalyticsEvent.new("test_event", {}, ["firebase", "mixpanel"])],
|
|
31
|
+
people: [Evva::AnalyticsProperty.new("test_prop", "String", ["firebase", "mixpanel"])],
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "when excluding a destination" do
|
|
36
|
+
before { Evva.filter_destinations!(bundle, ["firebase"]) }
|
|
37
|
+
|
|
38
|
+
it "removes it from the destinations list" do
|
|
39
|
+
expect(bundle[:destinations]).to eq(["mixpanel"])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "removes it from event destinations" do
|
|
43
|
+
expect(bundle[:events].first.destinations).to eq(["mixpanel"])
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "removes it from people property destinations" do
|
|
47
|
+
expect(bundle[:people].first.destinations).to eq(["mixpanel"])
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "when exclude list is empty" do
|
|
52
|
+
before { Evva.filter_destinations!(bundle, []) }
|
|
53
|
+
|
|
54
|
+
it "does not change anything" do
|
|
55
|
+
expect(bundle[:destinations]).to eq(["firebase", "mixpanel"])
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
26
60
|
context "when generic.yml does not exist locally" do
|
|
27
61
|
let(:error) { "Could not open yml file" }
|
|
28
62
|
before do
|
|
@@ -34,6 +34,7 @@ describe Evva::Config do
|
|
|
34
34
|
its(:people_enum_file_name) { should eq("people/enum/file/name") }
|
|
35
35
|
its(:destinations_file_name) { should eq "destinations/file/name" }
|
|
36
36
|
its(:package_name) { should eq "com.package.name.analytics" }
|
|
37
|
+
its(:swift_public?) { should eq(false) }
|
|
37
38
|
|
|
38
39
|
describe "#data_source" do
|
|
39
40
|
subject(:data_source) { config.data_source }
|
|
@@ -45,4 +46,42 @@ describe Evva::Config do
|
|
|
45
46
|
it { expect { config }.to raise_error /unknown data source type 'i_dunno'/i }
|
|
46
47
|
end
|
|
47
48
|
end
|
|
49
|
+
|
|
50
|
+
describe "#exclude_destinations" do
|
|
51
|
+
context "when not set" do
|
|
52
|
+
its(:exclude_destinations) { should eq([]) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "when set to an array" do
|
|
56
|
+
before { hash[:exclude_destinations] = ["firebase"] }
|
|
57
|
+
|
|
58
|
+
its(:exclude_destinations) { should eq(["firebase"]) }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context "when not an array" do
|
|
62
|
+
before { hash[:exclude_destinations] = "firebase" }
|
|
63
|
+
|
|
64
|
+
it { expect { config }.to raise_error(ArgumentError, /Expected Array, got String/) }
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "#swift_public?" do
|
|
69
|
+
context "when swift_public is true" do
|
|
70
|
+
before { hash[:swift_public] = true }
|
|
71
|
+
|
|
72
|
+
its(:swift_public?) { should eq(true) }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context "when swift_public is false" do
|
|
76
|
+
before { hash[:swift_public] = false }
|
|
77
|
+
|
|
78
|
+
its(:swift_public?) { should eq(false) }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context "when swift_public is not a boolean" do
|
|
82
|
+
before { hash[:swift_public] = "yes" }
|
|
83
|
+
|
|
84
|
+
it { expect { config }.to raise_error(ArgumentError, "swift_public must be true or false") }
|
|
85
|
+
end
|
|
86
|
+
end
|
|
48
87
|
end
|
|
@@ -238,5 +238,26 @@ Swift
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
it { should eq expected }
|
|
241
|
+
|
|
242
|
+
context "when swift_public is true" do
|
|
243
|
+
let(:generator) { described_class.new(swift_public: true) }
|
|
244
|
+
|
|
245
|
+
let(:expected) {
|
|
246
|
+
<<-Swift
|
|
247
|
+
// This file was automatically generated by evva: https://github.com/hole19/evva
|
|
248
|
+
|
|
249
|
+
import Foundation
|
|
250
|
+
|
|
251
|
+
public extension Analytics {
|
|
252
|
+
public enum Destination {
|
|
253
|
+
case firebase
|
|
254
|
+
case whateverYouWantReally
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
Swift
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
it { should eq expected }
|
|
261
|
+
end
|
|
241
262
|
end
|
|
242
263
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: evva
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- André Andrade
|
|
8
8
|
- João Costa
|
|
9
9
|
- Ricardo Trindade
|
|
10
|
+
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
|
-
date:
|
|
13
|
+
date: 2026-05-26 00:00:00.000000000 Z
|
|
13
14
|
dependencies:
|
|
14
15
|
- !ruby/object:Gem::Dependency
|
|
15
16
|
name: colorize
|
|
@@ -112,6 +113,7 @@ homepage: https://github.com/hole19/
|
|
|
112
113
|
licenses:
|
|
113
114
|
- MIT
|
|
114
115
|
metadata: {}
|
|
116
|
+
post_install_message:
|
|
115
117
|
rdoc_options: []
|
|
116
118
|
require_paths:
|
|
117
119
|
- lib
|
|
@@ -126,7 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
128
|
- !ruby/object:Gem::Version
|
|
127
129
|
version: '0'
|
|
128
130
|
requirements: []
|
|
129
|
-
rubygems_version: 3.
|
|
131
|
+
rubygems_version: 3.5.3
|
|
132
|
+
signing_key:
|
|
130
133
|
specification_version: 4
|
|
131
134
|
summary: An event generating service
|
|
132
135
|
test_files: []
|