class Puppet::Pops::Loader::LoaderPaths::PlanPath

Constants

PLAN_PATH
PP_EXT
YAML_EXT

Public Class Methods

new(loader) click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
320 def initialize(loader)
321   super
322 
323   if Puppet.lookup(:yaml_plan_instantiator) { nil }
324     @extensions = [PP_EXT, YAML_EXT]
325   else
326     @extensions = [PP_EXT]
327   end
328   @init_filenames = @extensions.map { |ext| "init#{ext}" }
329 end

Public Instance Methods

effective_path(typed_name, start_index_in_name) click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
368 def effective_path(typed_name, start_index_in_name)
369   # Puppet name to path always skips the name-space as that is part of the generic path
370   # i.e. <module>/mymodule/functions/foo.pp is the function mymodule::foo
371   parts = typed_name.name_parts
372   if start_index_in_name > 0
373     return nil if start_index_in_name >= parts.size
374     parts = parts[start_index_in_name..-1]
375   end
376   basename = File.join(generic_path, parts)
377   @extensions.map { |ext| "#{basename}#{ext}" }
378 end
extension() click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
331 def extension
332   EMPTY_STRING
333 end
fuzzy_matching?() click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
343 def fuzzy_matching?
344   true
345 end
instantiator() click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
339 def instantiator()
340   Puppet::Pops::Loader::GenericPlanInstantiator
341 end
relative_path() click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
335 def relative_path
336   PLAN_PATH
337 end
typed_name(type, name_authority, relative_path, module_name) click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
351 def typed_name(type, name_authority, relative_path, module_name)
352   if @init_filenames.include?(relative_path) && !(module_name.nil? || module_name.empty?)
353     TypedName.new(type, module_name, name_authority)
354   else
355     n = ''
356     n << module_name unless module_name.nil?
357     ext = @extensions.find { |extension| relative_path.end_with?(extension) }
358     relative_path = relative_path[0..-(ext.length+1)]
359 
360     relative_path.split('/').each do |segment|
361       n << '::' if n.size > 0
362       n << segment
363     end
364     TypedName.new(type, n, name_authority)
365   end
366 end
valid_path?(path) click to toggle source
    # File lib/puppet/pops/loader/loader_paths.rb
347 def valid_path?(path)
348   @extensions.any? { |ext| path.end_with?(ext) } && path.start_with?(generic_path)
349 end