summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2009-02-14 02:11:21 +1100
committerJames Turnbull <james@lovedthanlost.net>2009-02-14 02:11:21 +1100
commit1bc7404f5e3efa633bb0a5cf10828071cfc4d876 (patch)
tree97a71a66d524a8d934552cd95ec4f229b6183e0d /lib/puppet/parser
parent336b6458a2264c550adf8e6799162380822e0d97 (diff)
downloadpuppet-1bc7404f5e3efa633bb0a5cf10828071cfc4d876.tar.gz
puppet-1bc7404f5e3efa633bb0a5cf10828071cfc4d876.tar.xz
puppet-1bc7404f5e3efa633bb0a5cf10828071cfc4d876.zip
Fixed #1831 - Added sprintf function
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/sprintf.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb
new file mode 100644
index 000000000..79744104d
--- /dev/null
+++ b/lib/puppet/parser/functions/sprintf.rb
@@ -0,0 +1,17 @@
+module Puppet::Parser::Functions
+ newfunction(:sprintf, :type => :rvalue,
+ :doc => "\
+ Perform printf-style formatting of text.
+
+ The first parameter is format string describing how the rest of the
+ parameters should be formatted. See the documentation for the
+ ``Kernel::sprintf()`` function in Ruby for all the details.
+ ") \
+ do |args|
+ if args.length < 1
+ raise Puppet::ParseError, 'sprintf() needs at least one argument'
+ end
+ fmt = args.shift()
+ return sprintf(fmt, *args)
+ end
+end