Class: Puppet::Pops::Loader::LoaderPaths::PlanPath
Constant Summary
collapse
- PLAN_PATH =
File.join('plans')
- PP_EXT =
'.pp'
- YAML_EXT =
'.yaml'
Puppet::Pops::Loader::LoaderPaths::PuppetSmartPath::EXTENSION
Instance Method Summary
collapse
Methods inherited from SmartPath
#generic_path, #lib_root?, #root_path, #valid_name?
Constructor Details
#initialize(loader) ⇒ PlanPath
Returns a new instance of PlanPath.
319
320
321
322
323
324
325
326
327
328
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 319
def initialize(loader)
super
if Puppet.lookup(:yaml_plan_instantiator) { nil }
@extensions = [PP_EXT, YAML_EXT]
else
@extensions = [PP_EXT]
end
@init_filenames = @extensions.map { |ext| "init#{ext}" }
end
|
Instance Method Details
#effective_path(typed_name, start_index_in_name) ⇒ Object
367
368
369
370
371
372
373
374
375
376
377
378
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 367
def effective_path(typed_name, start_index_in_name)
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
basename = File.join(generic_path, parts)
@extensions.map { |ext| "#{basename}#{ext}" }
end
|
#extension ⇒ Object
330
331
332
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 330
def extension
EMPTY_STRING
end
|
#fuzzy_matching? ⇒ Boolean
342
343
344
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 342
def fuzzy_matching?
true
end
|
#relative_path ⇒ Object
334
335
336
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 334
def relative_path
PLAN_PATH
end
|
#typed_name(type, name_authority, relative_path, module_name) ⇒ Object
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 350
def typed_name(type, name_authority, relative_path, module_name)
if @init_filenames.include?(relative_path) && !(module_name.nil? || module_name.empty?)
TypedName.new(type, module_name, name_authority)
else
n = ''.dup
n << module_name unless module_name.nil?
ext = @extensions.find { |extension| relative_path.end_with?(extension) }
relative_path = relative_path[0..-(ext.length + 1)]
relative_path.split('/').each do |segment|
n << '::' if n.size > 0
n << segment
end
TypedName.new(type, n, name_authority)
end
end
|
#valid_path?(path) ⇒ Boolean
346
347
348
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 346
def valid_path?(path)
@extensions.any? { |ext| path.end_with?(ext) } && path.start_with?(generic_path)
end
|