Sha256: de95e622577de6ec6bfc360aa0a21d3e7a72f23f16170a508a0c8f16ae8658ab

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

module GitlabQuality
  module TestTooling
    module Report
      class IssueLogger
        def initialize(file_path:)
          @file_path = file_path
          @data = File.exist?(file_path) ? JSON.parse(File.read(file_path)) : Hash.new { |h, k| h[k] = [] }
        end

        def collect(test, issues)
          data[test.ci_job_url] += Array(issues).map(&:web_url)
          data[test.ci_job_url].uniq!
        end

        def write
          dirname = File.dirname(file_path)

          FileUtils.mkdir_p(dirname) unless File.directory?(dirname)

          File.write(file_path, JSON.pretty_generate(data))
        end

        private

        attr_reader :file_path, :data
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-1.5.1 lib/gitlab_quality/test_tooling/report/issue_logger.rb
gitlab_quality-test_tooling-1.5.0 lib/gitlab_quality/test_tooling/report/issue_logger.rb