Class: Evva::Config
- Inherits:
-
Object
- Object
- Evva::Config
- Defined in:
- lib/evva/config.rb
Constant Summary collapse
- CONFIG_STRUCT =
{ type: Hash, elements: { type: { type: String }, data_source: { type: Hash, elements: { type: { type: String } } }, out_path: { type: String }, event_file_name: { type: String }, event_enum_file_name: { type: String }, people_file_name: { type: String }, people_enum_file_name: { type: String }, destinations_file_name: { type: String }, package_name: { type: String }, swift_public: { type: Object, optional: true }, exclude_destinations: { type: Array, optional: true } } }.freeze
- GOOGLE_SHEET_STRUCT =
{ type: Hash, elements: { type: { type: String }, events_url: { type: String }, people_properties_url: { type: String }, enum_classes_url: { type: String }, } }.freeze
- DICTIONARY_STRUCT =
{ "google_sheet" => GOOGLE_SHEET_STRUCT }.freeze
Instance Method Summary collapse
- #data_source ⇒ Object
- #destinations_file_name ⇒ Object
- #event_enum_file_name ⇒ Object
- #event_file_name ⇒ Object
- #exclude_destinations ⇒ Object
-
#initialize(hash:) ⇒ Config
constructor
A new instance of Config.
- #out_path ⇒ Object
- #package_name ⇒ Object
- #people_enum_file_name ⇒ Object
- #people_file_name ⇒ Object
- #special_enum_file_name ⇒ Object
- #swift_public? ⇒ Boolean
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(hash:) ⇒ Config
Returns a new instance of Config.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/evva/config.rb', line 3 def initialize(hash:) @hash = hash.deep_symbolize @hash.validate_structure!(CONFIG_STRUCT) unless dict_struct = DICTIONARY_STRUCT[@hash[:data_source][:type]] raise ArgumentError, "unknown data source type '#{@hash[:data_source][:type]}'" end @hash[:data_source].validate_structure!(dict_struct) if @hash.key?(:swift_public) && ![true, false].include?(@hash[:swift_public]) raise ArgumentError, "swift_public must be true or false" end end |
Instance Method Details
#data_source ⇒ Object
23 24 25 |
# File 'lib/evva/config.rb', line 23 def data_source @hash[:data_source] end |
#destinations_file_name ⇒ Object
55 56 57 |
# File 'lib/evva/config.rb', line 55 def destinations_file_name @hash[:destinations_file_name] end |
#event_enum_file_name ⇒ Object
39 40 41 |
# File 'lib/evva/config.rb', line 39 def event_enum_file_name @hash[:event_enum_file_name] end |
#event_file_name ⇒ Object
35 36 37 |
# File 'lib/evva/config.rb', line 35 def event_file_name @hash[:event_file_name] end |
#exclude_destinations ⇒ Object
67 68 69 |
# File 'lib/evva/config.rb', line 67 def exclude_destinations @hash[:exclude_destinations] || [] end |
#out_path ⇒ Object
31 32 33 |
# File 'lib/evva/config.rb', line 31 def out_path @hash[:out_path] end |
#package_name ⇒ Object
59 60 61 |
# File 'lib/evva/config.rb', line 59 def package_name @hash[:package_name] end |
#people_enum_file_name ⇒ Object
47 48 49 |
# File 'lib/evva/config.rb', line 47 def people_enum_file_name @hash[:people_enum_file_name] end |
#people_file_name ⇒ Object
43 44 45 |
# File 'lib/evva/config.rb', line 43 def people_file_name @hash[:people_file_name] end |
#special_enum_file_name ⇒ Object
51 52 53 |
# File 'lib/evva/config.rb', line 51 def special_enum_file_name @hash[:special_enum_file_name] end |
#swift_public? ⇒ Boolean
63 64 65 |
# File 'lib/evva/config.rb', line 63 def swift_public? @hash[:swift_public] == true end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/evva/config.rb', line 19 def to_h @hash end |
#type ⇒ Object
27 28 29 |
# File 'lib/evva/config.rb', line 27 def type @hash[:type] end |