aboutsummaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2015-02-20 15:37:10 -0500
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2015-02-20 15:37:10 -0500
commitc6beeb1718608389e027d287c7a8ddd586313df2 (patch)
treee7c2d4161b529967079d20ff4f81e5c118cf1a67 /lib/puppet
parentac5da1df281e636ecffe260b681e8119a1057e1d (diff)
parente9d8147584cf42dceec6d2cdd4314e8a85dc3aeb (diff)
downloadpuppet-common-c6beeb1718608389e027d287c7a8ddd586313df2.tar.gz
puppet-common-c6beeb1718608389e027d287c7a8ddd586313df2.tar.bz2
Merge branch 'master' of git://git.puppet.immerda.ch/module-common
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/functions/array_del.rb11
-rw-r--r--lib/puppet/parser/functions/array_include.rb11
-rw-r--r--lib/puppet/parser/functions/get_default.rb15
-rw-r--r--lib/puppet/parser/functions/join.rb10
-rw-r--r--lib/puppet/parser/functions/strlength.rb6
-rw-r--r--lib/puppet/parser/functions/tfile.rb3
-rw-r--r--lib/puppet/parser/functions/uniq_flatten.rb10
7 files changed, 17 insertions, 49 deletions
diff --git a/lib/puppet/parser/functions/array_del.rb b/lib/puppet/parser/functions/array_del.rb
deleted file mode 100644
index e604916..0000000
--- a/lib/puppet/parser/functions/array_del.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-Puppet::Parser::Functions::newfunction(
- :array_del,
- :type => :rvalue,
- :doc => "Deletes items from an array
-
- Example: array_del(['a','b'],'b') -> ['a']"
-) do |args|
- raise Puppet::ParseError, 'array_del() needs two arguments' if args.length != 2
- (res=args[0].dup).to_a.delete(args[1])
- res
-end
diff --git a/lib/puppet/parser/functions/array_include.rb b/lib/puppet/parser/functions/array_include.rb
deleted file mode 100644
index ce4748d..0000000
--- a/lib/puppet/parser/functions/array_include.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-Puppet::Parser::Functions::newfunction(
- :array_include,
- :type => :rvalue,
- :doc => "Checks whether an item is included or not
-
- Example: array_include(['a','b'],'b') -> true
- Example: array_include(['a','b'],'c') -> false"
-) do |args|
- raise Puppet::ParseError, 'array_include() needs two arguments' if args.length != 2
- args[0].include?(args[1])
-end
diff --git a/lib/puppet/parser/functions/get_default.rb b/lib/puppet/parser/functions/get_default.rb
new file mode 100644
index 0000000..3f4359b
--- /dev/null
+++ b/lib/puppet/parser/functions/get_default.rb
@@ -0,0 +1,15 @@
+# get_default($value, $default) : $value
+#
+# return $value || $default.
+module Puppet::Parser::Functions
+ newfunction(:get_default, :type => :rvalue) do |args|
+ value = nil
+ args.each { |x|
+ if ! x.nil? and x.length > 0
+ value = x
+ break
+ end
+ }
+ return value
+ end
+end
diff --git a/lib/puppet/parser/functions/join.rb b/lib/puppet/parser/functions/join.rb
deleted file mode 100644
index 95b664c..0000000
--- a/lib/puppet/parser/functions/join.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-Puppet::Parser::Functions::newfunction(
- :join,
- :type => :rvalue,
- :doc => "Joins the values of the array in arg1 with the string in arg2
-
- Example: join(['a','b'],',') -> 'a,b'"
-) do |args|
- raise Puppet::ParseError, 'join() needs two arguments' if args.length != 2
- args[0].to_a.join(args[1])
-end
diff --git a/lib/puppet/parser/functions/strlength.rb b/lib/puppet/parser/functions/strlength.rb
deleted file mode 100644
index 147b24a..0000000
--- a/lib/puppet/parser/functions/strlength.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Puppet::Parser::Functions
- newfunction(:strlength, :type => :rvalue) do |args|
- args[0].to_s.length
- end
-end
-
diff --git a/lib/puppet/parser/functions/tfile.rb b/lib/puppet/parser/functions/tfile.rb
index a984892..acb6609 100644
--- a/lib/puppet/parser/functions/tfile.rb
+++ b/lib/puppet/parser/functions/tfile.rb
@@ -9,7 +9,8 @@ Puppet::Parser::Functions::newfunction(
unless File.exists?(path)
dir = File.dirname(path)
unless File.directory?(dir)
- Puppet::Util.recmkdir(dir,0700)
+ require 'fileutils'
+ FileUtils.mkdir_p(dir, :mode => 0700)
end
require 'fileutils'
FileUtils.touch(path)
diff --git a/lib/puppet/parser/functions/uniq_flatten.rb b/lib/puppet/parser/functions/uniq_flatten.rb
deleted file mode 100644
index 4841c4d..0000000
--- a/lib/puppet/parser/functions/uniq_flatten.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-Puppet::Parser::Functions::newfunction(
- :uniq_flatten,
- :type => :rvalue,
- :doc => "Flattens an array and make it uniq
-
- Example: uniq_flatten([['a','b'],'a']) -> ['a','b']"
-) do |args|
- raise Puppet::ParseError, 'uniq_flatten() needs one arguments' if args.length != 1
- args[0].to_a.flatten.collect(&:to_s).uniq
-end