From 4cbe846750c40dec57c55dbe6382dfa57c4d79af Mon Sep 17 00:00:00 2001 From: Nigel Gibbs Date: Fri, 14 Aug 2015 09:33:46 +0100 Subject: (MODULES-2410) Add new functions dos2unix and unix2dos --- lib/puppet/parser/functions/unix2dos.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/puppet/parser/functions/unix2dos.rb (limited to 'lib/puppet/parser/functions/unix2dos.rb') diff --git a/lib/puppet/parser/functions/unix2dos.rb b/lib/puppet/parser/functions/unix2dos.rb new file mode 100644 index 0000000..0bd9cd1 --- /dev/null +++ b/lib/puppet/parser/functions/unix2dos.rb @@ -0,0 +1,15 @@ +# Custom Puppet function to convert unix to dos format +module Puppet::Parser::Functions + newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-EOS + Returns the DOS version of the given string. + Takes a single string argument. + EOS + ) do |arguments| + + unless arguments[0].is_a?(String) + raise(Puppet::ParseError, 'unix2dos(): Requires string as argument') + end + + arguments[0].gsub(/\r*\n/, "\r\n") + end +end -- cgit v1.2.3