evva 0.4.4 → 0.5.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/{rubocop.yml → .rubocop.yml} +10 -6
- data/.rubocop_todo.yml +244 -326
- data/Gemfile +12 -10
- data/Gemfile.lock +60 -49
- data/README.md +1 -1
- data/bin/evva +1 -1
- data/changelog.md +9 -0
- data/evva.gemspec +14 -12
- data/lib/evva/config.rb +1 -1
- data/lib/evva/file_reader.rb +1 -1
- data/lib/evva/google_sheet.rb +17 -17
- data/lib/evva/{android_generator.rb → kotlin_generator.rb} +8 -10
- data/lib/evva/logger.rb +6 -6
- data/lib/evva/object_extension.rb +1 -1
- data/lib/evva/swift_generator.rb +9 -11
- data/lib/evva/templates/kotlin/events.kt +1 -1
- data/lib/evva/version.rb +2 -2
- data/lib/evva.rb +24 -24
- data/spec/lib/evva/config_spec.rb +25 -25
- data/spec/lib/evva/google_sheet_spec.rb +21 -21
- data/spec/lib/evva/{android_generator_spec.rb → kotlin_generator_spec.rb} +31 -31
- data/spec/lib/evva/logger_spec.rb +9 -9
- data/spec/lib/evva/object_extension_spec.rb +28 -28
- data/spec/lib/evva/swift_generator_spec.rb +14 -14
- data/spec/spec_helper.rb +4 -4
- metadata +12 -10
| @@ -3,45 +3,45 @@ describe Evva::Config do | |
| 3 3 |  | 
| 4 4 | 
             
              let(:hash) do
         | 
| 5 5 | 
             
                {
         | 
| 6 | 
            -
                  type:  | 
| 6 | 
            +
                  type: "EvvaOS",
         | 
| 7 7 | 
             
                  data_source: {
         | 
| 8 | 
            -
                    type:  | 
| 9 | 
            -
                    events_url:  | 
| 10 | 
            -
                    people_properties_url:  | 
| 11 | 
            -
                    enum_classes_url:  | 
| 8 | 
            +
                    type: "google_sheet",
         | 
| 9 | 
            +
                    events_url: "https://events.csv",
         | 
| 10 | 
            +
                    people_properties_url: "https://people_properties.csv",
         | 
| 11 | 
            +
                    enum_classes_url: "https://enum_classes.csv",
         | 
| 12 12 | 
             
                  },
         | 
| 13 | 
            -
                  out_path:  | 
| 14 | 
            -
                  event_file_name:  | 
| 15 | 
            -
                  event_enum_file_name:  | 
| 16 | 
            -
                  people_file_name:  | 
| 17 | 
            -
                  people_enum_file_name:  | 
| 18 | 
            -
                  destinations_file_name:  | 
| 19 | 
            -
                  package_name:  | 
| 13 | 
            +
                  out_path: "clear/path/to/event",
         | 
| 14 | 
            +
                  event_file_name: "event/file/name",
         | 
| 15 | 
            +
                  event_enum_file_name: "event/enum/file",
         | 
| 16 | 
            +
                  people_file_name: "people/file/name",
         | 
| 17 | 
            +
                  people_enum_file_name: "people/enum/file/name",
         | 
| 18 | 
            +
                  destinations_file_name: "destinations/file/name",
         | 
| 19 | 
            +
                  package_name: "com.package.name.analytics",
         | 
| 20 20 | 
             
                }
         | 
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| 23 | 
            -
              context  | 
| 23 | 
            +
              context "when hash is missing params" do
         | 
| 24 24 | 
             
                before { hash.delete(:type) }
         | 
| 25 25 | 
             
                it { expect { config }.to raise_error /missing keys/i }
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 28 | 
             
              its(:to_h) { should eq(hash) }
         | 
