Sha256: 9208f4d30ebe7005d89bafa47dca6c46c2c8dc369e934cfe9b8664d70e46b607
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module SimpleCovJSONFormatter class SourceFileFormatter def initialize(source_file) @source_file = source_file @line_coverage = nil end def format if SimpleCov.branch_coverage? line_coverage.merge(branch_coverage) else line_coverage end end private def line_coverage @line_coverage ||= { lines: lines } end def branch_coverage { branches: branches } end def lines lines = [] @source_file.lines.each do |line| lines << parse_line(line) end lines end def branches branches = [] @source_file.branches.each do |branch| branches << parse_branch(branch) end branches end def parse_line(line) return line.coverage unless line.skipped? 'ignored' end def parse_branch(branch) { type: branch.type, start_line: branch.start_line, end_line: branch.end_line, coverage: parse_line(branch) } end end end
Version data entries
6 entries across 6 versions & 5 rubygems