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'
- FORBIDDEN_EXTENSIONS =
%w[.conf .md].freeze
PuppetSmartPath::EXTENSION
Instance Method Summary
collapse
#effective_path
Methods inherited from SmartPath
#effective_path, #generic_path, #initialize, #lib_root?, #root_path
Instance Method Details
#extension ⇒ Object
239
240
241
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 239
def extension
EMPTY_STRING
end
|
#fuzzy_matching? ⇒ Boolean
243
244
245
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 243
def fuzzy_matching?
true
end
|
#instantiator ⇒ Object
269
270
271
272
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 269
def instantiator
require_relative 'task_instantiator'
TaskInstantiator
end
|
#is_task_name?(name) ⇒ Boolean
283
284
285
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 283
def is_task_name?(name)
!!(name =~ /^[a-z][a-z0-9_]*$/)
end
|
#relative_path ⇒ Object
247
248
249
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 247
def relative_path
TASKS_PATH
end
|
#typed_name(type, name_authority, relative_path, module_name) ⇒ Object
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 251
def typed_name(type, name_authority, relative_path, module_name)
n = ''.dup
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
274
275
276
277
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 274
def valid_name?(typed_name)
typed_name.name_parts.size <= 2
end
|
#valid_path?(path) ⇒ Boolean
279
280
281
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 279
def valid_path?(path)
path.start_with?(generic_path) && is_task_name?(File.basename(path, '.*')) && !FORBIDDEN_EXTENSIONS.any? { |ext| path.end_with?(ext) }
end
|