Module: Evva
- Extended by:
- Evva
- Included in:
- Evva
- Defined in:
- lib/evva.rb,
lib/evva/config.rb,
lib/evva/logger.rb,
lib/evva/version.rb,
lib/evva/file_reader.rb,
lib/evva/google_sheet.rb,
lib/evva/mixpanel_enum.rb,
lib/evva/mixpanel_event.rb,
lib/evva/swift_generator.rb,
lib/evva/android_generator.rb
Defined Under Namespace
Modules: Logger
Classes: AndroidGenerator, Config, FileReader, GoogleSheet, MixpanelEnum, MixpanelEvent, SwiftGenerator
Constant Summary
collapse
- VERSION =
'0.2.0'.freeze
- VERSION_UPDATED_AT =
'2021-08-30'.freeze
Instance Method Summary
collapse
Instance Method Details
#analytics_data(config:) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/evva.rb', line 54
def analytics_data(config:)
source =
case config[:type]
when 'google_sheet'
Evva::GoogleSheet.new(config[:events_url], config[:people_properties_url], config[:enum_classes_url])
end
events_bundle = {}
events_bundle[:events] = source.events
events_bundle[:people] = source.people_properties
events_bundle[:enums] = source.enum_classes
events_bundle
end
|
#command_line_options(options) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/evva.rb', line 67
def command_line_options(options)
opts_hash = {}
opts_parser = OptionParser.new do |opts|
opts.on_tail('-h', '--help', 'Show this message') do
puts opts
exit
end
opts.on_tail('-v', '--version', 'Show version') do
puts Evva::VERSION
exit
end
end
opts_parser.parse!(options)
opts_hash
end
|
#evva_write(bundle, generator, configuration, extension) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/evva.rb', line 38
def evva_write(bundle, generator, configuration, extension)
path = "#{configuration.out_path}/#{configuration.event_file_name}.#{extension}"
write_to_file(path, generator.events(bundle[:events], configuration.event_file_name))
unless configuration.type.downcase == 'ios'
path = "#{configuration.out_path}/#{configuration.event_enum_file_name}.#{extension}"
write_to_file(path, generator.event_enum(bundle[:events], configuration.event_enum_file_name))
end
path = "#{configuration.out_path}/#{configuration.people_file_name}.#{extension}"
write_to_file(path, generator.people_properties(bundle[:people], configuration.people_file_name))
path = "#{configuration.out_path}/#{configuration.special_enum_file_name}.#{extension}"
write_to_file(path, generator.special_property_enums(bundle[:enums]))
end
|
#run(options) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/evva.rb', line 17
def run(options)
file_reader = Evva::FileReader.new
options = command_line_options(options)
unless config_file = file_reader.open_file('evva_config.yml', 'r', true)
Logger.error("Could not open evva_config.yml")
return
end
config = Evva::Config.new(hash: YAML.safe_load(config_file))
bundle = analytics_data(config: config.data_source)
case config.type.downcase
when 'android'
generator = Evva::AndroidGenerator.new(config.package_name)
evva_write(bundle, generator, config, 'kt')
when 'ios'
generator = Evva::SwiftGenerator.new
evva_write(bundle, generator, config, 'swift')
end
Evva::Logger.print_summary
end
|
#write_to_file(path, data) ⇒ Object
86
87
88
89
90
91
92
93
|
# File 'lib/evva.rb', line 86
def write_to_file(path, data)
file_reader = Evva::FileReader.new
if file = file_reader.open_file(path, "w", false)
file_reader.write_to_file(file, data)
else
Logger.error("Could not write to file in #{path}")
end
end
|