Class: Evva::GoogleSheet

Inherits:
Object
  • Object
show all
Defined in:
lib/evva/google_sheet.rb

Constant Summary collapse

EVENT_NAME =
"Event Name"
EVENT_PROPERTIES =
"Event Properties"
EVENT_DESTINATION =
"Event Destination"
PROPERTY_NAME =
"Property Name"
PROPERTY_TYPE =
"Property Type"
PROPERTY_DESTINATION =
"Property Destination"
ENUM_NAME =
"Enum Name"
ENUM_VALUES =
"Possible Values"

Instance Method Summary collapse

Constructor Details

#initialize(events_url, people_properties_url, enum_classes_url) ⇒ GoogleSheet

Returns a new instance of GoogleSheet.



17
18
19
20
21
# File 'lib/evva/google_sheet.rb', line 17

def initialize(events_url, people_properties_url, enum_classes_url)
  @events_url = events_url
  @people_properties_url = people_properties_url
  @enum_classes_url = enum_classes_url
end

Instance Method Details

#destinationsObject



64
65
66
# File 'lib/evva/google_sheet.rb', line 64

def destinations
  @destinations ||= events.map(&:destinations).flatten.uniq
end

#enum_classesObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/evva/google_sheet.rb', line 51

def enum_classes
  @enum_classes_csv ||= begin
    Logger.info("Downloading data from Google Sheet at #{@enum_classes_url}")
    get_csv(@enum_classes_url)
  end

  @enum_classes ||= @enum_classes_csv.map do |row|
    enum_name = row[ENUM_NAME]
    values = row[ENUM_VALUES].split(",")
    Evva::AnalyticsEnum.new(enum_name, values)
  end
end

#eventsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/evva/google_sheet.rb', line 23

def events
  @events_csv ||= begin
    Logger.info("Downloading data from Google Sheet at #{@events_url}")
    get_csv(@events_url)
  end

  @events ||= @events_csv.map do |row|
    event_name = row[EVENT_NAME]
    properties = hash_parser(row[EVENT_PROPERTIES])
    destinations = row[EVENT_DESTINATION]&.split(",")
    Evva::AnalyticsEvent.new(event_name, properties, destinations || [])
  end
end

#people_propertiesObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/evva/google_sheet.rb', line 37

def people_properties
  @people_properties_csv ||= begin
    Logger.info("Downloading data from Google Sheet at #{@people_properties_url}")
    get_csv(@people_properties_url)
  end

  @people_properties ||= @people_properties_csv.map do |row|
    property_name = row[PROPERTY_NAME]
    property_type = row[PROPERTY_TYPE]
    destinations = row[PROPERTY_DESTINATION]&.split(",")
    Evva::AnalyticsProperty.new(property_name, property_type, destinations || [])
  end
end