Method: Inspec::FileProvider.for_path

Defined in:
lib/inspec/file_provider.rb

.for_path(path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/inspec/file_provider.rb', line 8

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