evva 0.1.4.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -2
  3. data/.rspec +0 -1
  4. data/.rubocop_todo.yml +10 -10
  5. data/.travis.yml +1 -0
  6. data/Gemfile +9 -8
  7. data/Gemfile.lock +7 -11
  8. data/README.md +12 -2
  9. data/Rakefile +9 -0
  10. data/changelog.md +18 -1
  11. data/evva.gemspec +0 -3
  12. data/lib/evva/{mixpanel_enum.rb → analytics_enum.rb} +2 -1
  13. data/lib/evva/analytics_event.rb +17 -0
  14. data/lib/evva/analytics_property.rb +17 -0
  15. data/lib/evva/android_generator.rb +141 -84
  16. data/lib/evva/config.rb +21 -4
  17. data/lib/evva/google_sheet.rb +69 -44
  18. data/lib/evva/swift_generator.rb +91 -81
  19. data/lib/evva/templates/kotlin/base.kt +7 -0
  20. data/lib/evva/templates/kotlin/destinations.kt +5 -0
  21. data/lib/evva/templates/kotlin/event_enum.kt +5 -0
  22. data/lib/evva/templates/kotlin/events.kt +34 -0
  23. data/lib/evva/templates/kotlin/people_properties.kt +24 -0
  24. data/lib/evva/templates/kotlin/people_properties_enum.kt +5 -0
  25. data/lib/evva/templates/kotlin/special_property_enums.kt +10 -0
  26. data/lib/evva/templates/swift/base.swift +7 -0
  27. data/lib/evva/templates/swift/destinations.swift +5 -0
  28. data/lib/evva/templates/swift/events.swift +65 -0
  29. data/lib/evva/templates/swift/people_properties.swift +49 -0
  30. data/lib/evva/templates/swift/special_property_enums.swift +10 -0
  31. data/lib/evva/version.rb +2 -2
  32. data/lib/evva.rb +16 -6
  33. data/spec/evva_spec.rb +3 -5
  34. data/spec/fixtures/sample_public_enums.csv +3 -0
  35. data/spec/fixtures/sample_public_events.csv +4 -0
  36. data/spec/fixtures/sample_public_people_properties.csv +4 -0
  37. data/spec/fixtures/test.yml +9 -4
  38. data/spec/lib/evva/android_generator_spec.rb +132 -58
  39. data/spec/lib/evva/config_spec.rb +13 -5
  40. data/spec/lib/evva/google_sheet_spec.rb +60 -72
  41. data/spec/lib/evva/swift_generator_spec.rb +153 -40
  42. metadata +23 -39
  43. data/evva_config.yml +0 -10
  44. data/lib/evva/mixpanel_event.rb +0 -13
  45. data/spec/fixtures/sample_public_enums.html +0 -1
  46. data/spec/fixtures/sample_public_info.html +0 -1
  47. data/spec/fixtures/sample_public_people_properties.html +0 -1
  48. data/spec/fixtures/sample_public_sheet.html +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 87f47c713fe2f646dc5302d44a06e739976bfd6f
4
- data.tar.gz: ed72f81ccb086f03fc21426dee5332260a38aa6b
2
+ SHA256:
3
+ metadata.gz: f74dbff0766dc7623ca1ac518e7636172440511a4470398d594fefef8364fba9
4
+ data.tar.gz: 4793e14af612e48d0e7cf85aa313d5c6c4f92c5eb440be7a853503f39fd093e6
5
5
  SHA512:
