a little cleanup

This commit is contained in:
John Bintz 2010-04-28 16:19:03 -04:00
parent bc5ca70f75
commit 1ba0016f9f
3 changed files with 31 additions and 13 deletions

View File

@ -18,6 +18,14 @@ module Apache
#File.open(target, 'w') { |f| f.puts @config * "\n" }
end
def indent(string)
" " * (@indent * 2) + string
end
def <<(string)
@config << indent(string)
end
end
block_methods :if_module, :directory, :virtual_host

View File

@ -1,7 +1,14 @@
module Apache
module Quoteize
def quoteize(*args)
args.collect { |a| %{"#{a}"} }
args.collect do |arg|
case arg
when Symbol
arg.to_s.gsub('_', ' ')
else
%{"#{arg}"}
end
end
end
end
@ -10,10 +17,6 @@ module Apache
@config << Modules.build(*modules, &block)
end
def indent(string)
" " * (@indent * 2) + string
end
def block_methods(*methods)
methods.each do |method|
self.class.class_eval <<-EOT
@ -36,12 +39,12 @@ module Apache
start = start.uniq.join(' ')
@config << "" if (@indent == 0)
@config << indent("<" + start + ">")
self << "" if (@indent == 0)
self << "<" + start + ">"
@indent += 1
self.instance_eval(&block)
@indent -= 1
@config << indent("</" + tag_name + ">")
self << "</" + tag_name + ">"
end
def method_missing(method, *args)
@ -51,7 +54,7 @@ module Apache
args = *quoteize(*args)
end
@config << indent([ apachify(method), *args ] * ' ')
self << [ apachify(method), *args ] * ' '
end
def runner(user, group = nil)
@ -60,8 +63,15 @@ module Apache
end
def passenger(ruby_root, ruby_version, passenger_version)
end
def order(*args)
self << "Order #{args * ','}"
end
alias :order! :order
private
def apachify(name)
name = name.to_s

View File

@ -1,13 +1,13 @@
module Apache
module Permissions
def deny_from_all
order! "deny,allow"
deny! "from all"
order :deny, :allow
deny :from_all
end
def allow_from_all
order! "allow,deny"
allow! "from all"
order :allow, :deny
allow :from_all
end
end
end