Sha256: c3c5dd72639b69073e3879377b07de98a50a79dc0cece210a323b409ecbcc22b

Contents?: true

Size: 745 Bytes

Versions: 10

Compression:

Stored size: 745 Bytes

Contents

module LogStasher
  module Device
    def self.factory(config)
      config = stringify_keys(config)
      type   = config.delete('type') or fail ArgumentError, 'No "type" given'

      case type
      when 'redis', :redis then
        require 'logstasher/device/redis'
        ::LogStasher::Device::Redis.new(config)
      when "syslog", :syslog then
        require 'logstasher/device/syslog'
        ::LogStasher::Device::Syslog.new(config)
      else
        fail ArgumentError, "Unknown type: #{type}"
      end
    end

    def stringify_keys(hash)
      hash.inject({}) do |stringified_hash, (key, value)|
        stringified_hash[key.to_s] = value
        stringified_hash
      end
    end
    module_function :stringify_keys
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
md-logstasher-1.2.0 lib/logstasher/device.rb
md-logstasher-1.1.0 lib/logstasher/device.rb
md-logstasher-1.0.5 lib/logstasher/device.rb
md-logstasher-1.0.4 lib/logstasher/device.rb
md-logstasher-1.0.3 lib/logstasher/device.rb
md-logstasher-1.0.2 lib/logstasher/device.rb
md-logstasher-1.0.1 lib/logstasher/device.rb
md-logstasher-1.0.0 lib/logstasher/device.rb
md-logstasher-1.0.0.rc5 lib/logstasher/device.rb
md-logstasher-1.0.0.rc4 lib/logstasher/device.rb