Class: Redirus::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/redirus/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
# File 'lib/redirus/config.rb', line 7

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

Instance Method Details

#allowed_propertiesObject



61
62
63
# File 'lib/redirus/config.rb', line 61

def allowed_properties
  nginx_prop :allowed_properties, []
end

#config_templateObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/redirus/config.rb', line 46

def config_template
  nginx_prop :config_template, %q[#{upstream}

server {
  #{listen}

  server_name #{name}.localhost;
  server_tokens off;

  location / {
proxy_pass http://#{upstream_name};
  }
}]
end

#configs_pathObject



31
32
33
# File 'lib/redirus/config.rb', line 31

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

#http_templateObject



35
36
37
# File 'lib/redirus/config.rb', line 35

def http_template
  nginx_prop :http_template, 'listen *:80;'
end

#https_templateObject



39
40
41
42
43
44
# File 'lib/redirus/config.rb', line 39

def https_template
  nginx_prop :https_template, %q[listen *:443 ssl;
ssl_certificate     /usr/share/ssl/certs/localhost/host.cert;
ssl_certificate_key /usr/share/ssl/certs/localhost/host.key;
]
end

#namespaceObject



23
24
25
# File 'lib/redirus/config.rb', line 23

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

#nginx_pid_fileObject



27
28
29
# File 'lib/redirus/config.rb', line 27

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

#queuesObject



15
16
17
# File 'lib/redirus/config.rb', line 15

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

#redis_urlObject



19
20
21
# File 'lib/redirus/config.rb', line 19

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