Class: TreasureData::ConnectorConfigNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/td/connector_config_normalizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConnectorConfigNormalizer

Returns a new instance of ConnectorConfigNormalizer.



3
4
5
# File 'lib/td/connector_config_normalizer.rb', line 3

def initialize(config)
  @config = config
end

Instance Method Details

#normalized_configObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/td/connector_config_normalizer.rb', line 7

def normalized_config
  case
  when @config['in']
    {
      'in'      => @config['in'],
      'out'     => @config['out']  || {},
      'exec'    => @config['exec'] || {},
      'filters' => @config['filters'] || []
    }
  when @config['config']
    if @config.size != 1
      raise "Setting #{(@config.keys - ['config']).inspect} keys in a configuration file is not supported. Please set options to the command line argument."
    end

    self.class.new(@config['config']).normalized_config
  else
    {
      'in'   => @config,
      'out'  => {},
      'exec' => {},
      'filters' => []
    }
  end
end