Module: GitAnalyzer::Formatter::CSV

Defined in:
lib/git_analyzer/formatter/csv.rb

Constant Summary collapse

FILE_NAME =
'contributors.csv'

Class Method Summary collapse

Class Method Details

.write(data) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/git_analyzer/formatter/csv.rb', line 9

def write(data)
  ::CSV.open(FILE_NAME, 'wb') do |csv|
    if data.empty?
      csv << ['No commits found']
    else
      csv << data.first.keys # adds the attributes name on the first line
      data.each do |hash|
        csv << hash.values
      end
    end
  end
end