6
- metadata.gz: dda81be8b9ea3b174d0d20b8e68846681521574eee808318778ccd7265ec7ae27c185b5f615a010c8d544bf62ef5f3fd47382252476d7e46e8a80dc829c4f997
7
- data.tar.gz: cede59eb52f5858775c0fce0d6ca35621dc0365ace4171bd69f1961d9ea10fcdda4b2139f1fb4bfdb93a2462dafaa3ef0e980fb130eed78fa07bd2b3eb5a8adb
6
+ metadata.gz: ebbee6abfa8abd7e6717f20246a1271a7d7b35e4b9a42414293ff436cff842e82ac45beb7638dc642cdb00c1408f7c81cb4b8dcfdd7d4ee6dafa04f121388b5a
7
+ data.tar.gz: 18c42c24f8f2b7d923c9a99b5ec58a43d258340b2523fdb4bf8f136bb0d4d9a075f3497b4c0c8a8176c4e01b07db56f116066b1139389104497db86e6ed9e30b
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  *.sublime-*
2
- .ruby-version
3
2
  running
4
3
  coverage
5
4
  .DS_Store*
6
- .byebug_history
5
+ .byebug_history
data/.rspec CHANGED
@@ -1,5 +1,4 @@
1
1
  --color
2
2
  --format documentation
3
3
  --profile
4
- --drb
5
4
  --require spec_helper
data/.rubocop_todo.yml CHANGED
@@ -57,8 +57,8 @@ Layout/EmptyLinesAroundBlockBody:
57
57
  Layout/EmptyLinesAroundClassBody:
58
58
  Exclude:
59
59
  - 'lib/evva/android_generator.rb'
60
- - 'lib/evva/mixpanel_enum.rb'
61
- - 'lib/evva/mixpanel_event.rb'
60
+ - 'lib/evva/analytics_enum.rb'
61
+ - 'lib/evva/analytics_event.rb'
62
62
 
63
63
  # Offense count: 1
64
64
  # Cop supports --auto-correct.
@@ -163,8 +163,8 @@ Layout/TrailingBlankLines:
163
163
  - 'lib/evva/enum_generator.rb'
164
164
  - 'lib/evva/event_generator.rb'
165
165
  - 'lib/evva/google_sheet.rb'
166
- - 'lib/evva/mixpanel_enum.rb'
167
- - 'lib/evva/mixpanel_event.rb'
166
+ - 'lib/evva/analytics_enum.rb'
167
+ - 'lib/evva/analytics_event.rb'
168
168
  - 'spec/lib/evva/enum_generator_spec.rb'
169
169
  - 'spec/lib/evva/event_generator_spec.rb'
170
170
  - 'spec/lib/evva/google_sheet_spec.rb'
@@ -226,8 +226,8 @@ Lint/UselessAssignment:
226
226
  # Offense count: 2
227
227
  Lint/Void:
228
228
  Exclude:
229
- - 'lib/evva/mixpanel_enum.rb'
230
- - 'lib/evva/mixpanel_event.rb'
229
+ - 'lib/evva/analytics_enum.rb'
230
+ - 'lib/evva/analytics_event.rb'
231
231
 
232
232
  # Offense count: 8
233
233
  Metrics/AbcSize:
@@ -309,8 +309,8 @@ Style/Documentation:
309
309
  - 'lib/evva/event_generator.rb'
310
310
  - 'lib/evva/google_sheet.rb'
311
311
  - 'lib/evva/logger.rb'
312
- - 'lib/evva/mixpanel_enum.rb'
313
- - 'lib/evva/mixpanel_event.rb'
312
+ - 'lib/evva/analytics_enum.rb'
313
+ - 'lib/evva/analytics_event.rb'
314
314
 
315
315
  # Offense count: 1
316
316
  # Cop supports --auto-correct.
@@ -407,8 +407,8 @@ Style/RaiseArgs:
407
407
  # Cop supports --auto-correct.
408
408
  Style/RedundantSelf:
409
409
  Exclude:
410
- - 'lib/evva/mixpanel_enum.rb'
411
- - 'lib/evva/mixpanel_event.rb'
410
+ - 'lib/evva/analytics_enum.rb'
411
+ - 'lib/evva/analytics_event.rb'
412
412
  - 'lib/evva/object_extension.rb'
413
413
 
