File: dos2unix.rb

package info (click to toggle)
puppet-module-puppetlabs-stdlib 9.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,448 kB
  • sloc: ruby: 3,522; sh: 46; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 499 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

# Custom Puppet function to convert dos to unix format
module Puppet::Parser::Functions
  newfunction(:dos2unix, type: :rvalue, arity: 1, doc: <<-DOC
    @summary
      Returns the Unix version of the given string.

    Takes a single string argument.

    @return The retrieved version
  DOC
  ) do |arguments|
    raise(Puppet::ParseError, 'dos2unix(): Requires string as argument') unless arguments[0].is_a?(String)

    arguments[0].gsub(%r{\r\n}, "\n")
  end
end