Class: Puppet::Pops::Loader::LoaderPaths::PuppetSmartPath

Inherits:
SmartPath show all
Defined in:
lib/puppet/pops/loader/loader_paths.rb

Overview

A PuppetSmartPath is rooted at the loader’s directory one level up from what the loader specifies as it path (which is a reference to its ‘lib’ directory.

Direct Known Subclasses

FunctionPathPP, TypePathPP

Constant Summary collapse

EXTENSION =
'.pp'.freeze

Instance Attribute Summary

Attributes inherited from SmartPath

#generic_path

Instance Method Summary collapse

Methods inherited from SmartPath

#initialize, #instantiator, #relative_path

Constructor Details

This class inherits a constructor from Puppet::Pops::Loader::LoaderPaths::SmartPath

Instance Method Details

#effective_path(typed_name, start_index_in_name) ⇒ Object

Duplication of extension information, but avoids one call



108
109
110
111
112
# File 'lib/puppet/pops/loader/loader_paths.rb', line 108

def effective_path(typed_name, start_index_in_name)
  # Puppet name to path always skips the name-space as that is part of the generic path
  # i.e. <module>/mymodule/functions/foo.pp is the function mymodule::foo
  "#{File.join(generic_path, typed_name.name_parts[ 1..-1 ])}.pp"
end

#extensionObject



98
99
100
# File 'lib/puppet/pops/loader/loader_paths.rb', line 98

def extension
  EXTENSION
end

#root_pathObject



102
103
104
105
# File 'lib/puppet/pops/loader/loader_paths.rb', line 102

def root_path
  # Drop the lib part (it may not exist and cannot be navigated to in a relative way)
  Puppet::FileSystem.dir_string(@loader.path)
end