class SimpleCovJSONFormatter::SourceFileFormatter
Public Class Methods
new(source_file)
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 5 def initialize(source_file) @source_file = source_file @line_coverage = nil end
Public Instance Methods
format()
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 10 def format if SimpleCov.branch_coverage? line_coverage.merge(branch_coverage) else line_coverage end end
Private Instance Methods
branch_coverage()
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 26 def branch_coverage { branches: branches } end
branches()
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 41 def branches branches = [] @source_file.branches.each do |branch| branches << parse_branch(branch) end branches end
line_coverage()
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 20 def line_coverage @line_coverage ||= { lines: lines } end
lines()
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 32 def lines lines = [] @source_file.lines.each do |line| lines << parse_line(line) end lines end
parse_branch(branch)
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 56 def parse_branch(branch) { type: branch.type, start_line: branch.start_line, end_line: branch.end_line, coverage: parse_line(branch) } end
parse_line(line)
click to toggle source
# File lib/simplecov_json_formatter/source_file_formatter.rb, line 50 def parse_line(line) return line.coverage unless line.skipped? 'ignored' end