summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/unix2dos.rb
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
committervarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
commit066c08f8362d53f0f30897cb8710d11260c726ea (patch)
treea6369eecd88bb731fe413d0bbc8af73d74d1f447 /lib/puppet/parser/functions/unix2dos.rb
parent71123634744b9fe2ec7d6a3e38e9789fd84801e3 (diff)
parentb65dd1f45d10e10e45455358aeabb29167990e2c (diff)
Merge remote-tracking branch 'origin/master' into leap_master
Diffstat (limited to 'lib/puppet/parser/functions/unix2dos.rb')
-rw-r--r--lib/puppet/parser/functions/unix2dos.rb15
1 files changed, 15 insertions, 0 deletions
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