diff options
author | Colleen Murphy <cmurphy@users.noreply.github.com> | 2015-01-13 17:43:19 -0800 |
---|---|---|
committer | Colleen Murphy <cmurphy@users.noreply.github.com> | 2015-01-13 17:43:19 -0800 |
commit | 712a58a5ce1f8465710dacad49ca2e60c5d0150e (patch) | |
tree | 7e56b669bf51eb88ee01a5cbc1f84df5766ebf1c /lib/puppet/parser/functions/concat.rb | |
parent | 80f09623b63cf6946b5913b629911e2c49b5d1dd (diff) | |
parent | cfacdd543e942f7c5d94fd07f14c2f6d8128e83d (diff) | |
download | puppet-stdlib-712a58a5ce1f8465710dacad49ca2e60c5d0150e.tar.gz puppet-stdlib-712a58a5ce1f8465710dacad49ca2e60c5d0150e.tar.bz2 |
Merge pull request #397 from cyberious/4.6.x
4.6.x
Diffstat (limited to 'lib/puppet/parser/functions/concat.rb')
-rw-r--r-- | lib/puppet/parser/functions/concat.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb index 0d35b07..618e62d 100644 --- a/lib/puppet/parser/functions/concat.rb +++ b/lib/puppet/parser/functions/concat.rb @@ -4,31 +4,35 @@ module Puppet::Parser::Functions newfunction(:concat, :type => :rvalue, :doc => <<-EOS -Appends the contents of array 2 onto array 1. +Appends the contents of multiple arrays into array 1. *Example:* - concat(['1','2','3'],['4','5','6']) + concat(['1','2','3'],['4','5','6'],['7','8','9']) Would result in: - ['1','2','3','4','5','6'] + ['1','2','3','4','5','6','7','8','9'] EOS ) do |arguments| - # Check that 2 arguments have been given ... + # Check that more than 2 arguments have been given ... raise(Puppet::ParseError, "concat(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 + "given (#{arguments.size} for < 2)") if arguments.size < 2 a = arguments[0] - b = arguments[1] # Check that the first parameter is an array unless a.is_a?(Array) raise(Puppet::ParseError, 'concat(): Requires array to work with') end - result = a + Array(b) + result = a + arguments.shift + + arguments.each do |x| + result = result + Array(x) + end return result end |