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'

Instance Method Summary collapse

Methods inherited from SmartPath

#fuzzy_matching?, #generic_path, #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



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

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..]
  end
  "#{File.join(generic_path, parts)}#{extension}"
end

#extensionObject



138
139
140
# File 'lib/puppet/pops/loader/loader_paths.rb', line 138

def extension
  EXTENSION
end

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



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

def typed_name(type, name_authority, relative_path, module_name)
  n = ''.dup
  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