Class: Inspec::Targets::DirsHelper::ProfileDir

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/targets/dir.rb

Overview

InSpec profile Loader Previous versions used the ‘test` directory instead of the new `controls` directory. Usage of the test directory is deprecated and not recommended anymore. Support for `test` will be removed in InSpec 1.0 TODO: remove `test` support for InSpec 1.0

Instance Method Summary collapse

Instance Method Details

#get_filenames(paths) ⇒ Object



27
28
29
30
31
# File 'lib/inspec/targets/dir.rb', line 27

def get_filenames(paths)
  paths.find_all do |path|
    path.start_with?('controls', 'test') && path.end_with?('.rb')
  end
end

#get_libraries(paths) ⇒ Object



21
22
23
24
25
# File 'lib/inspec/targets/dir.rb', line 21

def get_libraries(paths)
  paths.find_all do |path|
    path.start_with?('libraries') && path.end_with?('.rb')
  end
end

#get_metadata(paths) ⇒ Object



33
34
35
36
# File 'lib/inspec/targets/dir.rb', line 33

def (paths)
  return 'inspec.yml' if paths.include?('inspec.yml')
  return 'metadata.rb' if paths.include?('metadata.rb')
end

#handles?(paths) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/inspec/targets/dir.rb', line 13

def handles?(paths)
  return true if paths.include?('inspec.yml')
  (
    !paths.grep(/^controls/).empty? ||
    !paths.grep(/^test/).empty?
  ) && paths.include?('metadata.rb')
end