-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jordiprats/master
metadades
- Loading branch information
Showing
3 changed files
with
63 additions
and
15 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,35 @@ | ||
#shamesly stolen from: https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/puppet/parser/functions/bool2httpd.rb | ||
# | ||
#Copyright (C) 2012 Puppet Labs Inc | ||
# | ||
#Puppet Labs can be contacted at: [email protected] | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
# | ||
# | ||
Puppet::Parser::Functions::newfunction(:bool2httpd, :type => :rvalue, :doc => <<-EOS | ||
Transform a supposed boolean to On or Off. Pass all other values through. | ||
Given a nil value (undef), bool2httpd will return 'Off' | ||
Example: | ||
$trace_enable = false | ||
$server_signature = 'mail' | ||
bool2httpd($trace_enable) | ||
# => 'Off' | ||
bool2httpd($server_signature) | ||
# => 'mail' | ||
bool2httpd(undef) | ||
# => 'Off' | ||
EOS | ||
) do |args| | ||
raise(Puppet::ParseError, "bool2httpd() wrong number of arguments. Given: #{args.size} for 1)") if args.size != 1 | ||
|
||
arg = args[0] | ||
|
||
if arg.nil? or arg == false or arg =~ /false/i or arg == :undef | ||
return 'Off' | ||
elsif arg == true or arg =~ /true/i | ||
return 'On' | ||
end | ||
|
||
return arg.to_s | ||
end |
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