Module: ResultIndexGenerator
- Included in:
- SaikuroCMDLineRunner
- Defined in:
- lib/saikuro.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
922 923 924 925 926 927 928 929 930 931 932 933 934 |
# File 'lib/saikuro.rb', line 922 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
911 912 913 914 915 916 917 918 919 920 |
# File 'lib/saikuro.rb', line 911 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
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
# File 'lib/saikuro.rb', line 885 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
954 955 956 957 958 959 960 |
# File 'lib/saikuro.rb', line 954 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
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
# File 'lib/saikuro.rb', line 936 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
962 963 964 965 966 967 968 |
# File 'lib/saikuro.rb', line 962 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 |