class Rcov::HTMLCoverage
:nodoc:
def create_file(destfile, fileinfo)
def create_file(destfile, fileinfo) doc = Rcov::Formatters::HtmlErbTemplate.new('detail.html.erb', :project_name => project_name, :rcov_page_title => fileinfo.name, :css => @css, :generated_on => Time.now, :rcov => Rcov, :formatter => self, :output_threshold => @output_threshold, :fileinfo => fileinfo ) File.open(destfile, "w") { |f| f.puts doc.render } end
def create_index(destname)
def create_index(destname) doc = Rcov::Formatters::HtmlErbTemplate.new('index.html.erb', :project_name => project_name, :generated_on => Time.now, :css => @css, :rcov => Rcov, :formatter => self, :output_threshold => @output_threshold, :total => SummaryFileInfo.new(self), :files => each_file_pair_sorted.map{|k,v| v} ) File.open(destname, "w") { |f| f.puts doc.render } end
def execute
def execute return if @files.empty? FileUtils.mkdir_p @dest # Copy collaterals ['screen.css','print.css','rcov.js','jquery-1.3.2.min.js','jquery.tablesorter.min.js'].each do |_file| _src = File.expand_path("#{File.dirname(__FILE__)}/../templates/#{_file}") FileUtils.cp(_src, File.join(@dest, "#{_file}")) end # Copy custom CSS, if any if @css begin _src = File.expand_path("#{@dest}/../#{@css}") FileUtils.cp(_src, File.join(@dest, "custom.css")) rescue @css = nil end end create_index(File.join(@dest, "index.html")) each_file_pair_sorted do |filename, fileinfo| create_file(File.join(@dest, mangle_filename(filename)), fileinfo) end end
def initialize(opts = {})
def initialize(opts = {}) options = DEFAULT_OPTS.clone.update(opts) super(options) @dest = options[:destdir] @css = options[:css] @color = options[:color] @fsr = options[:fsr] @do_callsites = options[:callsites] @do_cross_references = options[:cross_references] @span_class_index = 0 @charset = options[:charset] end
def project_name
def project_name Dir.pwd.split('/')[-1].split(/[^a-zA-Z0-9]/).map{|i| i.gsub(/[^a-zA-Z0-9]/,'').capitalize} * " " || "" end