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" } #File.open(target, 'w') { |f| f.puts @config * "\n" }
end end
def indent(string)
" " * (@indent * 2) + string
end
def <<(string)
@config << indent(string)
end
end end
block_methods :if_module, :directory, :virtual_host block_methods :if_module, :directory, :virtual_host

View File

@ -1,7 +1,14 @@
module Apache module Apache
module Quoteize module Quoteize
def quoteize(*args) 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
end end
@ -10,10 +17,6 @@ module Apache
@config << Modules.build(*modules, &block) @config << Modules.build(*modules, &block)
end end
def indent(string)
" " * (@indent * 2) + string
end
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
@ -36,12 +39,12 @@ module Apache
start = start.uniq.join(' ') start = start.uniq.join(' ')
@config << "" if (@indent == 0) self << "" if (@indent == 0)
@config << indent("<" + start + ">") self << "<" + start + ">"
@indent += 1 @indent += 1
self.instance_eval(&block) self.instance_eval(&block)
@indent -= 1 @indent -= 1
@config << indent("</" + tag_name + ">") self << "</" + tag_name + ">"
end end
def method_missing(method, *args) def method_missing(method, *args)
@ -51,7 +54,7 @@ module Apache
args = *quoteize(*args) args = *quoteize(*args)
end end
@config << indent([ apachify(method), *args ] * ' ') self << [ apachify(method), *args ] * ' '
end end
def runner(user, group = nil) def runner(user, group = nil)
@ -60,8 +63,15 @@ module Apache
end end
def passenger(ruby_root, ruby_version, passenger_version) def passenger(ruby_root, ruby_version, passenger_version)
end end
def order(*args)
self << "Order #{args * ','}"
end
alias :order! :order
private private
def apachify(name) def apachify(name)
name = name.to_s name = name.to_s

View File

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