class Franz::Config

All things configuration.

Public Class Methods

new(path) click to toggle source

Load a config file path into a Hash, converting to some native types where appropriate (e.g. a String denoting a Regexp will become Regexp).

@param path [String] path to a config file

@return [Hash] config compiled into a native Hash

# File lib/franz/config.rb, line 14
def self.new path
  config = JSON::parse File.read(path), symbolize_names: true
  config = {
    input: { configs: [] },
    output: {}
  }.deep_merge!(config)
  config[:input][:configs].map! do |input|
    input[:multiline] = Regexp.new input[:multiline] if input.has_key?(:multiline)
    input[:type] = input[:type].to_sym
    input
  end
  return config
end