Sha256: b462d0bb3e8399273025bb1fc28a0615c69ca83dbe5a6846af95daac7d19ce18

Contents?: true

Size: 916 Bytes

Versions: 7

Compression:

Stored size: 916 Bytes

Contents

require 'settings'
require 'uri'
require 'input_validator'

# Class that deals with Redis server configuration options
class RedisConf
  extend InputValidator

  # Read and parse Redis server configuration options
  #
  # @return [Hash] redis server options ready for use
  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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
oneacct-export-0.5.0 lib/redis_conf.rb
oneacct-export-0.4.6 lib/redis_conf.rb
oneacct-export-0.4.5 lib/redis_conf.rb
oneacct-export-0.4.4 lib/redis_conf.rb
oneacct-export-0.4.3 lib/redis_conf.rb
oneacct-export-0.4.2 lib/redis_conf.rb
oneacct-export-0.3.0 lib/redis_conf.rb