Method: AppStack::ConfigParser#parse_export_groups!

Defined in:
lib/app_stack/configuration.rb

#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