source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/any2array.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 8 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

File size: 769 bytes
Line 
1#
2# any2array.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
7This converts any object to an array containing that object. Empty argument
8lists are converted to an empty array. Arrays are left untouched. Hashes are
9converted to arrays of alternating keys and values.
10 EOS
11 ) do |arguments|
12
13 if arguments.empty?
14 return []
15 end
16
17 if arguments.length == 1
18 if arguments[0].kind_of?(Array)
19 return arguments[0]
20 elsif arguments[0].kind_of?(Hash)
21 result = []
22 arguments[0].each do |key, value|
23 result << key << value
24 end
25 return result
26 end
27 end
28
29 return arguments
30 end
31end
32
33# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.