Module: AppStack::ConfigParser
- Included in:
- App
- Defined in:
- lib/app_stack/configuration.rb
Overview
reopen App, mixin
Instance Method Summary collapse
- #load_config ⇒ Object
-
#parse_export_groups! ⇒ Object
rubocop:disable LineLength, MethodLength.
- #validate_config! ⇒ Object
Instance Method Details
#load_config ⇒ Object
41 42 43 44 |
# File 'lib/app_stack/configuration.rb', line 41 def load_config info 'load configuration file from:', @conf_file Configuration.new(@conf_file) end |
#parse_export_groups! ⇒ Object
rubocop:disable LineLength, MethodLength
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/app_stack/configuration.rb', line 59 def parse_export_groups! @export_groups = { 'default' => [] } config.export.each do |exp| case when exp.is_a?(Hash) then @export_groups.merge!(exp) when exp.is_a?(String) then @export_groups['default'] << exp else fail ParseError, "Error on #{@conf_file}, wrong type for export: '#{exp.inspect}'" end end # validate export file list format @export_groups.each do |gname, list| fail ParseError, "Error on #{@conf_file}, group name must be an String, not #{gname}" unless gname.is_a?(String) fail ParseError, "Error on #{@conf_file} export group #{gname}, export files should be defined as a Array of String, #{list} is not an array." unless list.is_a?(Array) list.each { |f| fail ParseError, "Error on #{@conf_file} export group #{gname}, export files should be defined as a Array of string, not #{f}" unless f.is_a?(String) } end @export_groups end |
#validate_config! ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/app_stack/configuration.rb', line 46 def validate_config! parse_export_groups! @sync_list = parse_stack_list!('sync') info 'load sync list as', @sync_list @import_list = parse_stack_list!('import') info 'load import list as', @import_list @render_list = parse_render_list! # rubocop:disable LineLength config.exclude.each { |f| fail "Error on #{@conf_file} for exclude settings, #{f.inspect} is not a String" unless f.is_a?(String) } end |