Sha256: e28fa5d6c43e704b9135557fee24bf2db4c831109e23c91f6749bfab5f1f94af

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require 'openscap_parser/rule_results'
require 'openscap_parser/selectors'

module OpenscapParser
  class TestResult < XmlNode
    include OpenscapParser::RuleResults
    include OpenscapParser::Selectors

    def target
      @target ||= parsed_xml.at_xpath('target') &&
        parsed_xml.at_xpath('target').text || ''
    end
    alias :host :target

    def target_fact_nodes
      @target_fact_nodes ||= parsed_xml.xpath('target-facts/fact')
    end

    def platform_nodes
      @platform_nodes ||= parsed_xml.xpath('platform')
    end

    def title
      @title ||= parsed_xml.at_xpath('title') &&
        parsed_xml.at_xpath('title').text || ''
    end

    def identity
      @identity ||= parsed_xml.at_xpath('identity') &&
        parsed_xml.at_xpath('identity').text || ''
    end

    def profile_id
      @profile_id ||= parsed_xml.at_xpath('profile') &&
        parsed_xml.at_xpath('profile')['idref'] || ''
    end

    def benchmark_id
      @benchmark_id ||= parsed_xml.at_xpath('benchmark') &&
        parsed_xml.at_xpath('benchmark')['id'] || ''
    end

    def set_value_nodes
      @set_value_nodes ||= parsed_xml.xpath('set-value')
    end

    def score
      @score ||= parsed_xml.at_xpath('score') &&
        parsed_xml.at_xpath('score').text.to_f
    end

    def start_time
      @start_time ||= DateTime.parse(parsed_xml['start-time'])
    end

    def end_time
      @end_time ||= DateTime.parse(parsed_xml['end-time'])
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
openscap_parser-1.7.0 lib/openscap_parser/test_result.rb
openscap_parser-1.6.0 lib/openscap_parser/test_result.rb
openscap_parser-1.5.1 lib/openscap_parser/test_result.rb
openscap_parser-1.5.0 lib/openscap_parser/test_result.rb
openscap_parser-1.4.0 lib/openscap_parser/test_result.rb
openscap_parser-1.3.1 lib/openscap_parser/test_result.rb
openscap_parser-1.3.0 lib/openscap_parser/test_result.rb
openscap_parser-1.2.0 lib/openscap_parser/test_result.rb
openscap_parser-1.1.0 lib/openscap_parser/test_result.rb
openscap_parser-1.0.2 lib/openscap_parser/test_result.rb
openscap_parser-1.0.1 lib/openscap_parser/test_result.rb