# ========================================================= # Classe de formatage des resultats renvoyes par rake stats # Author: Vincent Dubois # ========================================================= class StatsFormatter attr_accessor :result # Constructeur def initialize result self.result = result end # Methode qui permet de fabriquer le flux HTML a partir des flux console def to_html html = "
Name | Lines | LOC | Classes | Methods | M/C | LOC/M | " i = 0 results = self.result.split(/$/) bottom = 4 while !results[bottom].nil? and results[bottom][0..1] != "\n+" do bottom = bottom + 1 end lines = results[4..bottom-1] lines.each do |line| elements = line.split(/\|/) html = html + "
---|---|---|---|---|---|---|
#{elements[1]} | " html = html + "#{elements[2]} | " html = html + "#{elements[3]} | " html = html + "#{elements[4]} | " html = html + "#{elements[5]} | " html = html + "#{elements[6]} | " html = html + "#{elements[7]} | " html = html + "
#{elements[1]} | " [2,3,4,5,6,7].each do |j| html = html + "#{elements[j]} | " end html = html + "
#{elements[0]} : #{elements[1]} " html = html + "#{elements[2]} : #{elements[3]} " html = html + "#{elements[4]} : #{elements[5]}:#{elements[6]}