Class: SourceReaders::InspecReader

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, metadata_source) ⇒ InspecReader

Returns a new instance of InspecReader.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/source_readers/inspec.rb', line 28

def initialize(target, )
  @target = target
  @metadata = Inspec::Metadata.from_ref(
    ,
    @target.read(),
    nil)

  @tests = load_tests
  @libraries = load_libs
  prepare_load_paths
end

Instance Attribute Details

#librariesObject (readonly)

Returns the value of attribute libraries.



26
27
28
# File 'lib/source_readers/inspec.rb', line 26

def libraries
  @libraries
end

#metadataObject (readonly)

Returns the value of attribute metadata.



26
27
28
# File 'lib/source_readers/inspec.rb', line 26

def 
  @metadata
end

#testsObject (readonly)

Returns the value of attribute tests.



26
27
28
# File 'lib/source_readers/inspec.rb', line 26

def tests
  @tests
end

Class Method Details

.resolve(target) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/source_readers/inspec.rb', line 13

def self.resolve(target)
  return new(target, 'inspec.yml') if target.files.include?('inspec.yml')
  # TODO: deprecated for 1.0.0 release
  if target.files.include?('metadata.rb') &&
     (
       target.files.include?('controls') ||
       target.files.include?('test')
     )
    return new(target, 'metadata.rb')
  end
  nil
end