Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

nginx: fix borkd gem

  • Loading branch information...
commit 13338628acc485c05d408d0837a3cda08fdf1828 1 parent c6cd3ca
@defunkt authored
View
8 Manifest
@@ -0,0 +1,8 @@
+LICENSE
+Manifest
+README
+Rakefile
+bin/generate_nginx_config
+lib/config.yml.example
+lib/nginx.erb
+lib/nginx_config_generator.rb
View
2  Rakefile
@@ -1,7 +1,7 @@
require 'rubygems'
require 'echoe'
-Echoe.new('nginx_config_generator', '1.2') do |p|
+Echoe.new('nginx_config_generator', '1.3') do |p|
p.rubyforge_name = 'err'
p.author = 'Chris Wanstrath'
p.email = 'chris@ozmm.org'
View
1  lib/config.yml.example
@@ -60,6 +60,7 @@ ssl_sites:
- 127.0.0.1:8000
- 127.0.0.1:8001
no_www: true
+ server_name: errtheblog.com
# Just strings that get spit out as rewrites
rewrites:
- ^/feed/feedburner http://feeds.feedburner.com/errtheblog
View
10 lib/nginx.erb
@@ -53,18 +53,18 @@ http {
# this is where you define your mongrel clusters.
# you need one of these blocks for each cluster
# and each one needs its own name to refer to it later.
-<% config['sites'].each do |name, site| %>
-<% next unless site['upstream'] %>
+<% Array(config['sites']).each do |name, site| %>
+ <% next unless site['upstream'] %>
upstream <%= name %> {
-<% Array(site['upstream'] || site['upstreams']).each do |server| %>
+ <% Array(site['upstream'] || site['upstreams']).each do |server| %>
server <%= server %>;
-<% end %>
+ <% end %>
}
<% end %>
<% %w(sites ssl_sites).each do |site_type| %>
-<% config[site_type].each do |name, site| %>
+<% Array(config[site_type]).each do |name, site| %>
# the server directive is nginx's virtual host directive.
server {
View
6 lib/nginx_config_generator.rb
@@ -14,14 +14,14 @@ def file(file) "#{File.dirname(__FILE__)}/#{file}" end
error "Usage: generate_nginx_config [config file] [out file]" if ARGV.empty? && !env_in
-overwrite = !(%w(-y -o -f --force --overwrite) & ARGV).empty?
+overwrite = %w(-y -o -f --force --overwrite).any? { |f| ARGV.delete(f) }
-config = YAML.load(ERB.new(env_in || ARGV.shift || 'config.yml').result)
+config = YAML.load_file(ERB.new(env_in || ARGV.shift || 'config.yml').result)
template = file:'nginx.erb'
if File.exists?(out_file = env_out || ARGV.shift || 'nginx.conf') && !overwrite
error "=> #{out_file} already exists, won't overwrite it. Quitting."
else
- open(out_file, 'w+').write(ERB.new(File.read(template), nil, '>').result)
+ open(out_file, 'w+').write(ERB.new(File.read(template), nil, '>').result(binding))
error "=> Wrote #{out_file} successfully."
end
Please sign in to comment.
Something went wrong with that request. Please try again.