From 30c925a4f1f41dcab619fc268239679b4a65f218 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 12 May 2010 14:24:35 -0400 Subject: [PATCH] some code cleanup stuff --- .gitignore | 1 + lib/apache/mpm_prefork.rb | 4 ++-- lib/apache/rewrites.rb | 17 +++++++---------- lib/apache/ssl.rb | 9 +++++---- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index ffd3034..b388b57 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ docs/* pkg/* Manifest *.gemspec +tmp/* diff --git a/lib/apache/mpm_prefork.rb b/lib/apache/mpm_prefork.rb index 2003a56..ddbf5fd 100644 --- a/lib/apache/mpm_prefork.rb +++ b/lib/apache/mpm_prefork.rb @@ -47,8 +47,8 @@ module Apache when String @config << "#{which} #{opts * " "}" when Array - which.each do |w| - @config << "#{w} #{opts.shift}" + which.each do |tag| + @config << "#{tag} #{opts.shift}" end end end diff --git a/lib/apache/rewrites.rb b/lib/apache/rewrites.rb index b7649c9..d0796ec 100644 --- a/lib/apache/rewrites.rb +++ b/lib/apache/rewrites.rb @@ -170,7 +170,7 @@ module Apache module RegularExpressionMatcher # Test this rewritable thing 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) end @@ -179,14 +179,14 @@ module Apache end # Replace the placeholders in this rewritable thing - def replace_placeholders(s, opts) + def replace_placeholders(string, opts) opts.each do |opt, value| case value when String - s = s.gsub('%{' + opt.to_s.upcase + '}', value) + string = string.gsub('%{' + opt.to_s.upcase + '}', value) end end - s.gsub(%r{%\{[^\}]+\}}, '') + string.gsub(%r{%\{[^\}]+\}}, '') end end @@ -387,12 +387,9 @@ module Apache end result = false - case to[0..0] - when '-' - case to - when '-f' - result = opts[:files].include? source if opts[:files] - end + case to + when '-f' + result = opts[:files].include?(source) if opts[:files] else result = source[Regexp.new(to)] end diff --git a/lib/apache/ssl.rb b/lib/apache/ssl.rb index af2cd8c..650196e 100644 --- a/lib/apache/ssl.rb +++ b/lib/apache/ssl.rb @@ -3,12 +3,13 @@ module Apache def enable_ssl_engine(options = {}) self << "" self << "SSLEngine on" - options.each do |k, v| - case k + options.each do |key, value| + value = quoteize(value).first + case key when :certificate_file, :certificate_key_file - self << "SSL#{apachify(k)} #{quoteize(v).first}" + self << "SSL#{apachify(key)} #{value}" when :ca_certificate_file - self << "SSLCACertificateFile #{quoteize(v).first}" + self << "SSLCACertificateFile #{value}" end end self << ""