Last active
February 25, 2016 14:13
-
-
Save larribas/0b28392cd60d6588ba93 to your computer and use it in GitHub Desktop.
Generate rake stats in a CSV format, fit for easy manipulation: `rake stats | bin/export_rake_stats_to_csv.rb >> tmp/rake_stats.csv`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Read stats from input and get an array of arrays (a valid csv representation) | |
stats = STDIN.read.split("\n")[1..-2].reject { |line| line.start_with? '+' }.map { |line| line.split('|')[1..-1] } | |
# Write csv to output | |
require 'csv' | |
csv_string = CSV.generate do |csv| | |
stats.each { |row| csv << row } | |
end | |
puts csv_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment