Sha256: 3e14ecb6c9bffe2fe4a0973dc9a795364019ceacaf05a4a00243d87e5851dbef

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'fitting/report/prefix'

module Fitting
  module Report
    class Prefixes
      def initialize(config_path)
        @prefixes = []
        YAML.safe_load(File.read(config_path))['prefixes'].map do |prefix|
          @prefixes.push(Fitting::Report::Prefix.new(prefix['name'], prefix['tomogram_json_path'], prefix['skip']))
        end
      end

      def is_there_a_suitable_prefix?(test_path)
        @prefixes.map do |prefix|
          return true if test_path[0..prefix.name.size - 1] == prefix.name
        end

        false
      end

      def cram_into_the_appropriate_prefix(test)
        @prefixes.map do |prefix|
          if test.path[0..prefix.name.size - 1] == prefix.name
            prefix.add_test(test)
            return
          end
        end
      end

      def join(tests)
        tests.to_a.map do |test|
          if is_there_a_suitable_prefix?(test.path)
            cram_into_the_appropriate_prefix(test)
            test.mark_prefix
          end
        end
      end

      def to_a
        @prefixes
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fitting-2.15.0 lib/fitting/report/prefixes.rb
fitting-2.14.1 lib/fitting/report/prefixes.rb
fitting-2.14.0 lib/fitting/report/prefixes.rb