abstract class CoverageReporter::BaseParser

Overview

Coverage report parser interface.

To add a new parser create a class in src/coverage_reporter/parsers/ folder and implement three required methods. For example, if you add a mycov parser the code should look like this:

require "./base_parser"

module CoverageReporter
  class MycovParser < BaseParser
    def globs : Array(String)
      ["**/*/*.mycov"]
    end

    def matches?(filename : String) : Bool
      filename.ends_with?(".mycov")
    end

    def parse(filename : String) : Array(FileReport)
      # ... mycov format specific parsing
    end
  end
end

Them add your parser class to PARSERS constant in Parser class.

PARSERS = {
  # ...
  MycovParser,
}

Existing parsers can be used as a reference.

Direct Known Subclasses

Defined in:

coverage_reporter/parsers/base_parser.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(base_path : String | Nil = nil, forced : Bool = false) #

Initializes the parser.

base_path can be used to join with all paths in coverage report in order to properly reference a file.


[View source]

Class Method Detail

def self.name : String #

Returns parser name which can be used to force resolve the parser.


[View source]

Instance Method Detail

def file_report(name, coverage, branches = nil, source_digest = nil) #

Creates a FileReport instance. Use this method instead of explicit creation with FileReport.new().


[View source]
abstract def globs : Array(String) #

Returns an array of globs that will be used to look for coverage reports.


[View source]
abstract def matches?(filename : String) : Bool #

Checks if the file can be parsed with the parser.


[View source]
abstract def parse(filename : String) : Array(FileReport) #

Parses the file and returns an array of FileReport which will be sent to Coveralls API.


[View source]