Filter functions
[mirror/dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / filter.rb
1 module Puppet::Parser::Functions
2
3   # given an array of network addresses, return only the ipv4 addresses
4   newfunction(:filter_ipv4, :type => :rvalue) do |args|
5     x = args.shift
6
7     raise Puppet::ParseError, "Argument is not an array." unless x.kind_of?(Array)
8     return x.reject{ |x| x =~ /:/}
9   end
10
11   # given an array of network addresses, return only the ipv6 addresses
12   newfunction(:filter_ipv6, :type => :rvalue) do |args|
13     x = args.shift
14
15     raise Puppet::ParseError, "Argument is not an array." unless x.kind_of?(Array)
16     return x.reject{ |x| x !~ /:/}
17   end
18
19   # given an list, join with spaces
20   newfunction(:join_spc, :type => :rvalue) do |args|
21     x = args.shift
22
23     raise Puppet::ParseError, "Argument is not an array." unless x.kind_of?(Array)
24     return x.join(' ')
25   end
26 end
27 # vim:set et:
28 # vim:set sts=2 ts=2:
29 # vim:set shiftwidth=2: