class SimpleCovLinterFormatter::TextLinesFormatter

Public Class Methods

new(command_name, lines) click to toggle source
# File lib/simplecov_linter_formatter/formatters/text_lines_formatter.rb, line 3
def initialize(command_name, lines)
  @command_name = command_name
  @lines = lines
end

Public Instance Methods

format() click to toggle source
# File lib/simplecov_linter_formatter/formatters/text_lines_formatter.rb, line 8
def format
  {
    @command_name.to_sym => {
      coverage: group_lines_by_file
    }
  }
end

Private Instance Methods

group_lines_by_file() click to toggle source
# File lib/simplecov_linter_formatter/formatters/text_lines_formatter.rb, line 18
def group_lines_by_file
  result = {}

  @lines.each do |line|
    file = SimpleCovLinterFormatter::FileLine.new(line)
    result[file.file_name] ||= { lines: [nil] * file.lines_count }
    result[file.file_name][:lines][file.line_number_idx] = file.status == :missed ? 0 : nil
  end

  result
end