Sha256: e33065cbf2433d71e6aec643d15d12a1c92a1384eb2f030c672a816995ae14d5
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Slather module CoverageService module GutterJsonOutput def coverage_file_class Slather::CoverageFile end private :coverage_file_class def post output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } } symbols = {} coverage_files.each do |coverage_file| next unless coverage_file.gcov_data filename = coverage_file.source_file_pathname.to_s filename = filename.sub(Pathname.pwd.to_s, '')[1..-1] coverage_file.gcov_data.split("\n").each do |line| data = line.split(':') line_number = data[1].to_i next unless line_number > 0 coverage = data[0].strip symbol = { 'line' => line_number, 'long_text' => '', 'short_text' => coverage } if coverage != '-' symbol['background_color'] = coverage.to_i > 0 ? '0x35CC4B' : '0xFC635E' end if symbols.has_key?(filename) symbols[filename] << symbol else symbols[filename] = [ symbol ] end end end output['symbols_by_file'] = symbols File.open('.gutter.json', 'w') { |file| file.write(output.to_json) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slather-1.4.0 | lib/slather/coverage_service/gutter_json_output.rb |
slather-1.3.0 | lib/slather/coverage_service/gutter_json_output.rb |