2010-05-04 15:48:59 +00:00
|
|
|
module Apache
|
2010-05-10 19:57:34 +00:00
|
|
|
# Create lists of modules to load in the Apache 2.2 style (with LoadModule only)
|
2010-05-04 15:48:59 +00:00
|
|
|
class Modules
|
|
|
|
class << self
|
2010-05-04 21:04:44 +00:00
|
|
|
attr_accessor :modules
|
|
|
|
|
2010-05-10 19:57:34 +00:00
|
|
|
# Reset the list of modules to output
|
2010-05-04 21:04:44 +00:00
|
|
|
def reset!
|
2010-05-04 15:48:59 +00:00
|
|
|
@modules = []
|
2010-05-04 21:04:44 +00:00
|
|
|
end
|
|
|
|
|
2010-05-10 19:57:34 +00:00
|
|
|
# Build a block of LoadModule commands
|
|
|
|
#
|
|
|
|
# Apache::Modules.build(:expires, :headers) do
|
|
|
|
# funky "/path/to/funky/module.so"
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# becomes:
|
|
|
|
#
|
|
|
|
# LoadModule "expires_module" "modules/mod_expires.so"
|
|
|
|
# LoadModule "headers_module" "modules/mod_headers.so"
|
|
|
|
# LoadModule "funky_module" "/path/to/funky/module.so"
|
2010-05-04 21:04:44 +00:00
|
|
|
def build(*modules, &block)
|
|
|
|
reset!
|
2010-05-04 15:48:59 +00:00
|
|
|
|
2010-05-18 17:08:17 +00:00
|
|
|
modules.each { |mod| self.send(mod) }
|
2010-05-04 15:48:59 +00:00
|
|
|
self.instance_eval(&block) if block
|
|
|
|
|
2010-05-05 14:44:20 +00:00
|
|
|
[ '' ] + @modules + [ '' ]
|
2010-05-04 15:48:59 +00:00
|
|
|
end
|
|
|
|
|
2010-05-10 19:57:34 +00:00
|
|
|
# The method name becomes the module core name
|
2010-05-04 15:48:59 +00:00
|
|
|
def method_missing(method, *args)
|
|
|
|
module_name = "#{method}_module"
|
|
|
|
module_path = args[0] || "modules/mod_#{method}.so"
|
2010-05-18 17:08:17 +00:00
|
|
|
@modules << [ 'LoadModule', *[ module_name, module_path ].quoteize ] * " "
|
2010-05-04 15:48:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|