class Puppet::Pops::Loader::LoaderPaths::SmartPath
# DO NOT REMOVE YET. needed later? when there is the need to decamel a classname def de_camel(fq_name)
fq_name.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase
end
Attributes
generic_path[R]
Generic path, in the sense of “if there are any entities of this kind to load, where are they?”
Public Class Methods
new(loader)
click to toggle source
Creates SmartPath
for the given loader (loader knows how to check for existence etc.)
# File lib/puppet/pops/loader/loader_paths.rb 61 def initialize(loader) 62 @loader = loader 63 end
Public Instance Methods
effective_path(typed_name, start_index_in_name)
click to toggle source
Effective path is the generic path + the name part(s) + extension.
# File lib/puppet/pops/loader/loader_paths.rb 86 def effective_path(typed_name, start_index_in_name) 87 "#{File.join(generic_path, typed_name.name_parts)}#{extension}" 88 end
fuzzy_matching?()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 72 def fuzzy_matching? 73 false 74 end
instantiator()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 116 def instantiator 117 raise NotImplementedError.new 118 end
lib_root?()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 80 def lib_root? 81 @loader.lib_root? 82 end
relative_path()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 112 def relative_path 113 raise NotImplementedError.new 114 end
root_path()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 76 def root_path 77 @loader.path 78 end
typed_name(type, name_authority, relative_path, module_name)
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 90 def typed_name(type, name_authority, relative_path, module_name) 91 # Module name is assumed to be included in the path and therefore not added here 92 n = '' 93 unless extension.empty? 94 # Remove extension 95 relative_path = relative_path[0..-(extension.length+1)] 96 end 97 relative_path.split('/').each do |segment| 98 n << '::' if n.size > 0 99 n << segment 100 end 101 TypedName.new(type, n, name_authority) 102 end
valid_name?(typed_name)
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 108 def valid_name?(typed_name) 109 true 110 end
valid_path?(path)
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 104 def valid_path?(path) 105 path.end_with?(extension) && path.start_with?(generic_path) 106 end