Skip to content

Instantly share code, notes, and snippets.

@kenchan kenchan/stats.rb
Created Mar 26, 2009

Embed
What would you like to do?
#!/bin/ruby
require 'rubygems'
require 'activesupport'
require 'calendar/japanese/holiday'
class Date
include Calendar::Japanese::Holiday
end
t = 4.weeks.ago.to_date
File.delete("stats.txt") if File.exists?("stats.txt")
t.upto(1.day.ago.to_date) do |d|
next if d.holiday?
puts "#{d.to_s} svn up"
system "svn log -r{#{d.to_s}} | awk '/^r/ { print $1; }' | xargs svn up -q -r"
puts "exec rake stats"
system "echo #{d.to_s} >> stats.txt"
system "rake stats >> stats.txt"
end
csv = File.open("stats.csv", "w")
$\ = nil
File.open("stats.txt") do |txt|
while l = txt.gets
case l
when /^\d/
csv.print("#{l},")
when /^-/
when /Code/
lines = l.split
csv.print("#{lines[2]},#{lines[5]}\n")
end
end
end
csv.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.