diff options
Diffstat (limited to 'code/environments/production/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb')
-rw-r--r-- | code/environments/production/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/code/environments/production/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb b/code/environments/production/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb new file mode 100644 index 0000000..32722ba --- /dev/null +++ b/code/environments/production/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb @@ -0,0 +1,15 @@ +# Custom Puppet function to convert dos to unix format +module Puppet::Parser::Functions + newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-DOC + Returns the Unix version of the given string. + Takes a single string argument. + DOC + ) do |arguments| + + unless arguments[0].is_a?(String) + raise(Puppet::ParseError, 'dos2unix(): Requires string as argument') + end + + arguments[0].gsub(%r{\r\n}, "\n") + end +end |