more stuff

This commit is contained in:
John Bintz 2010-04-27 16:27:31 -04:00
parent c116f2f47f
commit f21f3aaf2f
2 changed files with 50 additions and 32 deletions

View File

@ -6,8 +6,8 @@ module Apache
end end
module Master module Master
def modules(&block) def modules(*modules, &block)
@config << Modules.build(&block) @config << Modules.build(*modules, &block)
end end
def indent(string) def indent(string)
@ -17,40 +17,59 @@ module Apache
def block_methods(*methods) def block_methods(*methods)
methods.each do |method| methods.each do |method|
self.class.class_eval <<-EOT self.class.class_eval <<-EOT
def #{method}(name = nil, &block) def #{method}(*name, &block)
tag_name = apachify("#{method}") blockify(apachify("#{method}"), name, &block)
start = [ tag_name ]
start << '"' + name + '"' if name
start = start.uniq.join(' ')
@config << "" if (@indent == 0)
@config << indent("<" + start + ">")
@indent += 1
self.instance_eval(&block)
@indent -= 1
@config << indent("</" + tag_name + ">")
end end
EOT EOT
end end
end end
def blockify(tag_name, name, &block)
start = [ tag_name ]
case name
when String
start << quoteize(name).first if name
when Array
start << (quoteize(*name) * " ") if name
end
start = start.uniq.join(' ')
@config << "" if (@indent == 0)
@config << indent("<" + start + ">")
@indent += 1
self.instance_eval(&block)
@indent -= 1
@config << indent("</" + tag_name + ">")
end
def method_missing(method, *args) def method_missing(method, *args)
@config << indent([ apachify(method), *quoteize(*args) ] * ' ') if method.to_s[-1..-1] == "!"
method = method.to_s[0..-2].to_sym
else
args = *quoteize(*args)
end
@config << indent([ apachify(method), *args ] * ' ')
end end
def runner(user, group = nil) def runner(user, group = nil)
@config << indent("User #{user}") user! user
@config << indent("Group #{group}") if group group! group if group
end end
def deny_from_all def deny_from_all
@config << indent("Order deny,allow") order! "deny,allow"
@config << indent("Deny from all") deny! "from all"
end end
def allow_from_all def allow_from_all
@config << indent("Order allow,deny") order! "allow,deny"
@config << indent("Allow from all") allow! "from all"
end
def passenger(ruby_root, ruby_version, passenger_version)
end end
private private
@ -68,10 +87,11 @@ module Apache
class << self class << self
include Apache::Quoteize include Apache::Quoteize
def build(&block) def build(*modules, &block)
@modules = [] @modules = []
self.instance_eval(&block) modules.each { |m| self.send(m) }
self.instance_eval(&block) if block
@modules @modules
end end

View File

@ -1,25 +1,23 @@
Apache::Config.build('httpd.conf') do Apache::Config.build('httpd.conf') do
server_root '/var/html/apache' server_root '/var/html/apache'
modules do modules :expires, :headers
expires modules :usertrack, :rewrite
headers load_module "php5_module", "modules/libphp5.so"
end
passenger_root '/var/html/ree/lib/ruby/gems/1.8/gems/passenger-2.2.11' passenger '/var/html/ree', '1.8', '2.2.11'
passenger_ruby '/var/html/ree/bin/ruby'
if_module "!mpm_netware" do if_module "!mpm_netware" do
runner 'webby', 'opoadm' runner 'webby', 'opoadm'
end end
directory '/' do directory '/' do
options 'FollowSymLinks' options! 'FollowSymLinks'
allow_override 'None' allow_override! 'None'
deny_from_all deny_from_all
end end
virtual_host '127.0.0.1:80' do virtual_host '127.0.0.1:80', '127.0.0.1:81' do
directory '/' do directory '/' do
allow_from_all allow_from_all
end end