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
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 59 def initialize(loader) 60 @loader = loader 61 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 85 def effective_path(typed_name, start_index_in_name) 86 "#{File.join(generic_path, typed_name.name_parts)}#{extension}" 87 end
fuzzy_matching?()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 71 def fuzzy_matching? 72 false 73 end
generic_path()
click to toggle source
Generic path, in the sense of “if there are any entities of this kind to load, where are they?”
# File lib/puppet/pops/loader/loader_paths.rb 64 def generic_path 65 return @generic_path unless @generic_path.nil? 66 67 the_root_path = root_path # @loader.path 68 @generic_path = (the_root_path.nil? ? relative_path : File.join(the_root_path, relative_path)) 69 end
instantiator()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 115 def instantiator 116 raise NotImplementedError.new 117 end
lib_root?()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 79 def lib_root? 80 @loader.lib_root? 81 end
relative_path()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 111 def relative_path 112 raise NotImplementedError.new 113 end
root_path()
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 75 def root_path 76 @loader.path 77 end
typed_name(type, name_authority, relative_path, module_name)
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 89 def typed_name(type, name_authority, relative_path, module_name) 90 # Module name is assumed to be included in the path and therefore not added here 91 n = String.new 92 unless extension.empty? 93 # Remove extension 94 relative_path = relative_path[0..-(extension.length+1)] 95 end 96 relative_path.split('/').each do |segment| 97 n << '::' if n.size > 0 98 n << segment 99 end 100 TypedName.new(type, n, name_authority) 101 end
valid_name?(typed_name)
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 107 def valid_name?(typed_name) 108 true 109 end
valid_path?(path)
click to toggle source
# File lib/puppet/pops/loader/loader_paths.rb 103 def valid_path?(path) 104 path.end_with?(extension) && path.start_with?(generic_path) 105 end