class Svnlog2csv::Row
Row
corrisponde a una riga che andrà scritta sul file csv. Ogni row è caratterizzata da una data (day) e una serie di azioni (actions). actions è un hash di hash, la cui struttura è
@actions[autore][tipo_azione]
tipo_azione è uno fra A (add), M (modify), D (delete), tot (totale). tot è semplicemente la somma di A, M e D.
Attributes
actions[R]
day[R]
Public Class Methods
legend(authors)
click to toggle source
Metodo statico che produce un array pronto per essere scritto sul csv. Contiene la legenda del csv.
# File lib/svnlog2csv/row.rb, line 47 def self.legend authors arr = authors.map do |author| author = author.to_sym ["#{author} A", "#{author} M", "#{author} D", "#{author} TOT"] end ["Data"] + arr.flatten end
new(day, authors)
click to toggle source
# File lib/svnlog2csv/row.rb, line 13 def initialize day, authors @day = day @authors = authors.map { |author| author.to_sym } @actions = Hash.new @authors.each { |author| @actions[author] = Hash.new(0) } end
Public Instance Methods
add(log_entry)
click to toggle source
Aggiunge i dati di un commit alla riga. Se autore “pippo” ha fatto un commit con 2 add e 1 modify, viene eseguito l'equivalente di queste operazioni:
@actions[:pippo][:A] += 2 @actions[:pippo][:M] += 1 @actions[:pippo][:tot] += 3
# File lib/svnlog2csv/row.rb, line 26 def add log_entry log_entry.actions.each_pair do |action, value| author = log_entry.author.to_sym @actions[author][action] += value @actions[author][:tot] += value end end
to_csv()
click to toggle source
Produce un array pronto per essere scritto sul csv. Viene scritta la data nella prima colonna, e per ogni autore quattro colonne (add, modify, delete, totale)
# File lib/svnlog2csv/row.rb, line 37 def to_csv arr = @authors.map do |author| author = author.to_sym [@actions[author][:A], @actions[author][:M], @actions[author][:D], @actions[author][:tot]] end [@day] + arr.flatten end