summaryrefslogtreecommitdiff
path: root/plugins/puppet/parser/functions/split.rb
blob: 5237c9203bbf6f744beed737916a489878184569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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|
		if args[0].is_a?(Array)
			args.collect do |a| a.split(/#{args[1]}/) end
		else
			args[0].split(/#{args[1]}/)
		end
	end
end