Sha256: a2bf15994cd4ca795a6d0e0b7de13f6542c22a7432b2a14514399829b48cf296
Contents?: true
Size: 1 KB
Versions: 6
Compression:
Stored size: 1 KB
Contents
require 'tork/config' begin require 'coverage' Tork::Config.after_fork_hooks << proc do Coverage.start end 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 rescue LoadError => error warn "tork/config/coverage: #{error.inspect}" end
Version data entries
6 entries across 6 versions & 1 rubygems