Sha256: 019bf7d6a4b03eac443015d19bc19c1d0742d4c3f1af7b81be8b24c5a891030a

Contents?: true

Size: 1.8 KB

Versions: 12

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

module ONCCertificationG10TestKit
  module Tasks
    class TestProcedure
      # procedure -> section -> steps
      attr_accessor :sections

      def initialize(data)
        @sections = data[:procedure].map { |section| Section.new(section) }
      end

      class Section
        attr_accessor :name, :steps

        def initialize(data)
          @name = data[:section]

          group = nil
          @steps = data[:steps].map do |step|
            if step[:group].nil?
              step[:group] = group
            else
              group = step[:group]
            end

            Step.new(step)
          end
        end
      end

      class Step
        attr_accessor :group, :id, :s_u_t, :t_l_v, :inferno_supported, :inferno_notes, :inferno_tests, :alternate_test

        def initialize(data)
          @group = data[:group]
          @id = data[:id]
          @s_u_t = data[:SUT]
          @t_l_v = data[:TLV]
          @inferno_supported = data[:inferno_supported]
          @inferno_notes = data[:inferno_notes]
          @alternate_test = data[:alternate_test]
          @inferno_tests = expand_tests(data[:inferno_tests]).flatten
        end

        def expand_tests(test_list)
          return [] if test_list.nil?

          test_list.map do |test|
            if test.include?(' - ')
              first, second = test.split(' - ')
              prefix, _, beginning = first.rpartition('.')
              second_prefix, _, ending = second.rpartition('.')
              raise "'#{prefix}' != '#{second_prefix}' in #{@group} #{@id}" unless prefix == second_prefix

              (beginning.to_i..ending.to_i).map { |index| "#{prefix}.#{format('%02<index>d', { index: index })}" }
            else
              [test]
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
onc_certification_g10_test_kit-3.2.0 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-3.1.0 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-3.0.1 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-3.0.0 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.3.0 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.2.2 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.2.1 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.2.0 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.2.0.rc1 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.1.1 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.1.0 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb
onc_certification_g10_test_kit-2.1.0.rc1 lib/onc_certification_g10_test_kit/tasks/test_procedure.rb