summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-26 00:09:26 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-26 00:09:26 +0100
commitde0e7adb66fd00a8b72b7e7746bd9844bca797d3 (patch)
tree6bd19543c19b9d0ca002edbb25612ea01045a8a7
parent738db6eb706c81d5b2a69692c77769432ec0c824 (diff)
downloadpuppet-stdlib-de0e7adb66fd00a8b72b7e7746bd9844bca797d3.tar.gz
puppet-stdlib-de0e7adb66fd00a8b72b7e7746bd9844bca797d3.tar.bz2
First version. Simple empty function to use within Puppet DSL.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r--empty.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/empty.rb b/empty.rb
new file mode 100644
index 0000000..b83ece0
--- /dev/null
+++ b/empty.rb
@@ -0,0 +1,25 @@
+#
+# empty.rb
+#
+
+module Puppet::Parser::Functions
+ newfunction(:empty, :type => :rvalue, :doc => <<-EOS
+ EOS
+ ) do |arguments|
+
+ raise(Puppet::ParseError, "empty(): Wrong number of arguments " +
+ "given (#{arguments.size} for 1)") if arguments.size < 1
+
+ array = arguments[0]
+
+ if not array.is_a?(Array)
+ raise(Puppet::ParseError, 'empty(): Requires an array to work with')
+ end
+
+ result = array.empty?
+
+ return result
+ end
+end
+
+# vim: set ts=2 sw=2 et :