Method: PuppetX::FileMapper::ClassMethods#load_all_providers_from_disk
- Defined in:
- lib/puppetx/filemapper.rb
#load_all_providers_from_disk ⇒ Array<Hash<String, Hash<Symbol, Object>>>
Reads all files from disk and returns an array of hashes representing provider instances.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/puppetx/filemapper.rb', line 153 def load_all_providers_from_disk validate_class! # Retrieve a list of files to fetch, and cache a copy of a filetype # for each one target_files.each do |file| @mapped_files[file][:filetype] = Puppet::Util::FileType.filetype(filetype).new(file) @mapped_files[file][:dirty] = false end # Read and parse each file. provider_hashes = [] @mapped_files.each_pair do |filename, file_attrs| # The filetype path must be a type pathname, or it must respond to to_str # If it doesn't meet these criteria go to next file path = file_attrs[:filetype].path next unless path.is_a?(Pathname) || path.respond_to?(:to_str) arr = parse_file(filename, file_attrs[:filetype].read) unless arr.is_a? Array raise Puppet::DevError, "expected #{self}.parse_file to return an Array, got a #{arr.class}" end provider_hashes.concat arr end provider_hashes end |