Module: AbideDevUtils::Sce::Generate::CoverageReport

Defined in:
lib/abide_dev_utils/sce/generate/coverage_report.rb

Overview

Methods and objects used to construct a report of what SCE enforces versus what the various compliance frameworks expect to be enforced.

Defined Under Namespace

Classes: BenchmarkReport, Filter, ReportOptions, ReportOutput

Class Method Summary collapse

Class Method Details

.generate(format_func: :to_h, opts: {}) ⇒ Object

Generate a coverage report for a Puppet module

Parameters:

  • format_func (Symbol) (defaults to: :to_h)

    the format function to use

  • opts (Hash) (defaults to: {})

    options for generating the report

Options Hash (opts:):

  • :benchmark (String)

    the benchmark to generate the report for

  • :profile (String)

    the profile to generate the report for

  • :level (String)

    the level to generate the report for

  • :format_func (Symbol)

    the format function to use

  • :ignore_benchmark_errors (Boolean)

    ignore all errors when loading benchmarks



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/abide_dev_utils/sce/generate/coverage_report.rb', line 25

def self.generate(format_func: :to_h, opts: {})
  opts = ReportOptions.new(opts)
  benchmarks = AbideDevUtils::Sce::BenchmarkLoader.benchmarks_from_puppet_module(
    ignore_all_errors: opts.ignore_benchmark_errors
  )
  benchmarks.filter_map do |b|
    next if opts.benchmark && !Regexp.new(Regexp.escape(opts.benchmark)).match?(b.title_key)
    next if opts.profile && b.mapper.profiles.none?(opts.profile)
    next if opts.level && b.mapper.levels.none?(opts.level)

    BenchmarkReport.new(b, opts).run.send(format_func)
  end
end