summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-04-29 09:27:10 +0200
committerKen Barber <ken@bob.sh>2011-04-30 15:59:31 +0200
commit99a93d366f2e1efb977fcc8fe300d3d8357c8214 (patch)
treefab7510323f123c83da6d7c6cae4fe9e3f2f1e27
parent781a8720577d0cafe2147f3a1b938db7bec31789 (diff)
downloadpuppet-stdlib-99a93d366f2e1efb977fcc8fe300d3d8357c8214.tar.gz
puppet-stdlib-99a93d366f2e1efb977fcc8fe300d3d8357c8214.tar.bz2
Convert to module format.
-rw-r--r--.gitignore1
-rw-r--r--Modulefile8
-rw-r--r--README6
-rw-r--r--lib/puppet/parser/functions/abs.rb (renamed from abs.rb)0
-rw-r--r--lib/puppet/parser/functions/bool2num.rb (renamed from bool2num.rb)0
-rw-r--r--lib/puppet/parser/functions/count.rb (renamed from count.rb)0
-rw-r--r--lib/puppet/parser/functions/delete_at.rb (renamed from delete_at.rb)0
-rw-r--r--lib/puppet/parser/functions/empty.rb (renamed from empty.rb)0
-rw-r--r--lib/puppet/parser/functions/fact.rb (renamed from fact.rb)0
-rw-r--r--lib/puppet/parser/functions/is_array.rb (renamed from is_array.rb)0
-rw-r--r--lib/puppet/parser/functions/is_hash.rb (renamed from is_hash.rb)0
-rw-r--r--lib/puppet/parser/functions/is_string.rb (renamed from is_string.rb)0
-rw-r--r--lib/puppet/parser/functions/join.rb (renamed from join.rb)0
-rw-r--r--lib/puppet/parser/functions/join_with_prefix.rb (renamed from join_with_prefix.rb)0
-rw-r--r--lib/puppet/parser/functions/keys.rb (renamed from keys.rb)0
-rw-r--r--lib/puppet/parser/functions/load_variables.rb (renamed from load_variables.rb)0
-rw-r--r--lib/puppet/parser/functions/member.rb33
-rw-r--r--lib/puppet/parser/functions/num2bool.rb (renamed from num2bool.rb)0
-rw-r--r--lib/puppet/parser/functions/persistent_crontab_minutes.rb (renamed from persistent_crontab_minutes.rb)0
-rw-r--r--lib/puppet/parser/functions/prefix.rb (renamed from prefix.rb)0
-rw-r--r--lib/puppet/parser/functions/random_crontab_minutes.rb (renamed from random_crontab_minutes.rb)0
-rw-r--r--lib/puppet/parser/functions/range.rb (renamed from range.rb)0
-rw-r--r--lib/puppet/parser/functions/reverse.rb (renamed from reverse.rb)0
-rw-r--r--lib/puppet/parser/functions/shuffle.rb (renamed from shuffle.rb)0
-rw-r--r--lib/puppet/parser/functions/size.rb (renamed from size.rb)0
-rw-r--r--lib/puppet/parser/functions/strftime.rb (renamed from strftime.rb)0
-rw-r--r--lib/puppet/parser/functions/time.rb (renamed from time.rb)0
-rw-r--r--lib/puppet/parser/functions/unique.rb (renamed from unique.rb)0
-rw-r--r--lib/puppet/parser/functions/values.rb (renamed from values.rb)0
-rw-r--r--lib/puppet/parser/functions/values_at.rb (renamed from values_at.rb)0
30 files changed, 45 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01d0a08
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+pkg/
diff --git a/Modulefile b/Modulefile
new file mode 100644
index 0000000..9b7d1e1
--- /dev/null
+++ b/Modulefile
@@ -0,0 +1,8 @@
+name 'kwilczynski/puppet-functions'
+version '0.0.1'
+source 'https://github.com/kwilczynski/puppet-functions'
+author 'Krzysztof Wilczynski'
+license 'UNKNOWN'
+summary 'A set of basic functions for puppet.'
+description 'This module provides a set of basic functions for puppet that extend the standard library.'
+project_page 'https://github.com/kwilczynski/puppet-functions'
diff --git a/README b/README
index c3a69c3..b01d803 100644
--- a/README
+++ b/README
@@ -1,3 +1,3 @@
-Various functions to use within Puppet will be stored here. Most of them
-are to be run by Puppet in order to extend its Domain Specific Language (DSL)
-abilities and functionality.
+puppet-functions
+
+This is the puppet-functions module.
diff --git a/abs.rb b/lib/puppet/parser/functions/abs.rb
index 0a554e4..0a554e4 100644
--- a/abs.rb
+++ b/lib/puppet/parser/functions/abs.rb
diff --git a/bool2num.rb b/lib/puppet/parser/functions/bool2num.rb
index b2989d0..b2989d0 100644
--- a/bool2num.rb
+++ b/lib/puppet/parser/functions/bool2num.rb
diff --git a/count.rb b/lib/puppet/parser/functions/count.rb
index c4e2283..c4e2283 100644
--- a/count.rb
+++ b/lib/puppet/parser/functions/count.rb
diff --git a/delete_at.rb b/lib/puppet/parser/functions/delete_at.rb
index 10190ba..10190ba 100644
--- a/delete_at.rb
+++ b/lib/puppet/parser/functions/delete_at.rb
diff --git a/empty.rb b/lib/puppet/parser/functions/empty.rb
index e78ebf0..e78ebf0 100644
--- a/empty.rb
+++ b/lib/puppet/parser/functions/empty.rb
diff --git a/fact.rb b/lib/puppet/parser/functions/fact.rb
index 27b7bb2..27b7bb2 100644
--- a/fact.rb
+++ b/lib/puppet/parser/functions/fact.rb
diff --git a/is_array.rb b/lib/puppet/parser/functions/is_array.rb
index 0b508fd..0b508fd 100644
--- a/is_array.rb
+++ b/lib/puppet/parser/functions/is_array.rb
diff --git a/is_hash.rb b/lib/puppet/parser/functions/is_hash.rb
index 259809c..259809c 100644
--- a/is_hash.rb
+++ b/lib/puppet/parser/functions/is_hash.rb
diff --git a/is_string.rb b/lib/puppet/parser/functions/is_string.rb
index 61037e3..61037e3 100644
--- a/is_string.rb
+++ b/lib/puppet/parser/functions/is_string.rb
diff --git a/join.rb b/lib/puppet/parser/functions/join.rb
index 945556a..945556a 100644
--- a/join.rb
+++ b/lib/puppet/parser/functions/join.rb
diff --git a/join_with_prefix.rb b/lib/puppet/parser/functions/join_with_prefix.rb
index 8bf96d9..8bf96d9 100644
--- a/join_with_prefix.rb
+++ b/lib/puppet/parser/functions/join_with_prefix.rb
diff --git a/keys.rb b/lib/puppet/parser/functions/keys.rb
index 3a92a47..3a92a47 100644
--- a/keys.rb
+++ b/lib/puppet/parser/functions/keys.rb
diff --git a/load_variables.rb b/lib/puppet/parser/functions/load_variables.rb
index a28c64b..a28c64b 100644
--- a/load_variables.rb
+++ b/lib/puppet/parser/functions/load_variables.rb
diff --git a/lib/puppet/parser/functions/member.rb b/lib/puppet/parser/functions/member.rb
new file mode 100644
index 0000000..a491a76
--- /dev/null
+++ b/lib/puppet/parser/functions/member.rb
@@ -0,0 +1,33 @@
+#
+# include.rb
+#
+
+# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
+# TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
+
+module Puppet::Parser::Functions
+ newfunction(:includes, :type => :rvalue, :doc => <<-EOS
+ EOS
+ ) do |arguments|
+
+ raise(Puppet::ParseError, "includes(): Wrong number of arguments " +
+ "given (#{arguments.size} for 2)") if arguments.size < 2
+
+ array = arguments[0]
+
+ if not array.is_a?(Array)
+ raise(Puppet::ParseError, 'includes(): Requires an array to work with')
+ end
+
+ item = arguments[1]
+
+ raise(Puppet::ParseError, 'includes(): You must provide item ' +
+ 'to search for within given array') if item.empty?
+
+ result = array.include?(item)
+
+ return result
+ end
+end
+
+# vim: set ts=2 sw=2 et :
diff --git a/num2bool.rb b/lib/puppet/parser/functions/num2bool.rb
index 2baef62..2baef62 100644
--- a/num2bool.rb
+++ b/lib/puppet/parser/functions/num2bool.rb
diff --git a/persistent_crontab_minutes.rb b/lib/puppet/parser/functions/persistent_crontab_minutes.rb
index cd80094..cd80094 100644
--- a/persistent_crontab_minutes.rb
+++ b/lib/puppet/parser/functions/persistent_crontab_minutes.rb
diff --git a/prefix.rb b/lib/puppet/parser/functions/prefix.rb
index 0e0cee2..0e0cee2 100644
--- a/prefix.rb
+++ b/lib/puppet/parser/functions/prefix.rb
diff --git a/random_crontab_minutes.rb b/lib/puppet/parser/functions/random_crontab_minutes.rb
index 8ab29e1..8ab29e1 100644
--- a/random_crontab_minutes.rb
+++ b/lib/puppet/parser/functions/random_crontab_minutes.rb
diff --git a/range.rb b/lib/puppet/parser/functions/range.rb
index 6afb50c..6afb50c 100644
--- a/range.rb
+++ b/lib/puppet/parser/functions/range.rb
diff --git a/reverse.rb b/lib/puppet/parser/functions/reverse.rb
index 79e9b93..79e9b93 100644
--- a/reverse.rb
+++ b/lib/puppet/parser/functions/reverse.rb
diff --git a/shuffle.rb b/lib/puppet/parser/functions/shuffle.rb
index 73e798c..73e798c 100644
--- a/shuffle.rb
+++ b/lib/puppet/parser/functions/shuffle.rb
diff --git a/size.rb b/lib/puppet/parser/functions/size.rb
index aa4f4ad..aa4f4ad 100644
--- a/size.rb
+++ b/lib/puppet/parser/functions/size.rb
diff --git a/strftime.rb b/lib/puppet/parser/functions/strftime.rb
index c919320..c919320 100644
--- a/strftime.rb
+++ b/lib/puppet/parser/functions/strftime.rb
diff --git a/time.rb b/lib/puppet/parser/functions/time.rb
index f7c1041..f7c1041 100644
--- a/time.rb
+++ b/lib/puppet/parser/functions/time.rb
diff --git a/unique.rb b/lib/puppet/parser/functions/unique.rb
index a922c94..a922c94 100644
--- a/unique.rb
+++ b/lib/puppet/parser/functions/unique.rb
diff --git a/values.rb b/lib/puppet/parser/functions/values.rb
index c1c4a77..c1c4a77 100644
--- a/values.rb
+++ b/lib/puppet/parser/functions/values.rb
diff --git a/values_at.rb b/lib/puppet/parser/functions/values_at.rb
index 331af6a..331af6a 100644
--- a/values_at.rb
+++ b/lib/puppet/parser/functions/values_at.rb