summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/unix2dos.rb
blob: 0bd9cd1f12027ee616a6e3b310616555a0dc6891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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