Sha256: f4ff32d86c114fe38b84a8cad038555f439d38f1a6e030e26f7dc32cef6c82f7

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module SimpleCovLinterFormatter
  class TextLinesFormatter
    def initialize(command_name, lines)
      @command_name = command_name
      @lines = lines
    end

    def format
      {
        @command_name.to_sym => {
          coverage: group_lines_by_file
        }
      }
    end

    private

    def group_lines_by_file
      result = {}

      @lines.each do |line|
        file_name, line_number, _column, status_lines_count = line.split(":")
        status, lines_count = status_lines_count.split("-")
        result[file_name] ||= { lines: [nil] * lines_count.to_i }
        result[file_name][:lines][line_number.to_i - 1] = status.to_sym == :missed ? 0 : nil
      end

      result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simplecov_linter_formatter-0.1.0 lib/simplecov_linter_formatter/formatters/text_lines_formatter.rb