# ================================================ # Classe de formatage de resultat renvoye par flog # Author: Vincent Dubois # ================================================ class FlogFormatter attr_accessor :results # Constructeur def initialize results self.results = results end # Methode qui permet de fabriquer le flux HTML a partir du flux console flog def to_html lines = self.results.split(/$/) total_score = lines[0].split(" = ")[1] html = "

Total score : #{total_score}

" # On supprime les deux premieres lignes (total et ligne vide) et la derniere (ligne vide) lines.delete_at(0) lines.delete_at(0) lines.delete_at(lines.length-1) begin lines.each_with_index do |line, index| html = html + format_line(line, index) end rescue Exception => e raise " Unable to format flog results. Exception is : #{e.to_s}" end html = html + "" end # Méthode qui permet de formater une ligne de resultat def format_line line, index html = "" if line[1..1] != ' ' if index != 0 html = html + "
" end html = html + "" total_score = line.split(': ')[1] total_score = total_score.split(/\(|\)/) html = html + "" else html = html + "" end return html end end
ElementScore
#{line.split(': ')[0]}#{total_score}
     #{line.split(': ')[1]}#{line.split(': ')[0]}