Class: Inspec::RunData

Inherits:
Struct
  • Object
show all
Includes:
HashLikeStruct
Defined in:
lib/inspec/run_data.rb,
lib/inspec/run_data.rb,
lib/inspec/run_data/result.rb,
lib/inspec/run_data/control.rb,
lib/inspec/run_data/profile.rb,
lib/inspec/run_data/statistics.rb

Defined Under Namespace

Classes: Control, Platform, Profile, Result, Statistics

Constant Summary collapse

SCHEMA_VERSION =

This is the data layout version of RunData. We plan to follow a data-oriented version of semver:

patch: fixing a bug in the provenance or description of a data element, no key changes
minor: adding new data elements
major: deleting or renaming data elements

Less than major version 1.0.0, the API is considered unstable. The current plan is to bump the major version to 1.0.0 when all of the existing core reporters have been migrated to plugins. It is probable that new data elements and new Hash compatibility behavior will be added during the core reporter plugin conversion process.

"0.3.0".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HashLikeStruct

#key?, #keys, #non_nil?

Constructor Details

#initialize(raw_run_data) ⇒ RunData

Returns a new instance of RunData.



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

def initialize(raw_run_data)
  @raw_run_data = raw_run_data

  self.controls   = @raw_run_data[:controls].map { |c| Inspec::RunData::Control.new(c) }
  self.profiles   = @raw_run_data[:profiles].map { |p| Inspec::RunData::Profile.new(p) }
  self.statistics = Inspec::RunData::Statistics.new(@raw_run_data[:statistics])
  self.platform   = Inspec::RunData::Platform.new(@raw_run_data[:platform])
  self.version    = @raw_run_data[:version]
end

Instance Attribute Details

#controlsObject

Returns the value of attribute controls

Returns:

  • (Object)

    the current value of controls



20
21
22
# File 'lib/inspec/run_data.rb', line 20

def controls
  @controls
end

#other_checksObject

Returns the value of attribute other_checks

Returns:

  • (Object)

    the current value of other_checks



20
21
22
# File 'lib/inspec/run_data.rb', line 20

def other_checks
  @other_checks
end

#platformObject

Returns the value of attribute platform

Returns:

  • (Object)

    the current value of platform



20
21
22
# File 'lib/inspec/run_data.rb', line 20

def platform
  @platform
end

#profilesObject

Returns the value of attribute profiles

Returns:

  • (Object)

    the current value of profiles



20
21
22
# File 'lib/inspec/run_data.rb', line 20

def profiles
  @profiles
end

#statisticsObject

Returns the value of attribute statistics

Returns:

  • (Object)

    the current value of statistics



20
21
22
# File 'lib/inspec/run_data.rb', line 20

def statistics
  @statistics
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



20
21
22
# File 'lib/inspec/run_data.rb', line 20

def version
  @version
end

Class Method Details

.compatible_schema?(constraints) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/inspec/run_data.rb', line 54

def self.compatible_schema?(constraints)
  reqs = Gem::Requirement.create(constraints)
  reqs.satisfied_by?(Gem::Version.new(SCHEMA_VERSION))
end