Sha256: 13baf221cec1e7a3c3445d520e2ef0e77aaccb1bb4028109ae6435b3bd33db25

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

class SimpleCov::Formatter::RcovFormatter
  PATH_RESULT = "/rcov/index.html"
  
  def format( result )
    @files = result.files
    
    @total_lines =  result.files.map { |e| e.lines.count }.inject(:+)
    @total_lines_code =  result.files.map { |e| e.covered_lines.count + e.missed_lines.count }.inject(:+)
    @total_coverage = result.covered_percent
    
    template = ERB.new( File.read( "#{File.dirname(__FILE__)}/../views/index.erb.html" ) )
    rcov_result = template.result( binding )
    
    FileUtils.mkdir_p( File.dirname( SimpleCov::Formatter::RcovFormatter.path_result ) )
    
    File.open( SimpleCov::Formatter::RcovFormatter.path_result, "w" ) do |file_result|
      file_result.write rcov_result
    end
    
    puts "Coverage report Rcov style generated for #{result.command_name} to #{SimpleCov::Formatter::RcovFormatter.path_result}"
    
    return rcov_result
  end
  
  private
    
    def self.path_result
      File.join( SimpleCov.coverage_path, SimpleCov::Formatter::RcovFormatter::PATH_RESULT )
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simplecov-rcov-0.1.1 lib/simplecov-rcov.rb
simplecov-rcov-0.1.0 lib/simplecov-rcov.rb