summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCorey Osman <corey@logicminds.biz>2015-09-03 10:31:51 -0700
committerCorey Osman <corey@logicminds.biz>2015-09-04 08:09:26 -0700
commitf2f2db4795fc0e3b9387e1e6c003e8e75efde903 (patch)
tree683943b340206622911d3108f50b1e7f25cc4035 /lib
parent6a1afae97e0451590c833acdd79fd730f49137b9 (diff)
accept any case of boolean strings
* previously the str2bool function did not accept 'TRUE' as a bool type. This causes the function to now accept TRUE, FALSE strings as a boolean type in order to be converted to a proper boolean. * This would also cause Y,N, YES, NO to be accepted as boolean types as well.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/functions/str2bool.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/puppet/parser/functions/str2bool.rb b/lib/puppet/parser/functions/str2bool.rb
index 446732e..8def131 100644
--- a/lib/puppet/parser/functions/str2bool.rb
+++ b/lib/puppet/parser/functions/str2bool.rb
@@ -5,8 +5,8 @@
module Puppet::Parser::Functions
newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS
This converts a string to a boolean. This attempt to convert strings that
-contain things like: y, 1, t, true to 'true' and strings that contain things
-like: 0, f, n, false, no to 'false'.
+contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things
+like: 0, F,f, N,n, false, FALSE, no to 'false'.
EOS
) do |arguments|
@@ -32,8 +32,8 @@ like: 0, f, n, false, no to 'false'.
# We yield false in this case.
#
when /^$/, '' then false # Empty string will be false ...
- when /^(1|t|y|true|yes)$/ then true
- when /^(0|f|n|false|no)$/ then false
+ when /^(1|t|y|true|yes)$/i then true
+ when /^(0|f|n|false|no)$/i then false
when /^(undef|undefined)$/ then false # This is not likely to happen ...
else
raise(Puppet::ParseError, 'str2bool(): Unknown type of boolean given')