Sha256: 94098639806d92c083bfaaf4940be0fa6ad99f4575092a7c7a7ec5b1f6497378

Contents?: true

Size: 1021 Bytes

Versions: 2

Compression:

Stored size: 1021 Bytes

Contents

require 'yaml'

ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))

module Redirus
  class Config
    def initialize(path=nil)
      if File.exists?(path)
        @config = YAML.load_file(path)
      else
        @config = {}
      end
    end

    def queues
      @config['queues'] || ['default']
    end

    def redis_url
      @config['redis_url'] || 'redis://localhost:6379'
    end

    def namespace
      @config['namespace'] || 'redirus'
    end

    def nginx_pid_file
      nginx_prop :pid, 'nginx.pid'
    end

    def configs_path
      nginx_prop :configs_path, 'sites-enabled'
    end

    def http_template
      nginx_prop :http_template, 'http.conf.erb'
    end

    def https_template
      nginx_prop :https_template, 'https.conf.erb'
    end

    def allowed_properties
      nginx_prop :allowed_properties, []
    end

    private

    def nginx_prop(type, default=nil)
      value = @config['nginx'][type.to_s] if @config['nginx']
      value || default
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redirus-0.3.1 lib/redirus/config.rb
redirus-0.2.1 lib/redirus/config.rb