Mercurial > repos > other > Puppet
view modules/stdlib/lib/puppet/parser/functions/glob.rb @ 275:d9352a684e62
Mass update of modules to remove deprecation warnings
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 26 Jan 2020 11:36:07 +0000 |
parents | c42fb28cff86 |
children | adf6fe9bbc17 |
line wrap: on
line source
# # glob.rb # module Puppet::Parser::Functions newfunction(:glob, :type => :rvalue, :doc => <<-DOC @summary Uses same patterns as Dir#glob. @return Returns an Array of file entries of a directory or an Array of directories. @example Example Usage: $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf']) DOC ) do |arguments| unless arguments.size == 1 raise(Puppet::ParseError, 'glob(): Wrong number of arguments given ' \ "(#{arguments.size} for 1)") end pattern = arguments[0] unless pattern.is_a?(String) || pattern.is_a?(Array) raise(Puppet::ParseError, 'glob(): Requires either array or string ' \ 'to work') end Dir.glob(pattern) end end