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:
609 bytes
|
Line | |
---|
1 | #
|
---|
2 | # grep.rb
|
---|
3 | #
|
---|
4 |
|
---|
5 | module Puppet::Parser::Functions
|
---|
6 | newfunction(:grep, :type => :rvalue, :doc => <<-EOS
|
---|
7 | This function searches through an array and returns any elements that match
|
---|
8 | the provided regular expression.
|
---|
9 |
|
---|
10 | *Examples:*
|
---|
11 |
|
---|
12 | grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
|
---|
13 |
|
---|
14 | Would return:
|
---|
15 |
|
---|
16 | ['aaa','aaaddd']
|
---|
17 | EOS
|
---|
18 | ) do |arguments|
|
---|
19 |
|
---|
20 | if (arguments.size != 2) then
|
---|
21 | raise(Puppet::ParseError, "grep(): Wrong number of arguments "+
|
---|
22 | "given #{arguments.size} for 2")
|
---|
23 | end
|
---|
24 |
|
---|
25 | a = arguments[0]
|
---|
26 | pattern = Regexp.new(arguments[1])
|
---|
27 |
|
---|
28 | a.grep(pattern)
|
---|
29 |
|
---|
30 | end
|
---|
31 | end
|
---|
32 |
|
---|
33 | # vim: set ts=2 sw=2 et :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.