| 29 | 
            -
              its(:type) { should eq( | 
| 30 | 
            -
              its(:out_path) { should eq( | 
| 31 | 
            -
              its(:event_file_name) { should eq( | 
| 32 | 
            -
              its(:event_enum_file_name) { should eq  | 
| 33 | 
            -
              its(:people_file_name) { should eq( | 
| 34 | 
            -
              its(:people_enum_file_name) { should eq( | 
| 35 | 
            -
              its(:destinations_file_name) { should eq  | 
| 36 | 
            -
              its(:package_name) { should eq  | 
| 29 | 
            +
              its(:type) { should eq("EvvaOS") }
         | 
| 30 | 
            +
              its(:out_path) { should eq("clear/path/to/event") }
         | 
| 31 | 
            +
              its(:event_file_name) { should eq("event/file/name") }
         | 
| 32 | 
            +
              its(:event_enum_file_name) { should eq "event/enum/file" }
         | 
| 33 | 
            +
              its(:people_file_name) { should eq("people/file/name") }
         | 
| 34 | 
            +
              its(:people_enum_file_name) { should eq("people/enum/file/name") }
         | 
| 35 | 
            +
              its(:destinations_file_name) { should eq "destinations/file/name" }
         | 
| 36 | 
            +
              its(:package_name) { should eq "com.package.name.analytics" }
         | 
| 37 37 |  | 
| 38 | 
            -
              describe  | 
| 38 | 
            +
              describe "#data_source" do
         | 
| 39 39 | 
             
                subject(:data_source) { config.data_source }
         | 
| 40 40 |  | 
| 41 | 
            -
                it { should eq(type:  | 
| 41 | 
            +
                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 42 |  | 
| 43 | 
            -
                context  | 
| 44 | 
            -
                  before { hash[:data_source] = { type:  | 
| 43 | 
            +
                context "when given an unknown type data source" do
         | 
| 44 | 
            +
                  before { hash[:data_source] = { type: "i_dunno" } }
         | 
| 45 45 | 
             
                  it { expect { config }.to raise_error /unknown data source type 'i_dunno'/i }
         | 
| 46 46 | 
             
                end
         | 
| 47 47 | 
             
              end
         | 
| @@ -4,9 +4,9 @@ describe Evva::GoogleSheet do | |
| 4 4 | 
             
              let(:events_sheet) { "https://wtvr1" }
         | 
| 5 5 | 
             
              let(:people_sheet) { "https://wtvr2" }
         | 
| 6 6 | 
             
              let(:enum_sheet) { "https://wtvr3" }
         | 
| 7 | 
            -
              let(:events_file) { File.read( | 
| 8 | 
            -
              let(:people_file)  { File.read( | 
| 9 | 
            -
              let(:enum_file)  { File.read( | 
| 7 | 
            +
              let(:events_file) { File.read("spec/fixtures/sample_public_events.csv") }
         | 
| 8 | 
            +
              let(:people_file)  { File.read("spec/fixtures/sample_public_people_properties.csv") }
         | 
| 9 | 
            +
              let(:enum_file)  { File.read("spec/fixtures/sample_public_enums.csv") }
         | 
| 10 10 |  | 
| 11 11 | 
             
              before do
         | 
| 12 12 | 
             
                stub_request(:get, events_sheet).to_return(status: 200, body: events_file, headers: {})
         | 
| @@ -14,18 +14,18 @@ describe Evva::GoogleSheet do | |
| 14 14 | 
             
                stub_request(:get, enum_sheet).to_return(status: 200, body: enum_file, headers: {})
         | 
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 | 
            -
              describe  | 
| 17 | 
            +
              describe "#events" do
         | 
| 18 18 | 
             
                subject(:events) { sheet.events }
         | 
| 19 19 |  | 
| 20 20 | 
             
                it do
         | 
| 21 21 | 
             
                  expect { events }.not_to raise_error
         | 
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| 24 | 
            -
                it  | 
| 24 | 
            +
                it "returns an array with the corresponding events" do
         | 
| 25 25 | 
             
                  expected = [
         | 
| 26 | 
            -
                    Evva::AnalyticsEvent.new( | 
| 27 | 
            -
                    Evva::AnalyticsEvent.new( | 
| 28 | 
            -
                    Evva::AnalyticsEvent.new( | 
| 26 | 
            +
                    Evva::AnalyticsEvent.new("cp_page_view", { course_id: "Long", course_name: "String" }, ["firebase", "custom destination"]),
         | 
| 27 | 
            +
                    Evva::AnalyticsEvent.new("nav_feed_tap", {}, []),
         | 
| 28 | 
            +
                    Evva::AnalyticsEvent.new("cp_view_scorecard", { course_id: "Long", course_name: "String" }, ["custom destination"]),
         | 
| 29 29 | 
             
                  ]
         | 
| 30 30 | 
             
                  expect(events).to eq(expected)
         | 
| 31 31 | 
             
                end
         | 
| @@ -47,48 +47,48 @@ describe Evva::GoogleSheet do | |
| 47 47 | 
             
                end
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 | 
            -
              describe  | 
| 50 | 
            +
              describe "#people_properties" do
         | 
| 51 51 | 
             
                subject(:people_properties) { sheet.people_properties }
         | 
| 52 52 |  | 
| 53 53 | 
             
                it do
         | 
| 54 54 | 
             
                  expect { people_properties }.not_to raise_error
         | 
| 55 55 | 
             
                end
         | 
| 56 56 |  | 
| 57 | 
            -
                it  | 
| 57 | 
            +
                it "returns an array with the corresponding events" do
         | 
| 58 58 | 
             
                  expect(people_properties).to eq [
         | 
| 59 | 
            -
                    Evva::AnalyticsProperty.new( | 
| 60 | 
            -
                    Evva::AnalyticsProperty.new( | 
| 61 | 
            -
                    Evva::AnalyticsProperty.new( | 
| 59 | 
            +
                    Evva::AnalyticsProperty.new("rounds_with_wear", "String", ["firebase", "custom destination"]),
         | 
| 60 | 
            +
                    Evva::AnalyticsProperty.new("total_friends", "Int", []),
         | 
| 61 | 
            +
                    Evva::AnalyticsProperty.new("wearable_platform", "WearableAppPlatform", ["firebase"]),
         | 
| 62 62 | 
             
                  ]
         | 
| 63 63 | 
             
                end
         | 
| 64 64 | 
             
              end
         | 
| 65 65 |  | 
| 66 | 
            -
              describe  | 
| 66 | 
            +
              describe "#enum_classes" do
         | 
| 67 67 | 
             
                subject(:enum_classes) { sheet.enum_classes }
         | 
| 68 68 |  | 
| 69 69 | 
             
                it do
         | 
| 70 70 | 
             
                  expect { enum_classes }.not_to raise_error
         | 
| 71 71 | 
             
                end
         | 
| 72 72 |  | 
| 73 | 
            -
                it  | 
| 73 | 
            +
                it "returns an array with the corresponding events" do
         | 
| 74 74 | 
             
                  expect(enum_classes).to eq [
         | 
| 75 | 
            -
                    Evva::AnalyticsEnum.new( | 
| 76 | 
            -
                    Evva::AnalyticsEnum.new( | 
| 75 | 
            +
                    Evva::AnalyticsEnum.new("PageViewSourceScreen", ["course_discovery","synced_courses","nearby","deal"]),
         | 
| 76 | 
            +
                    Evva::AnalyticsEnum.new("PremiumClickBuy", ["notes","hi_res_maps","whatever"])
         | 
| 77 77 | 
             
                  ]
         | 
| 78 78 | 
             
                end
         | 
| 79 79 | 
             
              end
         | 
| 80 80 |  | 
| 81 | 
            -
              describe  | 
| 81 | 
            +
              describe "#destinations" do
         | 
| 82 82 | 
             
                subject(:destinations) { sheet.destinations }
         | 
| 83 83 |  | 
| 84 84 | 
             
                it do
         | 
| 85 85 | 
             
                  expect { destinations }.not_to raise_error
         | 
| 86 86 | 
             
                end
         | 
| 87 87 |  | 
| 88 | 
            -
                it  | 
| 88 | 
            +
                it "returns an array with the corresponding events" do
         | 
| 89 89 | 
             
                  expect(destinations).to eq [
         | 
| 90 | 
            -
                     | 
| 91 | 
            -
                     | 
| 90 | 
            +
                    "firebase",
         | 
| 91 | 
            +
                    "custom destination",
         | 
| 92 92 | 
             
                  ]
         | 
| 93 93 | 
             
                end
         | 
| 94 94 | 
             
              end
         | 
| @@ -1,16 +1,16 @@ | |
| 1 | 
            -
            describe Evva:: | 
| 1 | 
            +
            describe Evva::KotlinGenerator do
         | 
| 2 2 | 
             
              let(:generator) { described_class.new("com.hole19golf.hole19.analytics") }
         | 
| 3 3 |  | 
| 4 | 
            -
              describe  | 
| 4 | 
            +
              describe "#events" do
         | 
| 5 5 | 
             
                subject { generator.events(events, "AnalyticsEvent", "AnalyticsEvents", "AnalyticsDestinations") }
         | 
| 6 6 |  | 
| 7 7 | 
             
                let(:events) { [
         | 
| 8 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 9 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 10 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 11 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 12 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 13 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 8 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view", {}, []),
         | 
| 9 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_2", {}, ["firebase"]),
         | 
| 10 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_a", { course_id: "Long", course_name: "String" }, ["firebase", "custom destination"]),
         | 
| 11 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_b", { course_id: "Long", course_name: "String", from_screen: "CourseProfileSource" }, ["firebase"]),
         | 
| 12 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_c", { course_id: "Long", course_name: "String", from_screen: "CourseProfileSource?" }, []),
         | 
| 13 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_d", { course_id: "Long?", course_name: "String", viewed_at: "Date" }, []),
         | 
| 14 14 | 
             
                ] }
         | 
| 15 15 |  | 
| 16 16 | 
             
                let(:expected) {
         | 
| @@ -28,11 +28,11 @@ sealed class AnalyticsEvent( | |
| 28 28 | 
             
            ) {
         | 
| 29 29 | 
             
                val name = event.key
         | 
| 30 30 |  | 
| 31 | 
            -
                object CpPageView : AnalyticsEvent(
         | 
| 31 | 
            +
                data object CpPageView : AnalyticsEvent(
         | 
| 32 32 | 
             
                    event = AnalyticsEvents.CP_PAGE_VIEW,
         | 
| 33 33 | 
             
                )
         | 
| 34 34 |  | 
| 35 | 
            -
                object CpPageView2 : AnalyticsEvent(
         | 
| 35 | 
            +
                data object CpPageView2 : AnalyticsEvent(
         | 
| 36 36 | 
             
                    event = AnalyticsEvents.CP_PAGE_VIEW_2,
         | 
| 37 37 | 
             
                    destinations = arrayOf(
         | 
| 38 38 | 
             
                        AnalyticsDestinations.FIREBASE
         | 
| @@ -102,11 +102,11 @@ Kotlin | |
| 102 102 | 
             
                it { should eq expected }
         | 
| 103 103 | 
             
              end
         | 
| 104 104 |  | 
| 105 | 
            -
              describe  | 
| 105 | 
            +
              describe "#special_property_enums" do
         | 
| 106 106 | 
             
                subject { generator.special_property_enums(enums) }
         | 
| 107 107 | 
             
                let(:enums) { [
         | 
| 108 | 
            -
                  Evva::AnalyticsEnum.new( | 
| 109 | 
            -
                  Evva::AnalyticsEnum.new( | 
| 108 | 
            +
                  Evva::AnalyticsEnum.new("CourseProfileSource", ["course_discovery", "synced_courses"]),
         | 
| 109 | 
            +
                  Evva::AnalyticsEnum.new("PremiumFrom", ["Course Profile", "Round Setup"]),
         | 
| 110 110 | 
             
                ] }
         | 
| 111 111 | 
             
                let(:expected) {
         | 
| 112 112 | 
             
            <<-Kotlin
         | 
| @@ -130,12 +130,12 @@ Kotlin | |
| 130 130 | 
             
                it { should eq expected }
         | 
| 131 131 | 
             
              end
         | 
| 132 132 |  | 
| 133 | 
            -
              describe  | 
| 134 | 
            -
                subject { generator.event_enum(event_bundle,  | 
| 133 | 
            +
              describe "#event_enum" do
         | 
| 134 | 
            +
                subject { generator.event_enum(event_bundle, "AnalyticsEvents") }
         | 
| 135 135 | 
             
                let(:event_bundle) { [
         | 
| 136 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 137 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 138 | 
            -
             | 
| 136 | 
            +
                  Evva::AnalyticsEvent.new("nav_feed_tap", {}, []),
         | 
| 137 | 
            +
                  Evva::AnalyticsEvent.new("nav_performance_tap", {}, []),
         | 
| 138 | 
            +
                ] }
         | 
| 139 139 | 
             
                let(:expected) {
         | 
| 140 140 | 
             
            <<-Kotlin
         | 
| 141 141 | 
             
            package com.hole19golf.hole19.analytics
         | 
| @@ -153,12 +153,12 @@ Kotlin | |
| 153 153 | 
             
                it { should eq expected }
         | 
| 154 154 | 
             
              end
         | 
| 155 155 |  | 
| 156 | 
            -
              describe  | 
| 157 | 
            -
                subject { generator.people_properties(people_bundle,  | 
| 156 | 
            +
              describe "#people_properties" do
         | 
| 157 | 
            +
                subject { generator.people_properties(people_bundle, "AnalyticsProperty", "AnalyticsProperties", "AnalyticsDestinations") }
         | 
| 158 158 | 
             
                let(:people_bundle) { [
         | 
| 159 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 160 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 161 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 159 | 
            +
                  Evva::AnalyticsProperty.new("rounds_with_wear", "String", []),
         | 
| 160 | 
            +
                  Evva::AnalyticsProperty.new("last_active_at", "Date", []),
         | 
| 161 | 
            +
                  Evva::AnalyticsProperty.new("wear_platform", "WearableAppPlatform", ["firebase", "custom destination"]),
         | 
| 162 162 | 
             
                ] }
         | 
| 163 163 | 
             
                let(:expected) {
         | 
| 164 164 | 
             
            <<-Kotlin
         | 
| @@ -206,11 +206,11 @@ Kotlin | |
| 206 206 | 
             
                it { should eq expected }
         | 
| 207 207 | 
             
              end
         | 
| 208 208 |  | 
| 209 | 
            -
              describe  | 
| 210 | 
            -
                subject { generator.people_properties_enum(people_bundle,  | 
| 209 | 
            +
              describe "#people_properties_enum" do
         | 
| 210 | 
            +
                subject { generator.people_properties_enum(people_bundle, "AnalyticsProperties") }
         | 
| 211 211 | 
             
                let(:people_bundle) { [
         | 
| 212 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 213 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 212 | 
            +
                  Evva::AnalyticsProperty.new("rounds_with_wear", "String", ["firebase"]),
         | 
| 213 | 
            +
                  Evva::AnalyticsProperty.new("wear_platform", "WearableAppPlatform", ["firebase", "custom destination"]),
         | 
| 214 214 | 
             
                ] }
         | 
| 215 215 | 
             
                let(:expected) {
         | 
| 216 216 | 
             
            <<-Kotlin
         | 
| @@ -229,11 +229,11 @@ Kotlin | |
| 229 229 | 
             
                it { should eq expected }
         | 
| 230 230 | 
             
              end
         | 
| 231 231 |  | 
| 232 | 
            -
              describe  | 
| 233 | 
            -
                subject { generator.destinations(destinations_bundle,  | 
| 232 | 
            +
              describe "#destinations" do
         | 
| 233 | 
            +
                subject { generator.destinations(destinations_bundle, "AnalyticsDestinations") }
         | 
| 234 234 | 
             
                let(:destinations_bundle) { [
         | 
| 235 | 
            -
                   | 
| 236 | 
            -
                   | 
| 235 | 
            +
                  "firebase",
         | 
| 236 | 
            +
                  "whatever you want really"
         | 
| 237 237 | 
             
                ] }
         | 
| 238 238 | 
             
                let(:expected) {
         | 
| 239 239 | 
             
            <<-Kotlin
         | 
| @@ -4,30 +4,30 @@ describe Evva::Logger do | |
| 4 4 | 
             
              let(:warn)    { summary[:warn] }
         | 
| 5 5 | 
             
              let(:error)   { summary[:error] }
         | 
| 6 6 |  | 
| 7 | 
            -
              context  | 
| 8 | 
            -
                before { Evva::Logger.info  | 
| 7 | 
            +
              context "when logging to info" do
         | 
| 8 | 
            +
                before { Evva::Logger.info "msg" }
         | 
| 9 9 |  | 
| 10 | 
            -
                it  | 
| 10 | 
            +
                it "returns the expected totals" do
         | 
| 11 11 | 
             
                  expect(info).to  eq 1
         | 
| 12 12 | 
             
                  expect(warn).to  eq 0
         | 
| 13 13 | 
             
                  expect(error).to eq 0
         | 
| 14 14 | 
             
                end
         | 
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 | 
            -
              context  | 
| 18 | 
            -
                before { Evva::Logger.warn  | 
| 17 | 
            +
              context "when logging to warn" do
         | 
| 18 | 
            +
                before { Evva::Logger.warn "msg" }
         | 
| 19 19 |  | 
| 20 | 
            -
                it  | 
| 20 | 
            +
                it "returns the expected totals" do
         | 
| 21 21 | 
             
                  expect(info).to  eq 0
         | 
| 22 22 | 
             
                  expect(warn).to  eq 1
         | 
| 23 23 | 
             
                  expect(error).to eq 0
         | 
| 24 24 | 
             
                end
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
              context  | 
| 28 | 
            -
                before { Evva::Logger.error  | 
| 27 | 
            +
              context "when logging to error" do
         | 
| 28 | 
            +
                before { Evva::Logger.error "msg" }
         | 
| 29 29 |  | 
| 30 | 
            -
                it  | 
| 30 | 
            +
                it "returns the expected totals" do
         | 
| 31 31 | 
             
                  expect(info).to  eq 0
         | 
| 32 32 | 
             
                  expect(warn).to  eq 0
         | 
| 33 33 | 
             
                  expect(error).to eq 1
         | 
| @@ -1,91 +1,91 @@ | |
| 1 1 | 
             
            describe Object do
         | 
| 2 | 
            -
              describe  | 
| 2 | 
            +
              describe "#deep_symbolize" do
         | 
| 3 3 | 
             
                subject { obj.deep_symbolize }
         | 
| 4 4 |  | 
| 5 | 
            -
                context  | 
| 6 | 
            -
                  let(:obj) { {  | 
| 7 | 
            -
                  it { should eq(key1:  | 
| 5 | 
            +
                context "when object is an Hash" do
         | 
| 6 | 
            +
                  let(:obj) { { "key1" => "value1", key2: "value2" } }
         | 
| 7 | 
            +
                  it { should eq(key1: "value1", key2: "value2") }
         | 
| 8 8 |  | 
| 9 | 
            -
                  context  | 
| 10 | 
            -
                    before { obj[ | 
| 11 | 
            -
                    it { should eq(key1:  | 
| 9 | 
            +
                  context "with inner Hashes" do
         | 
| 10 | 
            +
                    before { obj["key2"] = { "key3" => { "key4" => "value4" } } }
         | 
| 11 | 
            +
                    it { should eq(key1: "value1", key2: { key3: { key4: "value4" } }) }
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 | 
            -
                context  | 
| 16 | 
            -
                  let(:obj) { [ | 
| 15 | 
            +
                context "when object is an Array" do
         | 
| 16 | 
            +
                  let(:obj) { ["value1"] }
         | 
| 17 17 | 
             
                  it { should eq obj }
         | 
| 18 18 |  | 
| 19 | 
            -
                  context  | 
| 20 | 
            -
                    let(:obj) { [{  | 
| 21 | 
            -
                    it { should eq([{ key1:  | 
| 19 | 
            +
                  context "with inner Hashes" do
         | 
| 20 | 
            +
                    let(:obj) { [{ "key1" => "value1" }, { "key2" => "value2" }] }
         | 
| 21 | 
            +
                    it { should eq([{ key1: "value1" }, { key2: "value2" }]) }
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 | 
            -
                context  | 
| 26 | 
            -
                  let(:obj) {  | 
| 25 | 
            +
                context "when object is something else" do
         | 
| 26 | 
            +
                  let(:obj) { "value1" }
         | 
| 27 27 | 
             
                  it { should eq obj }
         | 
| 28 28 | 
             
                end
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 | 
            -
              describe  | 
| 31 | 
            +
              describe "#validate_structure!" do
         | 
| 32 32 | 
             
                subject { obj.validate_structure!(structure) }
         | 
| 33 33 |  | 
| 34 | 
            -
                context  | 
| 35 | 
            -
                  let(:obj) {  | 
| 34 | 
            +
                context "when object type differs of the structure type" do
         | 
| 35 | 
            +
                  let(:obj) { "a string" }
         | 
| 36 36 | 
             
                  let(:structure) { { type: Integer } }
         | 
| 37 37 | 
             
                  it { expect { subject }.to raise_error /expected Integer, got String/i }
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            -
                context  | 
| 40 | 
            +
                context "when object is a Nil" do
         | 
| 41 41 | 
             
                  let(:obj) { nil }
         | 
| 42 42 | 
             
                  let(:structure) { { type: Integer } }
         | 
| 43 43 | 
             
                  it { expect { subject }.to raise_error /expected Integer, got NilClass/i }
         | 
| 44 44 |  | 
| 45 | 
            -
                  context  | 
| 45 | 
            +
                  context "but is also optional" do
         | 
| 46 46 | 
             
                    before { structure[:optional] = true }
         | 
| 47 47 | 
             
                    it { expect { subject }.not_to raise_error }
         | 
| 48 48 | 
             
                  end
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            -
                context  | 
| 51 | 
            +
                context "when object is an Array" do
         | 
| 52 52 | 
             
                  let(:obj) { %w[elem1 elem2] }
         | 
| 53 53 | 
             
                  let(:structure) { { type: Array } }
         | 
| 54 54 | 
             
                  it { expect { subject }.not_to raise_error }
         | 
| 55 55 |  | 
| 56 | 
            -
                  context  | 
| 56 | 
            +
                  context "given an element structure" do
         | 
| 57 57 | 
             
                    before { structure[:elements] = { type: String } }
         | 
| 58 58 | 
             
                    it { expect { subject }.not_to raise_error }
         | 
| 59 59 |  | 
| 60 | 
            -
                    context  | 
| 60 | 
            +
                    context "which is not respected" do
         | 
| 61 61 | 
             
                      before { structure[:elements] = { type: Integer } }
         | 
| 62 62 | 
             
                      it { expect { subject }.to raise_error /expected Integer, got String/i }
         | 
| 63 63 | 
             
                    end
         | 
| 64 64 | 
             
                  end
         | 
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 | 
            -
                context  | 
| 68 | 
            -
                  let(:obj) { { key1:  | 
| 67 | 
            +
                context "when object is an Hash" do
         | 
| 68 | 
            +
                  let(:obj) { { key1: "value1", key2: "value2", key3: "value3" } }
         | 
| 69 69 | 
             
                  let(:structure) { { type: Hash } }
         | 
| 70 70 | 
             
                  it { expect { subject }.not_to raise_error }
         | 
| 71 71 |  | 
| 72 | 
            -
                  context  | 
| 72 | 
            +
                  context "when given an element structure" do
         | 
| 73 73 | 
             
                    let(:structure) { { type: Hash, elements: { key1: { type: String }, key2: { type: String }, key3: { type: String } } } }
         | 
| 74 74 | 
             
                    it { expect { subject }.not_to raise_error }
         | 
| 75 75 |  | 
| 76 | 
            -
                    context  | 
| 76 | 
            +
                    context "which is not respected" do
         | 
| 77 77 | 
             
                      before { obj[:key2] = {} }
         | 
| 78 78 | 
             
                      it { expect { subject }.to raise_error /expected String, got Hash/i }
         | 
| 79 79 | 
             
                    end
         | 
| 80 80 |  | 
| 81 | 
            -
                    context  | 
| 81 | 
            +
                    context "when missing keys" do
         | 
| 82 82 | 
             
                      before do
         | 
| 83 83 | 
             
                        obj.delete(:key1)
         | 
| 84 84 | 
             
                        obj.delete(:key3)
         | 
| 85 85 | 
             
                      end
         | 
| 86 86 | 
             
                      it { expect { subject }.to raise_error /missing keys: key1, key3/i }
         | 
| 87 87 |  | 
| 88 | 
            -
                      context  | 
| 88 | 
            +
                      context "which are optional" do
         | 
| 89 89 | 
             
                        before do
         | 
| 90 90 | 
             
                          structure[:elements][:key1][:optional] = true
         | 
| 91 91 | 
             
                          structure[:elements][:key3][:optional] = true
         | 
| @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            describe Evva::SwiftGenerator do
         | 
| 2 2 | 
             
              let(:generator) { described_class.new }
         | 
| 3 3 |  | 
| 4 | 
            -
              describe  | 
| 4 | 
            +
              describe "#events" do
         | 
| 5 5 | 
             
                subject { generator.events(event_bundle, nil, nil, nil) }
         | 
| 6 6 |  | 
| 7 7 | 
             
                let(:event_bundle) { [
         | 
| 8 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 9 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 10 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 11 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 12 | 
            -
                  Evva::AnalyticsEvent.new( | 
| 8 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view", {}, ["firebase"]),
         | 
| 9 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_a", { course_id: "Long", course_name: "String" }, ["firebase", "Custom Destination"]),
         | 
| 10 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_b", { course_id: "Long", course_name: "String", from_screen: "CourseProfileSource" }, []),
         | 
| 11 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_c", { course_id: "Long", course_name: "String", from_screen: "CourseProfileSource?" }, []),
         | 
| 12 | 
            +
                  Evva::AnalyticsEvent.new("cp_page_view_d", { course_id: "Long?", course_name: "String" }, []),
         | 
| 13 13 | 
             
                ] }
         | 
| 14 14 |  | 
| 15 15 | 
             
                let(:expected) {
         | 
| @@ -107,12 +107,12 @@ Swift | |
| 107 107 | 
             
                it { should eq expected }
         | 
| 108 108 | 
             
              end
         | 
| 109 109 |  | 
| 110 | 
            -
              describe  | 
| 110 | 
            +
              describe "#special_property_enums" do
         | 
| 111 111 | 
             
                subject { generator.special_property_enums(enums) }
         | 
| 112 112 |  | 
| 113 113 | 
             
                let(:enums) { [
         | 
| 114 | 
            -
                  Evva::AnalyticsEnum.new( | 
| 115 | 
            -
                  Evva::AnalyticsEnum.new( | 
| 114 | 
            +
                  Evva::AnalyticsEnum.new("CourseProfileSource", ["course_discovery", "synced_courses"]),
         | 
| 115 | 
            +
                  Evva::AnalyticsEnum.new("PremiumFrom", ["Course Profile", "Round Setup"]),
         | 
| 116 116 | 
             
                ] }
         | 
| 117 117 |  | 
| 118 118 | 
             
                let(:expected) {
         | 
| @@ -142,9 +142,9 @@ Swift | |
| 142 142 | 
             
                subject { generator.people_properties(people_bundle, "", "", "") }
         | 
| 143 143 |  | 
| 144 144 | 
             
                let(:people_bundle) { [
         | 
| 145 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 146 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 147 | 
            -
                  Evva::AnalyticsProperty.new( | 
| 145 | 
            +
                  Evva::AnalyticsProperty.new("rounds_with_wear", "String", ["firebase"]),
         | 
| 146 | 
            +
                  Evva::AnalyticsProperty.new("wear_platform", "WearableAppPlatform", ["firebase", "custom destination"]),
         | 
| 147 | 
            +
                  Evva::AnalyticsProperty.new("number_of_times_it_happened", "Long", []),
         | 
| 148 148 | 
             
                ] }
         | 
| 149 149 |  | 
| 150 150 | 
             
                let(:expected) {
         | 
| @@ -218,8 +218,8 @@ Swift | |
| 218 218 | 
             
                subject { generator.destinations(destinations, "") }
         | 
| 219 219 |  | 
| 220 220 | 
             
                let(:destinations) { [
         | 
| 221 | 
            -
                   | 
| 222 | 
            -
                   | 
| 221 | 
            +
                  "firebase",
         | 
| 222 | 
            +
                  "whatever you want really"
         | 
| 223 223 | 
             
                ] }
         | 
| 224 224 |  | 
| 225 225 | 
             
                let(:expected) {
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,9 +1,9 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require "simplecov"
         | 
| 2 2 | 
             
            SimpleCov.start
         | 
| 3 3 |  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 6 | 
            -
            require  | 
| 4 | 
            +
            require "evva"
         | 
| 5 | 
            +
            require "rspec/its"
         | 
| 6 | 
            +
            require "webmock/rspec"
         | 
| 7 7 | 
             
            # This file was generated by the `rspec --init` command. Conventionally, all
         | 
| 8 8 | 
             
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         | 
| 9 9 | 
             
            # The generated `.rspec` file contains `--require spec_helper` which will cause
         | 
    
        metadata
    CHANGED
    
    | @@ -1,17 +1,19 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: evva
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 | 
            -
            -  | 
| 7 | 
            +
            - André Andrade
         | 
| 8 | 
            +
            - João Costa
         | 
| 9 | 
            +
            - Ricardo Trindade
         | 
| 8 10 | 
             
            autorequire:
         | 
| 9 11 | 
             
            bindir: bin
         | 
| 10 12 | 
             
            cert_chain: []
         | 
| 11 13 | 
             
            date: 2024-10-16 00:00:00.000000000 Z
         | 
| 12 14 | 
             
            dependencies:
         | 
| 13 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 16 | 
            +
              name: colorize
         | 
| 15 17 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 18 | 
             
                requirements:
         | 
| 17 19 | 
             
                - - "~>"
         | 
| @@ -25,19 +27,19 @@ dependencies: | |
| 25 27 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 28 | 
             
                    version: '1.0'
         | 
| 27 29 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            -
              name:  | 
| 30 | 
            +
              name: safe_yaml
         | 
| 29 31 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 32 | 
             
                requirements:
         | 
| 31 33 | 
             
                - - "~>"
         | 
| 32 34 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: '0 | 
| 35 | 
            +
                    version: '1.0'
         | 
| 34 36 | 
             
              type: :runtime
         | 
| 35 37 | 
             
              prerelease: false
         | 
| 36 38 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 39 | 
             
                requirements:
         | 
| 38 40 | 
             
                - - "~>"
         | 
| 39 41 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: '0 | 
| 42 | 
            +
                    version: '1.0'
         | 
| 41 43 | 
             
            description: Evva generates all the analytics event tracking functions for you
         | 
| 42 44 | 
             
            email: ricardo.trindade743@gmail.com
         | 
| 43 45 | 
             
            executables:
         | 
| @@ -47,6 +49,7 @@ extra_rdoc_files: [] | |
| 47 49 | 
             
            files:
         | 
| 48 50 | 
             
            - ".gitignore"
         | 
| 49 51 | 
             
            - ".rspec"
         | 
| 52 | 
            +
            - ".rubocop.yml"
         | 
| 50 53 | 
             
            - ".rubocop_todo.yml"
         | 
| 51 54 | 
             
            - ".travis.yml"
         | 
| 52 55 | 
             
            - Gemfile
         | 
| @@ -60,10 +63,10 @@ files: | |
| 60 63 | 
             
            - lib/evva/analytics_enum.rb
         | 
| 61 64 | 
             
            - lib/evva/analytics_event.rb
         | 
| 62 65 | 
             
            - lib/evva/analytics_property.rb
         | 
| 63 | 
            -
            - lib/evva/android_generator.rb
         | 
| 64 66 | 
             
            - lib/evva/config.rb
         | 
| 65 67 | 
             
            - lib/evva/file_reader.rb
         | 
| 66 68 | 
             
            - lib/evva/google_sheet.rb
         | 
| 69 | 
            +
            - lib/evva/kotlin_generator.rb
         | 
| 67 70 | 
             
            - lib/evva/logger.rb
         | 
| 68 71 | 
             
            - lib/evva/object_extension.rb
         | 
| 69 72 | 
             
            - lib/evva/swift_generator.rb
         | 
| @@ -80,15 +83,14 @@ files: | |
| 80 83 | 
             
            - lib/evva/templates/swift/people_properties.swift
         | 
| 81 84 | 
             
            - lib/evva/templates/swift/special_property_enums.swift
         | 
| 82 85 | 
             
            - lib/evva/version.rb
         | 
| 83 | 
            -
            - rubocop.yml
         | 
| 84 86 | 
             
            - spec/evva_spec.rb
         | 
| 85 87 | 
             
            - spec/fixtures/sample_public_enums.csv
         | 
| 86 88 | 
             
            - spec/fixtures/sample_public_events.csv
         | 
| 87 89 | 
             
            - spec/fixtures/sample_public_people_properties.csv
         | 
| 88 90 | 
             
            - spec/fixtures/test.yml
         | 
| 89 | 
            -
            - spec/lib/evva/android_generator_spec.rb
         | 
| 90 91 | 
             
            - spec/lib/evva/config_spec.rb
         | 
| 91 92 | 
             
            - spec/lib/evva/google_sheet_spec.rb
         | 
| 93 | 
            +
            - spec/lib/evva/kotlin_generator_spec.rb
         | 
| 92 94 | 
             
            - spec/lib/evva/logger_spec.rb
         | 
| 93 95 | 
             
            - spec/lib/evva/object_extension_spec.rb
         | 
| 94 96 | 
             
            - spec/lib/evva/swift_generator_spec.rb
         | 
| @@ -105,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 105 107 | 
             
              requirements:
         | 
| 106 108 | 
             
              - - ">="
         | 
| 107 109 | 
             
                - !ruby/object:Gem::Version
         | 
| 108 | 
            -
                  version:  | 
| 110 | 
            +
                  version: 3.2.0
         | 
| 109 111 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 110 112 | 
             
              requirements:
         | 
| 111 113 | 
             
              - - ">="
         |