class SimpleCovLinterFormatter::SourceFileFormatter

Constants

FILE_COLUMN

Public Class Methods

new(source_file) click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 5
def initialize(source_file)
  @source_file = source_file
end

Public Instance Methods

format() click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 9
def format
  lines.map do |line|
    build_line_text(line)
  end
end

Private Instance Methods

build_line_msg(line) click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 26
def build_line_msg(line)
  [
    line.status,
    lines_count,
    stats.percent
  ].map(&:to_s).join(SimpleCovLinterFormatter::MSG_DIVIDER)
end
build_line_text(line) click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 17
def build_line_text(line)
  [
    @source_file.filename,
    line.line_number,
    FILE_COLUMN,
    build_line_msg(line)
  ].map(&:to_s).join(SimpleCovLinterFormatter::LINE_SECTIONS_DIVIDER)
end
lines() click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 42
def lines
  @lines ||= @source_file.lines
end
lines_count() click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 38
def lines_count
  @lines_count ||= lines.count
end
stats() click to toggle source
# File lib/simplecov_linter_formatter/formatters/source_file_formatter.rb, line 34
def stats
  @stats ||= @source_file.coverage_statistics[:line]
end