From 010fb5e5685fec7aefe9e62901ebcdf06af19d5a Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 7 Mar 2012 19:55:21 -0800 Subject: (#13018) Fix missing method any? message for ruby 1.9.x The any? method doesn't exist for 1.9.x, this converts a string to a single element array to work around the problem. --- lib/puppet/parser/functions/validate_re.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/functions/validate_re.rb b/lib/puppet/parser/functions/validate_re.rb index 9c216d8..b5e8ff4 100644 --- a/lib/puppet/parser/functions/validate_re.rb +++ b/lib/puppet/parser/functions/validate_re.rb @@ -30,7 +30,7 @@ module Puppet::Parser::Functions msg = args[2] || "validate_re(): #{args[0].inspect} does not match #{args[1].inspect}" - raise Puppet::ParseError, (msg) unless args[1].any? do |re_str| + raise Puppet::ParseError, (msg) unless [args[1]].flatten.any? do |re_str| args[0] =~ Regexp.compile(re_str) end -- cgit v1.2.3 From f156e554d43f7d5517d2fd79bab41f7d9ee73688 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Fri, 9 Mar 2012 14:08:54 -0800 Subject: (maint) Comment Ken's fix to String#any? Just added a comment about why we're doing what we're doing. --- lib/puppet/parser/functions/validate_re.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/functions/validate_re.rb b/lib/puppet/parser/functions/validate_re.rb index b5e8ff4..ca25a70 100644 --- a/lib/puppet/parser/functions/validate_re.rb +++ b/lib/puppet/parser/functions/validate_re.rb @@ -30,6 +30,8 @@ module Puppet::Parser::Functions msg = args[2] || "validate_re(): #{args[0].inspect} does not match #{args[1].inspect}" + # We're using a flattened array here because we can't call String#any? in + # Ruby 1.9 like we can in Ruby 1.8 raise Puppet::ParseError, (msg) unless [args[1]].flatten.any? do |re_str| args[0] =~ Regexp.compile(re_str) end -- cgit v1.2.3