Class: OpenSCAP::Xccdf::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/openscap/xccdf/testresult.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(t) ⇒ TestResult

Returns a new instance of TestResult.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/openscap/xccdf/testresult.rb', line 23

def initialize(t)
  case t
  when OpenSCAP::Source
    @raw = OpenSCAP.xccdf_result_import_source(t.raw)
    OpenSCAP.raise! if @raw.null?
  when FFI::Pointer
    @raw = OpenSCAP.xccdf_result_import_source(t)
    OpenSCAP.raise! if @raw.null?
  else
    fail OpenSCAP::OpenSCAPError, "Cannot initialize TestResult with #{t}"
  end
  init_ruleresults
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



21
22
23
# File 'lib/openscap/xccdf/testresult.rb', line 21

def raw
  @raw
end

#rrObject (readonly)

Returns the value of attribute rr.



20
21
22
# File 'lib/openscap/xccdf/testresult.rb', line 20

def rr
  @rr
end

Instance Method Details

#destroyObject



61
62
63
64
# File 'lib/openscap/xccdf/testresult.rb', line 61

def destroy
  OpenSCAP.xccdf_result_free @raw
  @raw = nil
end

#idObject



37
38
39
# File 'lib/openscap/xccdf/testresult.rb', line 37

def id
  OpenSCAP.xccdf_result_get_id(@raw)
end

#profileObject



41
42
43
# File 'lib/openscap/xccdf/testresult.rb', line 41

def profile
  OpenSCAP.xccdf_result_get_profile(@raw)
end

#scoreObject



45
46
47
# File 'lib/openscap/xccdf/testresult.rb', line 45

def score
  @score ||= score_init
end

#score!(benchmark) ⇒ Object



49
50
51
52
53
54
# File 'lib/openscap/xccdf/testresult.rb', line 49

def score!(benchmark)
  # recalculate the scores in the scope of given benchmark
  @score = nil
  OpenSCAP.raise! unless OpenSCAP.xccdf_result_recalculate_scores(@raw, benchmark.raw) == 0
  score
end

#sourceObject



56
57
58
59
# File 'lib/openscap/xccdf/testresult.rb', line 56

def source
  source_p = OpenSCAP.xccdf_result_export_source(raw, nil)
  OpenSCAP::Source.new source_p
end