Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / glob.rb
1 #
2 #  glob.rb
3 #
4
5 module Puppet::Parser::Functions
6   newfunction(:glob, :type => :rvalue, :doc => <<-'EOS'
7     Returns an Array of file entries of a directory or an Array of directories.
8     Uses same patterns as Dir#glob
9     EOS
10   ) do |arguments|
11
12     raise(Puppet::ParseError, "glob(): Wrong number of arguments given " +
13       "(#{arguments.size} for 1)") unless arguments.size == 1
14
15     pattern = arguments[0]
16
17     raise(Puppet::ParseError, 'glob(): Requires either array or string ' +
18       'to work') unless pattern.is_a?(String) || pattern.is_a?(Array)
19
20     Dir.glob(pattern)
21   end
22 end