Sha256: 4a2bfb46014af5f4ff71106bbcd8e6c6a0c96694ef3b584bbe575e5ec70d9e60

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

# DeployRubygem - deploy a gem using rake
# Containing a class
module DeployRubygem
  # Using Inspec to deploy and manage Inspec
  class InspecTestorResult
    attr_reader :success_control, :success_result, :failed_control, :failed_result, :pending_control, :pending_result

    def initialize(as_json)
      @as_json = as_json
      @success_control = 0
      @success_result = 0
      @failed_control = 0
      @failed_result = 0
      @pending_control = 0
      @pending_result = 0
      results
    end

    def profile
      @as_json['profiles'].first
    end

    def status
      profile['status']
    end

    def controls
      profile['controls']
    end

    def result_summary
      {
        success_control: success_control,
        success_result: success_result,
        failed_control: failed_control,
        failed_result: failed_result,
        pending_control: pending_control,
        pending_result: pending_result
      }
    end

    private

    def results
      controls.each do |control_result|
        control_as_fail = false
        control_result['results'].each do |item_result|
          case item_result['status']
          when 'passed'
            @success_result += 1
          when 'failed'
            @failed_result += 1
            @failed_control += 1
            control_as_fail = true
          else
            @pending_result += 1
            @pending_control += 1
            control_as_fail = true
          end
        end
        @success_control += 1 unless control_as_fail
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
deploy_rubygem-0.60.29 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.28 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.26 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.25 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.24 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.23 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.22 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.21 lib/deploy_rubygem/inspec_result.rb
deploy_rubygem-0.60.20 lib/deploy_rubygem/inspec_result.rb