16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/simplecov-rcov.rb', line 16
def format( result )
Dir[File.join(File.dirname(__FILE__), '../assets/*')].each do |path|
FileUtils.cp_r(path, asset_output_path)
end
@path_relativizer = Hash.new{|h,base|
h[base] = Pathname.new(base).cleanpath.to_s.gsub(%r{^\w:[/\\]}, "").gsub(/\./, "_").gsub(/[\\\/]/, "-") + ".html"
}
generated_on = Time.now
@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 = coverage(result.files)
@total_coverage_code = coverage_code(result.files)
FileUtils.mkdir_p( SimpleCov::Formatter::RcovFormatter.output_path )
write_file(template("index.html"), File.join(SimpleCov::Formatter::RcovFormatter.output_path, "/index.html") , binding)
template = template("detail.html")
result.files.each do |file|
write_file(template, File.join(SimpleCov::Formatter::RcovFormatter.output_path, relative_filename(shortened_filename(file))), binding)
end
puts "Coverage report Rcov style generated for #{result.command_name} to #{SimpleCov::Formatter::RcovFormatter.output_path}"
end
|