class RedisConf

Class that deals with Redis server configuration options

Public Class Methods

options() click to toggle source

Read and parse Redis server configuration options

@return [Hash] redis server options ready for use

# File lib/redis_conf.rb, line 12
def self.options
  options = {}
  if Settings['redis']
    options[:namespace] = Settings.redis['namespace']
    options[:url] = Settings.redis['url']
  end

  options[:namespace] ||= 'oneacct_export'
  options[:url] ||= 'redis://localhost:6379'

  fail ArgumentError, "#{options[:url]} is not a valid URL."\
    unless uri?(options[:url])

  if Settings['redis'] && Settings.redis['password']
    fail ArgumentError, 'Redis password cannot be empty'\
      if Settings.redis['password'].empty?
    options[:url].insert(options[:url].index('/') + 2, ":#{Settings.redis['password']}@")
  end

  options
end