Module: Saikuro::ResultIndexGenerator
- Included in:
- CLI
- Defined in:
- lib/saikuro/result_index_generator.rb
Instance Method Summary collapse
- #list_analyzed_files(files) ⇒ Object
- #print_summary_table_rows(ewvals, klass_type) ⇒ Object
- #summarize_errors_and_warnings(enw, header) ⇒ Object
- #write_cyclo_index(files, output_dir) ⇒ Object
- #write_index(files, filename, title, header) ⇒ Object
- #write_token_index(files, output_dir) ⇒ Object
Instance Method Details
#list_analyzed_files(files) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/saikuro/result_index_generator.rb', line 40 def list_analyzed_files(files) f = StringIO.new f.puts "<h2 class=\"class_name\">Analyzed Files</h2>" f.puts "<ul>" files.each do |fname, warnings, errors| readname = fname.split("_")[0...-1].join("_") f.puts "<li>" f.puts "<p class=\"file_name\"><a href=\"./#{fname}\">#{readname}</a>" f.puts "</li>" end f.puts "</ul>" f.string end |
#print_summary_table_rows(ewvals, klass_type) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/saikuro/result_index_generator.rb', line 29 def print_summary_table_rows(ewvals, klass_type) f = StringIO.new ewvals.sort { |a,b| b <=> a}.each do |v, vals| vals.sort.each do |fname, c, m| f.puts "<tr><td><a href=\"./#{fname}\">#{c}</a></td><td>#{m}</td>" f.puts "<td class=\"#{klass_type}\">#{v}</td></tr>" end end f.string end |
#summarize_errors_and_warnings(enw, header) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/saikuro/result_index_generator.rb', line 3 def summarize_errors_and_warnings(enw, header) return "" if enw.empty? f = StringIO.new erval = Hash.new { |h,k| h[k] = Array.new } wval = Hash.new { |h,k| h[k] = Array.new } enw.each do |fname, warnings, errors| errors.each do |c,m,v| erval[v] << [fname, c, m] end warnings.each do |c,m,v| wval[v] << [fname, c, m] end end f.puts "<h2 class=\"class_name\">Errors and Warnings</h2>" f.puts "<table width=\"100%\" border=\"1\">" f.puts header f.puts print_summary_table_rows(erval, "error") f.puts print_summary_table_rows(wval, "warning") f.puts "</table>" f.string end |
#write_cyclo_index(files, output_dir) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/saikuro/result_index_generator.rb', line 72 def write_cyclo_index(files, output_dir) header = "<tr><th>Class</th><th>Method</th><th>Complexity</th></tr>" write_index(files, "#{output_dir}/index_cyclo.html", "Index for cyclomatic complexity", header) end |
#write_index(files, filename, title, header) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/saikuro/result_index_generator.rb', line 54 def write_index(files, filename, title, header) return if files.empty? File.open(filename,"w") do |f| f.puts "<html><head><title>#{title}</title></head>" f.puts "#{HTMLStyleSheet.style_sheet}\n<body>" f.puts "<h1>#{title}</h1>" enw = files.find_all { |fn,w,e| (!w.empty? || !e.empty?) } f.puts summarize_errors_and_warnings(enw, header) f.puts "<hr/>" f.puts list_analyzed_files(files) f.puts "</body></html>" end end |
#write_token_index(files, output_dir) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/saikuro/result_index_generator.rb', line 80 def write_token_index(files, output_dir) header = "<tr><th>File</th><th>Line #</th><th>Tokens</th></tr>" write_index(files, "#{output_dir}/index_token.html", "Index for tokens per line", header) end |