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.

Constant Summary collapse

EXTENSION =
'.pp'.freeze

Instance Attribute Summary

Attributes inherited from SmartPath

#generic_path

Instance Method Summary collapse

Methods inherited from SmartPath

#fuzzy_matching?, #initialize, #instantiator, #lib_root?, #relative_path, #root_path, #valid_name?, #valid_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


145
146
147
148
149
150
151
152
153
154
# File 'lib/puppet/pops/loader/loader_paths.rb', line 145

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
  parts = typed_name.name_parts
  if start_index_in_name > 0
    return nil if start_index_in_name >= parts.size
    parts = parts[start_index_in_name..-1]
  end
  "#{File.join(generic_path, parts)}#{extension}"
end

#extensionObject


140
141
142
# File 'lib/puppet/pops/loader/loader_paths.rb', line 140

def extension
  EXTENSION
end

#typed_name(type, name_authority, relative_path, module_name) ⇒ Object


156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/puppet/pops/loader/loader_paths.rb', line 156

def typed_name(type, name_authority, relative_path, module_name)
  n = ''
  n << module_name unless module_name.nil?
  unless extension.empty?
    # Remove extension
    relative_path = relative_path[0..-(extension.length+1)]
  end
  relative_path.split('/').each do |segment|
    n << '::' if n.size > 0
    n << segment
  end
  TypedName.new(type, n, name_authority)
end