Skip to content

Instantly share code, notes, and snippets.

@larribas
Last active February 25, 2016 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larribas/0b28392cd60d6588ba93 to your computer and use it in GitHub Desktop.
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`
#!/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