Class: Puppet::Pops::Loader::ModuleLoaders::FileBased Private
- Inherits:
-
AbstractPathBasedModuleLoader
- Object
- Loader
- BaseLoader
- AbstractPathBasedModuleLoader
- Puppet::Pops::Loader::ModuleLoaders::FileBased
- Defined in:
- lib/puppet/pops/loader/module_loaders.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Attribute Summary collapse
- #path_index ⇒ Object readonly private
- #smart_paths ⇒ Object readonly private
Attributes inherited from AbstractPathBasedModuleLoader
#module_name, #path, #private_loader
Attributes inherited from BaseLoader
Instance Method Summary collapse
- #add_to_index(smart_path) ⇒ Object private
- #existing_path(effective_path) ⇒ Object private
- #get_contents(effective_path) ⇒ Object private
-
#initialize(parent_loader, loaders, module_name, path, loader_name) ⇒ FileBased
constructor
private
Create a kind of ModuleLoader for one module (Puppet Module, or module like).
- #meaningful_to_search?(smart_path) ⇒ Boolean private
- #to_s ⇒ Object private
Methods inherited from AbstractPathBasedModuleLoader
Methods inherited from BaseLoader
#add_entry, #get_entry, #load_typed, #promote_entry, #set_entry
Methods inherited from Loader
#[], #find, #get_entry, #load, #load_typed, #parent, #private_loader, #set_entry
Constructor Details
#initialize(parent_loader, loaders, module_name, path, loader_name) ⇒ FileBased
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a kind of ModuleLoader for one module (Puppet Module, or module like)
198 199 200 201 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 198 def initialize(parent_loader, loaders, module_name, path, loader_name) super @path_index = Set.new() end |
Instance Attribute Details
#path_index ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
189 190 191 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 189 def path_index @path_index end |
#smart_paths ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
188 189 190 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 188 def smart_paths @smart_paths end |
Instance Method Details
#add_to_index(smart_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
216 217 218 219 220 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 216 def add_to_index(smart_path) found = Dir.glob(File.join(smart_path.generic_path, '**', "*#{smart_path.extension}")) @path_index.merge(found) found end |
#existing_path(effective_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
203 204 205 206 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 203 def existing_path(effective_path) # Optimized, checks index instead of visiting file system @path_index.include?(effective_path) ? effective_path : nil end |
#get_contents(effective_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
222 223 224 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 222 def get_contents(effective_path) Puppet::FileSystem.read(effective_path) end |
#meaningful_to_search?(smart_path) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
208 209 210 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 208 def meaningful_to_search?(smart_path) ! add_to_index(smart_path).empty? end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
212 213 214 |
# File 'lib/puppet/pops/loader/module_loaders.rb', line 212 def to_s() "(ModuleLoader::FileBased '#{loader_name()}' '#{module_name()}')" end |