Module: PuppetDebugger::Support::Loader

Included in:
PuppetDebugger::Support
Defined in:
lib/puppet-debugger/support/loader.rb

Overview

the Loader module wraps a few puppet loader functions

Instance Method Summary collapse

Instance Method Details

#all_data_typesArray[String]

Returns - combined list of core data types and environment data types.

Returns:

  • (Array[String])
    • combined list of core data types and environment data types



29
30
31
32
33
34
35
# File 'lib/puppet-debugger/support/loader.rb', line 29

def all_data_types
  unless loaders.respond_to?(:implementation_registry)
    Puppet.info("Data Types Not Available in Puppet: #{Puppet.version}")
    return []
  end
  core_datatypes + environment_data_types
end

#core_datatypesArray[String]

Returns - a list of core data types.

Returns:

  • (Array[String])
    • a list of core data types



22
23
24
25
26
# File 'lib/puppet-debugger/support/loader.rb', line 22

def core_datatypes
  loaders.implementation_registry
         .instance_variable_get(:'@implementations_per_type_name')
         .keys.find_all { |t| t !~ /::/ }
end

#create_loader(environment) ⇒ Object



7
8
9
# File 'lib/puppet-debugger/support/loader.rb', line 7

def create_loader(environment)
  Puppet::Pops::Loaders.new(environment)
end

#environment_data_typesArray[String]

Returns - returns a list of all the custom data types found in all the modules in the environment.

Returns:

  • (Array[String])
    • returns a list of all the custom data types found in all the modules in the environment



12
13
14
15
16
17
18
19
# File 'lib/puppet-debugger/support/loader.rb', line 12

def environment_data_types
  files = Dir.glob(puppet_environment.modulepath.map { |m| File.join(m, '**', 'types', '**', '*.pp') })
  files.map do |f|
    m = File.read(f).match(/type\s([a-z\d\:_]+)/i)
    next if m =~ /type|alias/ # can't figure out the best way to filter type and alias out
    m[1] if m && m[1] =~ /::/
  end.uniq.compact
end

#loadersObject



37
38
39
# File 'lib/puppet-debugger/support/loader.rb', line 37

def loaders
  @loaders ||= create_loader(puppet_environment)
end