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
319 def initialize(loader)
320   super
321 
322   if Puppet.lookup(:yaml_plan_instantiator) { nil }
323     @extensions = [PP_EXT, YAML_EXT]
324   else
325     @extensions = [PP_EXT]
326   end
327   @init_filenames = @extensions.map { |ext| "init#{ext}" }
328 end

Public Instance Methods

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