Class: Inspec::Targets::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



93
94
95
96
97
# File 'lib/inspec/targets/dir.rb', line 93

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

#get_libraries(paths) ⇒ Object



87
88
89
90
91
# File 'lib/inspec/targets/dir.rb', line 87

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

#get_metadata(paths) ⇒ Object



99
100
101
102
# File 'lib/inspec/targets/dir.rb', line 99

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

#handles?(paths) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
82
83
84
85
# File 'lib/inspec/targets/dir.rb', line 79

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