From 3ff12051c8efabcdfb43b99810ff1c2ea22750a3 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Mon, 23 Nov 2009 11:54:04 -0500 Subject: move plugin directory to fit new 0.25.x style and update file paths accordingly --- lib/puppet/parser/functions/split.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/puppet/parser/functions/split.rb (limited to 'lib/puppet/parser/functions/split.rb') diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb new file mode 100644 index 0000000..bffecc1 --- /dev/null +++ b/lib/puppet/parser/functions/split.rb @@ -0,0 +1,23 @@ +# This function has two modes of operation: +# +# split($string, $delimiter) : $string +# +# Split the first argument on every $delimiter. $delimiter is interpreted as +# Ruby regular expression. +# +# split($string[], $delimiter) : $string[][] +# +# Returns an array of split results with the result of applying split to each +# item from the first argument. +# +# 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 -- cgit v1.2.3