diff --git a/lib/apache/config.rb b/lib/apache/config.rb index 748a376..983155e 100644 --- a/lib/apache/config.rb +++ b/lib/apache/config.rb @@ -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 diff --git a/lib/apache/master.rb b/lib/apache/master.rb index b6e46af..0e2fc60 100644 --- a/lib/apache/master.rb +++ b/lib/apache/master.rb @@ -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("") + self << "" 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 diff --git a/lib/apache/permissions.rb b/lib/apache/permissions.rb index dfef9c9..99fec4f 100644 --- a/lib/apache/permissions.rb +++ b/lib/apache/permissions.rb @@ -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