]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Convert to module format.
authorKen Barber <ken@bob.sh>
Fri, 29 Apr 2011 07:27:10 +0000 (09:27 +0200)
committerKen Barber <ken@bob.sh>
Sat, 30 Apr 2011 13:59:31 +0000 (15:59 +0200)
30 files changed:
.gitignore [new file with mode: 0644]
Modulefile [new file with mode: 0644]
README
lib/puppet/parser/functions/abs.rb [moved from abs.rb with 100% similarity]
lib/puppet/parser/functions/bool2num.rb [moved from bool2num.rb with 100% similarity]
lib/puppet/parser/functions/count.rb [moved from count.rb with 100% similarity]
lib/puppet/parser/functions/delete_at.rb [moved from delete_at.rb with 100% similarity]
lib/puppet/parser/functions/empty.rb [moved from empty.rb with 100% similarity]
lib/puppet/parser/functions/fact.rb [moved from fact.rb with 100% similarity]
lib/puppet/parser/functions/is_array.rb [moved from is_array.rb with 100% similarity]
lib/puppet/parser/functions/is_hash.rb [moved from is_hash.rb with 100% similarity]
lib/puppet/parser/functions/is_string.rb [moved from is_string.rb with 100% similarity]
lib/puppet/parser/functions/join.rb [moved from join.rb with 100% similarity]
lib/puppet/parser/functions/join_with_prefix.rb [moved from join_with_prefix.rb with 100% similarity]
lib/puppet/parser/functions/keys.rb [moved from keys.rb with 100% similarity]
lib/puppet/parser/functions/load_variables.rb [moved from load_variables.rb with 100% similarity]
lib/puppet/parser/functions/member.rb [new file with mode: 0644]
lib/puppet/parser/functions/num2bool.rb [moved from num2bool.rb with 100% similarity]
lib/puppet/parser/functions/persistent_crontab_minutes.rb [moved from persistent_crontab_minutes.rb with 100% similarity]
lib/puppet/parser/functions/prefix.rb [moved from prefix.rb with 100% similarity]
lib/puppet/parser/functions/random_crontab_minutes.rb [moved from random_crontab_minutes.rb with 100% similarity]
lib/puppet/parser/functions/range.rb [moved from range.rb with 100% similarity]
lib/puppet/parser/functions/reverse.rb [moved from reverse.rb with 100% similarity]
lib/puppet/parser/functions/shuffle.rb [moved from shuffle.rb with 100% similarity]
lib/puppet/parser/functions/size.rb [moved from size.rb with 100% similarity]
lib/puppet/parser/functions/strftime.rb [moved from strftime.rb with 100% similarity]
lib/puppet/parser/functions/time.rb [moved from time.rb with 100% similarity]
lib/puppet/parser/functions/unique.rb [moved from unique.rb with 100% similarity]
lib/puppet/parser/functions/values.rb [moved from values.rb with 100% similarity]
lib/puppet/parser/functions/values_at.rb [moved from values_at.rb with 100% similarity]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..01d0a08
--- /dev/null
@@ -0,0 +1 @@
+pkg/
diff --git a/Modulefile b/Modulefile
new file mode 100644 (file)
index 0000000..9b7d1e1
--- /dev/null
@@ -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 c3a69c38df976bd8f8549f4adcb064d718c82277..b01d803a1cf75cfc5a37a154c9eb8a44c37fb21c 100644 (file)
--- 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.
similarity index 100%
rename from abs.rb
rename to lib/puppet/parser/functions/abs.rb
similarity index 100%
rename from fact.rb
rename to lib/puppet/parser/functions/fact.rb
similarity index 100%
rename from join.rb
rename to lib/puppet/parser/functions/join.rb
similarity index 100%
rename from keys.rb
rename to lib/puppet/parser/functions/keys.rb
diff --git a/lib/puppet/parser/functions/member.rb b/lib/puppet/parser/functions/member.rb
new file mode 100644 (file)
index 0000000..a491a76
--- /dev/null
@@ -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 :
similarity index 100%
rename from size.rb
rename to lib/puppet/parser/functions/size.rb
similarity index 100%
rename from time.rb
rename to lib/puppet/parser/functions/time.rb