summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-29 04:36:28 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-29 04:36:28 +0100
commit65f98d2f09ab8fde4bcf81532d026c74f132e1e7 (patch)
treeb11e042ba09498345dce7eb9ef152b45283680f2
parenteab2a63f1bdd5478a9d6a5c5db71d6129cb79dcf (diff)
downloadpuppet-stdlib-65f98d2f09ab8fde4bcf81532d026c74f132e1e7.tar.gz
puppet-stdlib-65f98d2f09ab8fde4bcf81532d026c74f132e1e7.tar.bz2
Adding relevant code.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r--keys.rb25
-rw-r--r--values.rb25
2 files changed, 50 insertions, 0 deletions
diff --git a/keys.rb b/keys.rb
new file mode 100644
index 0000000..7d50889
--- /dev/null
+++ b/keys.rb
@@ -0,0 +1,25 @@
+#
+# keys.rb
+#
+
+module Puppet::Parser::Functions
+ newfunction(:keys, :type => :rvalue, :doc => <<-EOS
+ EOS
+ ) do |arguments|
+
+ raise(Puppet::ParseError, "keys(): Wrong number of arguments " +
+ "given (#{arguments.size} for 1)") if arguments.size < 1
+
+ hash = arguments[0]
+
+ if not hash.is_a?(Hash)
+ raise(Puppet::ParseError, 'keys(): Requires a hash to work with')
+ end
+
+ result = hash.keys
+
+ return result
+ end
+end
+
+# vim: set ts=2 sw=2 et :
diff --git a/values.rb b/values.rb
new file mode 100644
index 0000000..8e58184
--- /dev/null
+++ b/values.rb
@@ -0,0 +1,25 @@
+#
+# values.rb
+#
+
+module Puppet::Parser::Functions
+ newfunction(:values, :type => :rvalue, :doc => <<-EOS
+ EOS
+ ) do |arguments|
+
+ raise(Puppet::ParseError, "values(): Wrong number of arguments " +
+ "given (#{arguments.size} for 1)") if arguments.size < 1
+
+ hash = arguments[0]
+
+ if not hash.is_a?(Hash)
+ raise(Puppet::ParseError, 'values(): Requires a hash to work with')
+ end
+
+ result = hash.values
+
+ return result
+ end
+end
+
+# vim: set ts=2 sw=2 et :