Class: Inspec::Targets::FolderHelper

Inherits:
DirsResolver show all
Defined in:
lib/inspec/targets/folder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DirsResolver

__collect, from_target, #handler, resolve

Constructor Details

#initialize(target, _opts = {}) ⇒ FolderHelper

Returns a new instance of FolderHelper.



16
17
18
19
20
21
22
23
24
# File 'lib/inspec/targets/folder.rb', line 16

def initialize(target, _opts = {})
  @base_folder = target
  # find all files in the folder
  files = Dir[File.join(target, '**', '*')]
  # remove the prefix
  prefix = File.join(target, '')
  @files = files.map { |x| x.sub(prefix, '') }
  @file_handler = Inspec::Targets.modules['file']
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



14
15
16
# File 'lib/inspec/targets/folder.rb', line 14

def files
  @files
end

Class Method Details

.handles?(target) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/inspec/targets/folder.rb', line 10

def self.handles?(target)
  File.directory?(target)
end

Instance Method Details

#resolve(path, opts = {}) ⇒ Object



26
27
28
29
30
# File 'lib/inspec/targets/folder.rb', line 26

def resolve(path, opts = {})
  o = (opts || {})
  o[:base_folder] = @base_folder
  @file_handler.resolve(path, o)
end

#to_sObject



32
33
34
# File 'lib/inspec/targets/folder.rb', line 32

def to_s
  'Folder Loader'
end