class Inspec::FileProvider
def self.for_path(path)
def self.for_path(path) if path.is_a?(Hash) MockProvider.new(path) elsif File.directory?(path) DirProvider.new(path) elsif File.exist?(path) && path.end_with?('.tar.gz', 'tgz') TarProvider.new(path) elsif File.exist?(path) && path.end_with?('.zip') ZipProvider.new(path) elsif File.exist?(path) DirProvider.new(path) else raise "No file provider for the provided path: #{path}" end end
def binread(file)
way in which encoding of the returned data structure is handled.
it, it will be the same. For some special cases, it will add change the
It will default to #read if not defined. For most streams that implement
Provide a method for reading binary contents from a file.
def binread(file) read(file) end
def files
-
(Array[String])- list of file paths that are included
def files raise "Fetcher #{self} does not implement `files()`. This is required." end
def initialize(_path)
def initialize(_path) end
def read(_file)
-
(String)- contents of the file described
Parameters:
-
_file(String) -- path of the file to be read
def read(_file) raise "#{self} does not implement `read(...)`. This is required." end
def relative_provider
def relative_provider RelativeFileProvider.new(self) end