Method: Puppet::Parser::TypeLoader#import

Defined in:
lib/puppet/parser/type_loader.rb

#import(pattern, dir) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Import manifest files that match a given file glob pattern.

Parameters:

  • pattern (String)

    the file glob to apply when determining which files to load

  • dir (String)

    base directory to use when the file is not found in a module



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/puppet/parser/type_loader.rb', line 19

def import(pattern, dir)
  modname, files = Puppet::Parser::Files.find_manifests_in_modules(pattern, environment)
  if files.empty?
    abspat = File.expand_path(pattern, dir)
    file_pattern = abspat + (File.extname(abspat).empty? ? '.pp' : '')

    files = Dir.glob(file_pattern).uniq.reject { |f| FileTest.directory?(f) }
    modname = nil

    if files.empty?
      raise_no_files_found(pattern)
    end
  end

  load_files(modname, files)
end