Sha256: 447d9fb2505dda2eccfbd5ec3bfae1e293252bf4bdb2adce53574d58bfe73d6e
Contents?: true
Size: 795 Bytes
Versions: 10
Compression:
Stored size: 795 Bytes
Contents
require 'coverage' at_exit do if not $! or ($!.kind_of? SystemExit and $!.success?) and coverage_by_file = Coverage.result rescue nil then report = {} coverage_by_file.each do |file, coverage| # ignore files outside working directory if file.start_with? Dir.pwd nsloc = 0 holes = [] coverage.each_with_index do |hits, index| # ignore non-source lines of code unless hits.nil? nsloc += 1 # +1 because line numbers go 1..N holes << index + 1 if hits.zero? end end grade = ((nsloc - holes.length) / nsloc.to_f) * 100 report[file] = { grade: grade, nsloc: nsloc, holes: holes } end end require 'yaml' YAML.dump report, STDOUT end end
Version data entries
10 entries across 10 versions & 1 rubygems