Puppet Function: getparent

Defined in:
lib/puppet/parser/functions/getparent.rb
Function type:
Ruby 3.x API

Overview

getparent()Any

Returns:

  • (Any)


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/puppet/parser/functions/getparent.rb', line 4

newfunction(:getparent, :type => :rvalue) do |args|
  if args.length == 1
    # normalize the path to use forward slashes
    original_path = args[0].gsub /\\+/, '/'
    return Pathname(original_path).parent.to_s
  elsif args.length > 1
    raise Puppet::ParseError, "only 1 path may be supplied"
  else
    raise Puppet::ParseError, "path argument required"
  end
end