Module: Fluent::Compat::TextParser::TypeConverterCompatParameters

Included in:
CSVParser, JSONParser, LabeledTSVParser, RegexpParser, TSVParser
Defined in:
lib/fluent/compat/parser.rb

Instance Method Summary collapse

Instance Method Details

#convert_type_converter_parameters!(conf) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/fluent/compat/parser.rb', line 124

def convert_type_converter_parameters!(conf)
  if conf["types"]
    delimiter = conf["types_delimiter"] || ','
    label_delimiter = conf["types_label_delimiter"] || ':'
    types = {}
    conf['types'].split(delimiter).each do |pair|
      key, value = pair.split(label_delimiter, 2)
      if value.start_with?("time#{label_delimiter}")
        value = value.split(label_delimiter, 2).join(':')
      elsif value.start_with?("array#{label_delimiter}")
        value = value.split(label_delimiter, 2).join(':')
      end
      types[key] = value
    end
    conf["types"] = JSON.dump(types)
  end
end