Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / glob.rb
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb
new file mode 100644 (file)
index 0000000..54cdda6
--- /dev/null
@@ -0,0 +1,22 @@
+#
+#  glob.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:glob, :type => :rvalue, :doc => <<-'EOS'
+    Returns an Array of file entries of a directory or an Array of directories.
+    Uses same patterns as Dir#glob
+    EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "glob(): Wrong number of arguments given " +
+      "(#{arguments.size} for 1)") unless arguments.size == 1
+
+    pattern = arguments[0]
+
+    raise(Puppet::ParseError, 'glob(): Requires either array or string ' +
+      'to work') unless pattern.is_a?(String) || pattern.is_a?(Array)
+
+    Dir.glob(pattern)
+  end
+end