414
414
  # Offense count: 1
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile CHANGED
@@ -1,13 +1,14 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.3.3'
3
2
 
4
3
  gem 'colorize'
5
- gem 'rubocop'
6
4
  gem 'safe_yaml'
7
- gem 'xml-simple'
8
5
 
9
- gem 'rspec'
10
- gem 'rspec-its'
11
- gem 'simplecov', require: false, group: :test
12
- gem 'simplecov-rcov', require: false
13
- gem 'webmock', '~> 1.20'
6
+ group :test do
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ gem 'rspec-its'
10
+ gem 'simplecov', require: false, group: :test
11
+ gem 'simplecov-rcov', require: false
12
+ gem 'webmock', '~> 1.20'
13
+ gem 'rubocop'
14
+ end
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- addressable (2.5.2)
5
- public_suffix (>= 2.0.2, < 4.0)
4
+ addressable (2.8.0)
5
+ public_suffix (>= 2.0.2, < 5.0)
6
6
  ast (2.3.0)
7
7
  colorize (0.8.1)
8
8
  crack (0.4.3)
@@ -10,15 +10,15 @@ GEM
10
10
  diff-lcs (1.3)
11
11
  docile (1.1.5)
12
12
  hashdiff (0.3.7)
13
- json (2.1.0)
13
+ json (2.3.0)
14
14
  parallel (1.12.0)
15
15
  parser (2.4.0.0)
16
16
  ast (~> 2.2)
17
17
  powerpack (0.1.1)
18
- public_suffix (3.0.0)
18
+ public_suffix (4.0.6)
19
19
  rainbow (2.2.2)
20
20
  rake
21
- rake (12.1.0)
21
+ rake (12.3.3)
22
22
  rspec (3.7.0)
23
23
  rspec-core (~> 3.7.0)
24
24
  rspec-expectations (~> 3.7.0)
@@ -56,13 +56,13 @@ GEM
56
56
  addressable (>= 2.3.6)
57
57
  crack (>= 0.3.2)
58
58
  hashdiff
59
- xml-simple (1.1.5)
60
59
 
61
60
  PLATFORMS
62
61
  ruby
63
62
 
64
63
  DEPENDENCIES
65
64
  colorize
65
+ rake
66
66
  rspec
67
67
  rspec-its
68
68
  rubocop
@@ -70,10 +70,6 @@ DEPENDENCIES
70
70
  simplecov
71
71
  simplecov-rcov
72
72
  webmock (~> 1.20)
73
- xml-simple
74
-
75
- RUBY VERSION
76
- ruby 2.3.3p222
77
73
 
78
74
  BUNDLED WITH
79
- 1.15.4
75
+ 2.2.26
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
1
  Evva
