Class: OneshotCoverage::SimplecovReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/oneshot_coverage/simplecov_reporter.rb

Defined Under Namespace

Modules: DefaultFilter

Instance Method Summary collapse

Constructor Details

#initialize(log_path:, project_path: Dir.pwd, file_filter: DefaultFilter) ⇒ SimplecovReporter

Returns a new instance of SimplecovReporter.

Parameters:

  • log_path (Hash)

    a customizable set of options

  • project_path (Hash) (defaults to: Dir.pwd)

    a customizable set of options

  • file_filter (Hash) (defaults to: DefaultFilter)

    a customizable set of options

Options Hash (log_path:):

  • oneshot (String)

    coverage log generated by FileLogger or same scheme json file acceptable

Options Hash (project_path:):

  • target (String)

    project path.

Options Hash (file_filter:):

  • Object (Object)

    respond to #call with return true | false. this filter used for coverage target. file_filter.call(path) return false, then path will not be included to report



22
23
24
25
26
27
28
29
30
# File 'lib/oneshot_coverage/simplecov_reporter.rb', line 22

def initialize(
  log_path:,
  project_path: Dir.pwd,
  file_filter: DefaultFilter
)
  @project_path = project_path.end_with?('/') ? project_path : "#{project_path}/"
  @log_path = log_path
  @file_filter = file_filter
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
# File 'lib/oneshot_coverage/simplecov_reporter.rb', line 32

def run
  raise "Please install & require 'simplecov' if you want to use this" unless defined? SimpleCov

  coverages = coverage_stubs
  fill_lines(coverages)
  gen_html(coverages)
end