Class: Puppet::Pops::Loader::LoaderPaths::TaskPath
Overview
TaskPath is like PuppetSmartPath but it does not use an extension and may match more than one path with one name
Constant Summary
collapse
- TASKS_PATH =
'tasks'.freeze
- FORBIDDEN_EXTENSIONS =
%w{.conf .md}.freeze
PuppetSmartPath::EXTENSION
Instance Attribute Summary
Attributes inherited from SmartPath
#generic_path
Instance Method Summary
collapse
#effective_path
Methods inherited from SmartPath
#effective_path, #initialize, #lib_root?, #root_path
Instance Method Details
#extension ⇒ Object
240
241
242
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 240
def extension
EMPTY_STRING
end
|
#fuzzy_matching? ⇒ Boolean
244
245
246
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 244
def fuzzy_matching?
true
end
|
#instantiator ⇒ Object
270
271
272
273
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 270
def instantiator
require_relative 'task_instantiator'
TaskInstantiator
end
|
#is_task_name?(name) ⇒ Boolean
284
285
286
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 284
def is_task_name?(name)
!!(name =~ /^[a-z][a-z0-9_]*$/)
end
|
#relative_path ⇒ Object
248
249
250
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 248
def relative_path
TASKS_PATH
end
|
#typed_name(type, name_authority, relative_path, module_name) ⇒ Object
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 252
def typed_name(type, name_authority, relative_path, module_name)
n = ''
n << module_name unless module_name.nil?
relative_path = relative_path.sub(%r{\.[^/.]*\z}, '')
if relative_path == 'init' && !(module_name.nil? || module_name.empty?)
TypedName.new(type, module_name, name_authority)
else
relative_path.split('/').each do |segment|
n << '::' if n.size > 0
n << segment
end
TypedName.new(type, n, name_authority)
end
end
|
#valid_name?(typed_name) ⇒ Boolean
275
276
277
278
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 275
def valid_name?(typed_name)
typed_name.name_parts.size <= 2
end
|
#valid_path?(path) ⇒ Boolean
280
281
282
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 280
def valid_path?(path)
path.start_with?(generic_path) && is_task_name?(File.basename(path, '.*')) && !FORBIDDEN_EXTENSIONS.any? { |ext| path.end_with?(ext) }
end
|