From: o Date: Wed, 16 Apr 2014 12:21:32 +0000 (+0200) Subject: add an array_join function X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=4b4744e402f5cbc5f9856971d1a64002c7eb0796;p=puppet-common.git add an array_join function --- diff --git a/lib/puppet/parser/functions/array_join.rb b/lib/puppet/parser/functions/array_join.rb new file mode 100644 index 0000000..c715c5d --- /dev/null +++ b/lib/puppet/parser/functions/array_join.rb @@ -0,0 +1,8 @@ +Puppet::Parser::Functions::newfunction(:array_join, + :type => :rvalue, + :doc => "Join a list of strings with an optional delimiter.") do |args| + unless 1..2.include? args.length + raise Puppet::ParseError, 'array_join() takes 1 or 2 arguments' + end + args.first.join args.last +end