Class: RSpecTracer::CoverageWriter
- Inherits:
-
Object
- Object
- RSpecTracer::CoverageWriter
- Defined in:
- lib/rspec_tracer/coverage_writer.rb
Instance Method Summary collapse
-
#initialize(file_name, reporter) ⇒ CoverageWriter
constructor
A new instance of CoverageWriter.
- #print_stats(elapsed_time) ⇒ Object
- #write_report ⇒ Object
Constructor Details
#initialize(file_name, reporter) ⇒ CoverageWriter
Returns a new instance of CoverageWriter.
5 6 7 8 |
# File 'lib/rspec_tracer/coverage_writer.rb', line 5 def initialize(file_name, reporter) @file_name = file_name @reporter = reporter end |
Instance Method Details
#print_stats(elapsed_time) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rspec_tracer/coverage_writer.rb', line 21 def print_stats(elapsed_time) starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) total, covered, percent = coverage_stats ending = Process.clock_gettime(Process::CLOCK_MONOTONIC) elapsed = RSpecTracer::TimeFormatter.format_time((ending - starting) + elapsed_time) puts <<-STATS.strip.gsub(/\s+/, ' ') Coverage report generated for RSpecTracer to #{@file_name}. #{covered} / #{total} LOC (#{percent}%) covered (took #{elapsed}) STATS end |
#write_report ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec_tracer/coverage_writer.rb', line 10 def write_report report = { RSpecTracer: { coverage: @reporter.coverage, timestamp: Time.now.utc.to_i } } File.write(@file_name, JSON.pretty_generate(report)) end |