aboutsummaryrefslogtreecommitdiff
path: root/plugins/puppet/parser/functions/split.rb
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/puppet/parser/functions/split.rb')
-rw-r--r--plugins/puppet/parser/functions/split.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/puppet/parser/functions/split.rb b/plugins/puppet/parser/functions/split.rb
index d08a40b..5237c92 100644
--- a/plugins/puppet/parser/functions/split.rb
+++ b/plugins/puppet/parser/functions/split.rb
@@ -1,7 +1,17 @@
-# generic split call
+# split($string, $delimiter) : $string
+# split($string[], $delimiter) : $string[][]
+#
+# Split the first argument(s) on every $delimiter. $delimiter is interpreted as
+# Ruby regular expression.
+#
+# For long-term portability it is recommended to refrain from using Ruby's
+# extended RE features.
module Puppet::Parser::Functions
newfunction(:split, :type => :rvalue) do |args|
- args[0].split(/#{args[1]}/)
+ if args[0].is_a?(Array)
+ args.collect do |a| a.split(/#{args[1]}/) end
+ else
+ args[0].split(/#{args[1]}/)
+ end
end
end
-