Last change
on this file since 30903 was 30903, checked in by davidb, 7 years ago |
Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details
|
File size:
866 bytes
|
Line | |
---|
1 | #
|
---|
2 | # concat.rb
|
---|
3 | #
|
---|
4 |
|
---|
5 | module Puppet::Parser::Functions
|
---|
6 | newfunction(:concat, :type => :rvalue, :doc => <<-EOS
|
---|
7 | Appends the contents of multiple arrays into array 1.
|
---|
8 |
|
---|
9 | *Example:*
|
---|
10 |
|
---|
11 | concat(['1','2','3'],['4','5','6'],['7','8','9'])
|
---|
12 |
|
---|
13 | Would result in:
|
---|
14 |
|
---|
15 | ['1','2','3','4','5','6','7','8','9']
|
---|
16 | EOS
|
---|
17 | ) do |arguments|
|
---|
18 |
|
---|
19 | # Check that more than 2 arguments have been given ...
|
---|
20 | raise(Puppet::ParseError, "concat(): Wrong number of arguments " +
|
---|
21 | "given (#{arguments.size} for < 2)") if arguments.size < 2
|
---|
22 |
|
---|
23 | a = arguments[0]
|
---|
24 |
|
---|
25 | # Check that the first parameter is an array
|
---|
26 | unless a.is_a?(Array)
|
---|
27 | raise(Puppet::ParseError, 'concat(): Requires array to work with')
|
---|
28 | end
|
---|
29 |
|
---|
30 | result = a
|
---|
31 | arguments.shift
|
---|
32 |
|
---|
33 | arguments.each do |x|
|
---|
34 | result = result + (x.is_a?(Array) ? x : [x])
|
---|
35 | end
|
---|
36 |
|
---|
37 | return result
|
---|
38 | end
|
---|
39 | end
|
---|
40 |
|
---|
41 | # vim: set ts=2 sw=2 et :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.