Class: Franz::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/franz/config.rb

Overview

All things configuration.

Class Method Summary collapse

Class Method Details

.new(path) ⇒ Hash

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).

Parameters:

  • path (String)

    path to a config file

Returns:

  • (Hash)

    config compiled into a native Hash



14
15
16
17
18
19
20
21
22
23
24
25
26
# 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