Class: Inspec::DirProvider

Inherits:
FileProvider show all
Defined in:
lib/inspec/file_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FileProvider

for_path, #relative_provider

Constructor Details

#initialize(path) ⇒ DirProvider

Returns a new instance of DirProvider.



54
55
56
57
58
59
60
61
# File 'lib/inspec/file_provider.rb', line 54

def initialize(path)
  @files = if File.file?(path)
             [path]
           else
             Dir[File.join(path, '**', '*')]
           end
  @path = path
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



53
54
55
# File 'lib/inspec/file_provider.rb', line 53

def files
  @files
end

Instance Method Details

#read(file) ⇒ Object



63
64
65
66
67
# File 'lib/inspec/file_provider.rb', line 63

def read(file)
  return nil unless files.include?(file)
  return nil unless File.file?(file)
  File.read(file)
end