some code cleanup stuff

This commit is contained in:
John Bintz 2010-05-12 14:24:35 -04:00
parent 0d17547925
commit 30c925a4f1
4 changed files with 15 additions and 16 deletions

1
.gitignore vendored
View File

@ -5,5 +5,6 @@ docs/*
pkg/* pkg/*
Manifest Manifest
*.gemspec *.gemspec
tmp/*

View File

@ -47,8 +47,8 @@ module Apache
when String when String
@config << "#{which} #{opts * " "}" @config << "#{which} #{opts * " "}"
when Array when Array
which.each do |w| which.each do |tag|
@config << "#{w} #{opts.shift}" @config << "#{tag} #{opts.shift}"
end end
end end
end end

View File

@ -170,7 +170,7 @@ module Apache
module RegularExpressionMatcher module RegularExpressionMatcher
# Test this rewritable thing # Test this rewritable thing
def test(from, opts = {}) def test(from, opts = {})
from = from.gsub(@from, @to.gsub(/\$([0-9])/) { |m| '\\' + $1 }) from = from.gsub(@from, @to.gsub(/\$([0-9])/) { |match| '\\' + $1 })
replace_placeholders(from, opts) replace_placeholders(from, opts)
end end
@ -179,14 +179,14 @@ module Apache
end end
# Replace the placeholders in this rewritable thing # Replace the placeholders in this rewritable thing
def replace_placeholders(s, opts) def replace_placeholders(string, opts)
opts.each do |opt, value| opts.each do |opt, value|
case value case value
when String when String
s = s.gsub('%{' + opt.to_s.upcase + '}', value) string = string.gsub('%{' + opt.to_s.upcase + '}', value)
end end
end end
s.gsub(%r{%\{[^\}]+\}}, '') string.gsub(%r{%\{[^\}]+\}}, '')
end end
end end
@ -387,12 +387,9 @@ module Apache
end end
result = false result = false
case to[0..0]
when '-'
case to case to
when '-f' when '-f'
result = opts[:files].include? source if opts[:files] result = opts[:files].include?(source) if opts[:files]
end
else else
result = source[Regexp.new(to)] result = source[Regexp.new(to)]
end end

View File

@ -3,12 +3,13 @@ module Apache
def enable_ssl_engine(options = {}) def enable_ssl_engine(options = {})
self << "" self << ""
self << "SSLEngine on" self << "SSLEngine on"
options.each do |k, v| options.each do |key, value|
case k value = quoteize(value).first
case key
when :certificate_file, :certificate_key_file when :certificate_file, :certificate_key_file
self << "SSL#{apachify(k)} #{quoteize(v).first}" self << "SSL#{apachify(key)} #{value}"
when :ca_certificate_file when :ca_certificate_file
self << "SSLCACertificateFile #{quoteize(v).first}" self << "SSLCACertificateFile #{value}"
end end
end end
self << "" self << ""