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:
674 bytes
|
Line | |
---|
1 | #
|
---|
2 | # union.rb
|
---|
3 | #
|
---|
4 |
|
---|
5 | module Puppet::Parser::Functions
|
---|
6 | newfunction(:union, :type => :rvalue, :doc => <<-EOS
|
---|
7 | This function returns a union of two or more arrays.
|
---|
8 |
|
---|
9 | *Examples:*
|
---|
10 |
|
---|
11 | union(["a","b","c"],["b","c","d"])
|
---|
12 |
|
---|
13 | Would return: ["a","b","c","d"]
|
---|
14 | EOS
|
---|
15 | ) do |arguments|
|
---|
16 |
|
---|
17 | # Check that 2 or more arguments have been given ...
|
---|
18 | raise(Puppet::ParseError, "union(): Wrong number of arguments " +
|
---|
19 | "given (#{arguments.size} for < 2)") if arguments.size < 2
|
---|
20 |
|
---|
21 | arguments.each do |argument|
|
---|
22 | raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array)
|
---|
23 | end
|
---|
24 |
|
---|
25 | arguments.reduce(:|)
|
---|
26 | end
|
---|
27 | end
|
---|
28 |
|
---|
29 | # vim: set ts=2 sw=2 et :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.