apache-config-generator/lib/apache/master.rb

79 lines
2.1 KiB
Ruby
Raw Normal View History

2010-04-27 20:11:47 +00:00
module Apache
module Master
2010-04-27 20:27:31 +00:00
def modules(*modules, &block)
2010-05-04 21:04:44 +00:00
@config += Modules.build(*modules, &block)
2010-04-27 20:11:47 +00:00
end
def runner(user, group = nil)
2010-04-27 20:27:31 +00:00
user! user
group! group if group
2010-04-27 20:11:47 +00:00
end
2010-04-27 20:27:31 +00:00
def passenger(ruby_root, ruby_version, passenger_version)
2010-05-04 15:48:59 +00:00
load_module 'passenger_module', "#{ruby_root}/lib/ruby/gems/#{ruby_version}/gems/passenger-#{passenger_version}/ext/apache2/mod_passenger.so"
passenger_root "#{ruby_root}/lib/ruby/gems/#{ruby_version}/gems/passenger-#{passenger_version}"
passenger_ruby "#{ruby_root}/bin/ruby"
2010-04-28 20:19:03 +00:00
end
2010-05-05 14:44:20 +00:00
def enable_gzip!
directory '/' do
add_output_filter_by_type! :DEFLATE, 'text/html', 'text/plain', 'text/css', 'text/javascript', 'application/javascript'
browser_match! '^Mozilla/4', "gzip-only-text/html"
browser_match! '^Mozilla/4\.0[678]', "no-gzip"
browser_match! '\bMSIE', '!no-gzip', '!gzip-only-text/html'
end
2010-04-27 20:11:47 +00:00
end
2010-05-05 16:25:07 +00:00
def timeout(t)
self << "Timeout #{t}"
end
def comment(c)
out = [ '' ]
case c
when String
out += c.split("\n")
when Array
2010-05-07 15:52:34 +00:00
out += c
2010-05-05 16:25:07 +00:00
end
out << ''
2010-05-07 15:52:34 +00:00
self + out.collect { |line| "# #{line.strip}".strip }
2010-05-05 16:25:07 +00:00
end
def script_alias(uri, path)
directory? path
2010-05-07 17:56:49 +00:00
self << %{ScriptAlias #{quoteize(uri, path) * ' '}}
2010-05-05 16:25:07 +00:00
end
alias :script_alias! :script_alias
2010-05-07 02:26:12 +00:00
def add_type!(mime, extension, options = {})
self << "AddType #{mime} #{extension}"
options.each do |type, value|
self << "Add#{type.to_s.capitalize} #{value} #{extension}"
end
end
2010-05-07 15:26:40 +00:00
def apache_include(*opts)
self << "Include #{opts * " "}"
end
def apache_alias(*opts)
self << "Alias #{quoteize(*opts) * " "}"
end
def set_header(hash)
hash.each do |key, value|
output = "Header set #{quoteize(key)}"
case value
2010-05-07 17:56:49 +00:00
when String, Symbol
2010-05-07 15:26:40 +00:00
output += " #{quoteize(value)}"
when Array
output += " #{quoteize(value.first)} #{value.last}"
end
self << output
end
end
2010-04-27 20:11:47 +00:00
end
end