add an array_join function
authoro <o@immerda.ch>
Wed, 16 Apr 2014 12:21:32 +0000 (14:21 +0200)
committero <o@immerda.ch>
Wed, 16 Apr 2014 12:21:32 +0000 (14:21 +0200)
lib/puppet/parser/functions/array_join.rb [new file with mode: 0644]

diff --git a/lib/puppet/parser/functions/array_join.rb b/lib/puppet/parser/functions/array_join.rb
new file mode 100644 (file)
index 0000000..c715c5d
--- /dev/null
@@ -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