2
+ ========
3
+
4
+ [![Status](https://travis-ci.org/hole19/evva.svg?branch=master)](https://travis-ci.org/hole19/evva?branch=master)
5
+ [![Gem](https://img.shields.io/gem/v/evva.svg?style=flat)](http://rubygems.org/gems/evva "View this project in Rubygems")
6
+
7
+ Evva automatically generates code for triggering events based on a Google Sheets specification. It generated code for both iOS (Swift) and Android (Kotlin).
2
8
 
3
9
  # Instalation
4
10
 
@@ -18,11 +24,15 @@ Evva
18
24
 
19
25
  data_source:
20
26
  type: google_sheet
21
- sheet_id: <GOOGLE-DRIVE-SHEET-ID>
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>
22
30
 
23
31
  out_path: /folder/where/analytics/classes/are
24
32
  event_file_name: /file/with/tracking/functions
25
33
  event_enum_file_name: /file/with/event/names
26
34
  people_file_name: /file/with/people/properties
27
- special_enum_file_name: //file/with/special/enum/properties/
35
+ people_file_name: /file/with/people/property/names
36
+ destinations_file_name: /file/with/destinations
37
+ special_enum_file_name: /file/with/special/enum/properties/
28
38
  ```
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "rake"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.pattern = Dir.glob("spec/**/*_spec.rb")
6
+ t.rspec_opts = "--format documentation"
7
+ end
8
+
9
+ task default: :spec
data/changelog.md CHANGED
@@ -1,4 +1,20 @@
1
1
  # Change Log
2
+
3
+ ## [0.4.0] - 2021-12-21
4
+ - Adds type to people properties
5
+ - Adds a list of destinations to events and people properties
6
+
7
+ ## [0.3.0] - 2021-12-16
8
+ - Revamp Android generator to generate events as classes instead of methods.
9
+
10
+ ## [0.2.0] - 2021-08-30
11
+ - Google Spreadsheet option stopped working due to a change in the API. This version fixes that.
12
+
13
+ Note: You'll need a new setup. View README.
14
+
15
+ ## [0.1.4.4] - 2019-02-04
16
+ - Adds support for dynamic android package name
17
+
2
18
  ## [0.1.4.3] - 2018-10-12
3
19
  - Fixes swift and kotlin tabs, indentation and property names
4
20
  - Merges all special enums in a single file
@@ -23,5 +39,6 @@
23
39
  ## [0.1.1] - 2017-11-07
24
40
  - Fixes mismatch between file name and class name generated.
25
41
 
26
- ## [0.1.0] - 2017/10/26
42
+ ## [0.1.0] - 2017-10-26
27
43
  - Initial Release.
44
+
data/evva.gemspec CHANGED
@@ -18,7 +18,4 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_runtime_dependency 'safe_yaml', '~> 1.0'
20
20
  s.add_runtime_dependency 'colorize', '~> 0.7'
21
- s.add_runtime_dependency 'xml-simple', '~> 1.1'
22
-
23
- s.add_development_dependency 'webmock', '~> 1.20'
24
21
  end
@@ -1,6 +1,7 @@
1
1
  module Evva
2
- class MixpanelEnum
2
+ class AnalyticsEnum
3
3
  attr_reader :enum_name, :values
4
+
4
5
  def initialize(enum_name, values)
5
6
  @enum_name = enum_name
6
7
  @values = values
@@ -0,0 +1,17 @@
1
+ module Evva
2
+ class AnalyticsEvent
3
+ attr_reader :event_name, :properties, :destinations
4
+
5
+ def initialize(event_name, properties, destinations)
6
+ @event_name = event_name
7
+ @properties = properties
8
+ @destinations = destinations
9
+ end
10
+
11
+ def ==(other)
12
+ event_name == other.event_name &&
13
+ properties == other.properties &&
14
+ destinations == other.destinations
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Evva
2
+ class AnalyticsProperty
3
+ attr_reader :property_name, :type, :destinations
4
+
5
+ def initialize(property_name, type, destinations)
6
+ @property_name = property_name
7
+ @type = type
8
+ @destinations = destinations
9
+ end
10
+
11
+ def ==(other)
12
+ property_name == other.property_name &&
13
+ type == other.type &&
14
+ destinations == other.destinations
15
+ end
16
+ end
17
+ end
@@ -1,125 +1,182 @@
1
1
  module Evva
2
2
  class AndroidGenerator
3
+ attr_accessor :package_name
3
4
 
4
- def events(bundle, file_name)
5
- header_footer_wrapper([IMPORT_EVENT, IMPORT_MASK, IMPORT_JSON]) do
6
- """open class #{file_name}(private val mask: MixpanelAnalyticsMask) {
5
+ def initialize(package_name)
6
+ @package_name = package_name
7
+ end
7
8
 
8
- #{bundle.map { |e| kotlin_function(e) }.join("\n\n")}
9
+ BASE_TEMPLATE = File.expand_path("./templates/kotlin/base.kt", __dir__)
10
+ EVENTS_TEMPLATE = File.expand_path("./templates/kotlin/events.kt", __dir__)
11
+ EVENT_ENUM_TEMPLATE = File.expand_path("./templates/kotlin/event_enum.kt", __dir__)
12
+ PEOPLE_PROPERTIES_TEMPLATE = File.expand_path("./templates/kotlin/people_properties.kt", __dir__)
13
+ PEOPLE_PROPERTIES_ENUM_TEMPLATE = File.expand_path("./templates/kotlin/people_properties_enum.kt", __dir__)
14
+ SPECIAL_PROPERTY_ENUMS_TEMPLATE = File.expand_path("./templates/kotlin/special_property_enums.kt", __dir__)
15
+ DESTINATIONS_TEMPLATE = File.expand_path("./templates/kotlin/destinations.kt", __dir__)
9
16
 
10
- \topen fun updateProperties(property: MixpanelProperties, value: Any) {
11
- \t\tmask.updateProperties(property.key, value)
12
- \t}
17
+ TAB_SIZE = " " # \t -> 4 spaces
13
18
 
14
- \topen fun incrementCounter(property: MixpanelProperties) {
15
- \t\tmask.incrementCounter(property.key)
16
- \t}
17
- }"""
18
- end
19
- end
19
+ NATIVE_TYPES = %w[Long Int String Double Float Boolean Date].freeze
20
20
 
21
- def people_properties(people_bundle, file_name)
21
+ def events(bundle, file_name, enums_file_name, destinations_file_name)
22
22
  header_footer_wrapper do
23
- body = "enum class MixpanelProperties(val key: String) {\n"
24
- body << people_bundle.map { |prop| "\t#{prop.upcase}(\"#{prop}\")" }.join(",\n")
25
- body << ";\n}"
23
+ class_name = file_name
24
+ enums_class_name = enums_file_name
25
+ destinations_class_name = destinations_file_name
26
+
27
+ events = bundle.map do |event|
28
+ properties = event.properties.map do |name, type|
29
+ param_name = camelize(name.to_s, false)
30
+ value_fetcher = param_name
31
+
32
+ if is_special_property?(type)
33
+ if type.end_with?('?')
34
+ # optional value, we need ? to access a parameter
35
+ value_fetcher += "?"
36
+ end
37
+ value_fetcher += ".key"
38
+ end
39
+
40
+ {
41
+ param_name: param_name,
42
+ value_fetcher: value_fetcher,
43
+ type: type,
44
+ name: name.to_s,
45
+ }
46
+ end
47
+
48
+ destinations = event.destinations.map { |p| constantize(p) }
49
+
50
+ {
51
+ class_name: camelize(event.event_name),
52
+ event_name: constantize(event.event_name),
53
+ properties: properties,
54
+ destinations: destinations,
55
+ is_object: properties.count == 0 && destinations.count == 0,
56
+ }
57
+ end
58
+
59
+ template_from(EVENTS_TEMPLATE).result(binding)
26
60
  end
27
61
  end
28
62
 
29
63
  def event_enum(bundle, file_name)
30
- header_footer_wrapper([IMPORT_EVENT]) do
31
- body = "enum class #{file_name}(override val key: String) : Event {\n"
32
- body << bundle.map(&:event_name).map { |prop| "\t#{prop.upcase}(\"#{prop}\")" }.join(",\n")
33
- body << ";\n}"
64
+ header_footer_wrapper do
65
+ class_name = file_name
66
+
67
+ events = bundle.map(&:event_name).map do |event_name|
68
+ {
69
+ name: constantize(event_name),
70
+ value: event_name,
71
+ }
72
+ end
73
+
74
+ template_from(EVENT_ENUM_TEMPLATE).result(binding)
34
75
  end
35
76
  end
36
77
 
37
- def special_property_enums(enums)
78
+ def people_properties(people_bundle, file_name, enums_file_name, destinations_file_name)
38
79
  header_footer_wrapper do
39
- enums.map do |enum|
40
- body = "enum class #{enum.enum_name}(val key: String) {\n"
41
- body << enum.values.map { |vals| "\t#{vals.tr(' ', '_').upcase}(\"#{vals}\")"}.join(",\n")
42
- body << ";\n}"
43
- end.join("\n\n")
80
+ class_name = file_name
81
+ enums_class_name = enums_file_name
82
+ destinations_class_name = destinations_file_name
83
+
84
+ properties = people_bundle.map do |property|
85
+ {
86
+ class_name: camelize(property.property_name),
87
+ property_name: constantize(property.property_name),
88
+ type: property.type,
89
+ is_special_property: is_special_property?(property.type),
90
+ destinations: property.destinations.map { |p| constantize(p) },
91
+ }
92
+ end
93
+
94
+ template_from(PEOPLE_PROPERTIES_TEMPLATE).result(binding)
44
95
  end
45
96
  end
46
97
 
47
- IMPORT_EVENT = "import com.hole19golf.hole19.analytics.Event".freeze
48
- IMPORT_MASK = "import com.hole19golf.hole19.analytics.MixpanelAnalyticsMask".freeze
49
- IMPORT_JSON = "import org.json.JSONObject".freeze
50
-
51
- NATIVE_TYPES = %w[Long Int String Double Float Boolean].freeze
98
+ def people_properties_enum(people_bundle, file_name)
99
+ header_footer_wrapper do
100
+ class_name = file_name
52
101
 
53
- private
102
+ properties = people_bundle.map(&:property_name).map do |property_name|
103
+ {
104
+ name: constantize(property_name),
105
+ value: property_name,
106
+ }
107
+ end
54
108
 
55
- def imports_header(imports = [])
56
- return unless imports.length > 0
57
- imports.join("\n") + "\n\n"
109
+ template_from(PEOPLE_PROPERTIES_ENUM_TEMPLATE).result(binding)
110
+ end
58
111
  end
59
112
 
60
- def header_footer_wrapper(imports = [])
61
- <<-Kotlin
62
- package com.hole19golf.hole19.analytics
113
+ def special_property_enums(enums_bundle)
114
+ header_footer_wrapper do
115
+ enums = enums_bundle.map do |enum|
116
+ values = enum.values.map do |value|
117
+ {
118
+ name: constantize(value),
119
+ value: value,
120
+ }
121
+ end
63
122
 
64
- #{imports_header(imports)}/**
65
- * This file was automatically generated by evva: https://github.com/hole19/evva
66
- */
123
+ {
124
+ class_name: enum.enum_name,
125
+ values: values,
126
+ }
127
+ end
67
128
 
68
- #{yield.gsub("\t", " ")}
69
- Kotlin
129
+ template_from(SPECIAL_PROPERTY_ENUMS_TEMPLATE).result(binding)
130
+ end
70
131
  end
71
132
 
72
- def kotlin_function(event_data)
73
- function_name = 'track' + titleize(event_data.event_name)
74
- function_arguments = event_data.properties.map { |name, type| "#{name}: #{type}" }.join(', ')
75
- if !function_arguments.empty?
76
- props = json_props(event_data.properties)
77
- """\topen fun #{function_name}(#{function_arguments}) {
78
- #{props}
79
- \t\tmask.trackEvent(MixpanelEvent.#{event_data.event_name.upcase}, properties)
80
- \t}"""
133
+ def destinations(bundle, file_name)
134
+ header_footer_wrapper do
135
+ class_name = file_name
81
136
 
82
- else
83
- """\topen fun #{function_name}() {
84
- \t\tmask.trackEvent(MixpanelEvent.#{event_data.event_name.upcase})
85
- \t}"""
137
+ destinations = bundle.map { |d| constantize(d) }
138
+
139
+ template_from(DESTINATIONS_TEMPLATE).result(binding)
86
140
  end
87
141
  end
88
142
 
89
- def json_props(properties)
90
- split_properties =
91
- properties
92
- .map do |name, type|
93
- if special_property?(type)
94
- if optional_property?(type)
95
- "#{name}?.let { put(\"#{name}\", it.key) }"
96
- else
97
- "put(\"#{name}\", #{name}.key)"
98
- end
99
- else
100
- if optional_property?(type)
101
- "#{name}?.let { put(\"#{name}\", it) }"
102
- else
103
- "put(\"#{name}\", #{name})"
104
- end
105
- end
106
- end
107
- .map { |line| "\t\t\t#{line}" }
108
- .join("\n")
143
+ private
144
+
145
+ def header_footer_wrapper
146
+ package_name = @package_name
147
+
148
+ content = yield
149
+ .chop # trim trailing newlines created by sublime
109
150
 
110
- "\t\tval properties = JSONObject().apply {\n#{split_properties}\n\t\t}"
151
+ template_from(BASE_TEMPLATE).result(binding).gsub("\t", TAB_SIZE)
111
152
  end
112
153
 
113
- def special_property?(type)
114
- !NATIVE_TYPES.include?(type.chomp('?'))
154
+ def template_from(path)
155
+ file = File.read(path)
156
+
157
+ # - 2nd argument (nil) changes nothing
158
+ # - 3rd argument activates trim mode using "-" so that you can decide to
159
+ # not include a line (useful on loops and if statements)
160
+ ERB.new(file, nil, '-')
115
161
  end
116
162
 
117
- def optional_property?(type)
118
- type.include?('?')
163
+ # extracted from Rails' ActiveSupport
164
+ def camelize(string, uppercase_first_letter = true)
165
+ string = string.to_s
166
+ if uppercase_first_letter
167
+ string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
168
+ else
169
+ string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
170
+ end
171
+ string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub("/", "::")
119
172
  end
120
173
 
121
- def titleize(str)
122
- str.split('_').collect(&:capitalize).join
174
+ def constantize(string)
175
+ string.tr(' ', '_').upcase
176
+ end
177
+
178
+ def is_special_property?(type)
179
+ !NATIVE_TYPES.include?(type.chomp('?'))
123
180
  end
124
181
  end
125
182
  end
data/lib/evva/config.rb CHANGED
@@ -31,18 +31,30 @@ module Evva
31
31
  @hash[:event_file_name]
32
32
  end
33
33
 
34
+ def event_enum_file_name
35
+ @hash[:event_enum_file_name]
36
+ end
37
+
34
38
  def people_file_name
35
39
  @hash[:people_file_name]
36
40
  end
37
41
 
38
- def event_enum_file_name
39
- @hash[:event_enum_file_name]
42
+ def people_enum_file_name
43
+ @hash[:people_enum_file_name]
40
44
  end
41
45
 
42
46
  def special_enum_file_name
43
47
  @hash[:special_enum_file_name]
44
48
  end
45
49
 
50
+ def destinations_file_name
51
+ @hash[:destinations_file_name]
52
+ end
53
+
54
+ def package_name
55
+ @hash[:package_name]
56
+ end
57
+
46
58
  CONFIG_STRUCT = {
47
59
  type: Hash,
48
60
  elements: {
@@ -53,7 +65,10 @@ module Evva
53
65
  out_path: { type: String },
54
66
  event_file_name: { type: String },
55
67
  event_enum_file_name: { type: String },
56
- people_file_name: { type: String }
68
+ people_file_name: { type: String },
69
+ people_enum_file_name: { type: String },
70
+ destinations_file_name: { type: String },
71
+ package_name: { type: String }
57
72
  }
58
73
  }.freeze
59
74
 
@@ -61,7 +76,9 @@ module Evva
61
76
  type: Hash,
62
77
  elements: {
63
78
  type: { type: String },
64
- sheet_id: { type: String }
79
+ events_url: { type: String },
80
+ people_properties_url: { type: String },
81
+ enum_classes_url: { type: String },
65
82
  }
66
83
  }.freeze
67
84