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
module Master
def modules(&block)
@config << Modules.build(&block)
def modules(*modules, &block)
@config << Modules.build(*modules, &block)
end
def indent(string)
@ -17,10 +17,23 @@ module Apache
def block_methods(*methods)
methods.each do |method|
self.class.class_eval <<-EOT
def #{method}(name = nil, &block)
tag_name = apachify("#{method}")
def #{method}(*name, &block)
blockify(apachify("#{method}"), name, &block)
end
EOT
end
end
def blockify(tag_name, name, &block)
start = [ tag_name ]
start << '"' + name + '"' if 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)
@ -30,27 +43,33 @@ module Apache
@indent -= 1
@config << indent("</" + tag_name + ">")
end
EOT
end
end
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
def runner(user, group = nil)
@config << indent("User #{user}")
@config << indent("Group #{group}") if group
user! user
group! group if group
end
def deny_from_all
@config << indent("Order deny,allow")
@config << indent("Deny from all")
order! "deny,allow"
deny! "from all"
end
def allow_from_all
@config << indent("Order allow,deny")
@config << indent("Allow from all")
order! "allow,deny"
allow! "from all"
end
def passenger(ruby_root, ruby_version, passenger_version)
end
private
@ -68,10 +87,11 @@ module Apache
class << self
include Apache::Quoteize
def build(&block)
def build(*modules, &block)
@modules = []
self.instance_eval(&block)
modules.each { |m| self.send(m) }
self.instance_eval(&block) if block
@modules
end

View File

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