forked from chef-boneyard/httpd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the DSL to its own file and re-org'd for readability
- Loading branch information
Franklin Webber
committed
Jul 11, 2014
1 parent
8ef3b94
commit 56cdef6
Showing
2 changed files
with
87 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module Opscode | ||
module Httpd | ||
module Module | ||
module Helpers | ||
|
||
module ModuleInfoDSL | ||
# | ||
# Given a key, which is a hash of criteria (i.e. module name, platform, | ||
# version, httpd_version), this method will return for you the package | ||
# where that module exists. `Nil` is returned if the key does not match | ||
# any of the defined criteria. | ||
# | ||
# @example Searching for the 'alias' module on debian 10.04 with | ||
# httpd version 2.2 | ||
# | ||
# ModuleInfo.find(:module => 'alias', :platform_family => 'debian', :version => '10.04', :httpd_version: '2.2') | ||
# | ||
def find(key) | ||
found_key = modules_list.keys.find { |lock| key.merge(lock) == key } | ||
modules_list[found_key] | ||
end | ||
|
||
# | ||
# Define what package stores a list of modules based on the any of the | ||
# criteria: module platform_family, platform, version, httpd_version. | ||
# | ||
# @example Module 'ssl' on an Amazon 2014.03 instance using httpd version 2.4 can be found in the package 'mod_ssl' | ||
# | ||
# modules for: { platform: "amazon", version: "2014.03", httpd_version: "2.4" }, | ||
# are: [ "ssl" ], found_in_package: -> (name) { "mod_#{name}" } | ||
# | ||
# When defining the criteria you can specify as little or as much | ||
# criteria you need. Not specifying the field means that field allows | ||
# any value. | ||
# | ||
# @example Module 'alias' on an Debian instance using httpd version 2.2 can be found in the package 'apache2' | ||
# | ||
# modules for: { platform_family: "debian", httpd_version: "2.2" }, | ||
# are: [ "alias" ], found_in_package: -> (name) { "apache2" } | ||
# | ||
# | ||
# This states that the 'alias' module is found on any version | ||
# (e.g. 7, 10.04, 12.04) of Debian with httpd version 2.2. | ||
# | ||
def modules(options) | ||
options[:are].each do |mod| | ||
key = options[:for].merge(:module => mod) | ||
modules_list[key] = options[:found_in_package].call(mod) | ||
end | ||
end | ||
|
||
def modules_list | ||
@modules_list ||= {} | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |