Created
May 10, 2012 15:50
-
-
Save irfn/2654056 to your computer and use it in GitHub Desktop.
paring
This file contains hidden or 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
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Raphaël · Punch Chart</title> | |
<script src="http://raphaeljs.com/raphael.js" type="text/javascript" charset="utf-8"></script> | |
<script src="http://raphaeljs.com/jquery.js" type="text/javascript" charset="utf-8"></script> | |
<script src="http://raphaeljs.com/github/dots.js" type="text/javascript" charset="utf-8"></script> | |
<link rel="stylesheet" href="http://raphaeljs.com/demo.css" type="text/css" media="screen"> | |
<link rel="stylesheet" href="http://raphaeljs.com/demo-print.css" type="text/css" media="print"> | |
<style type="text/css" media="screen"> | |
body { | |
margin: 0; | |
} | |
#chart { | |
color: #333; | |
left: 50%; | |
margin: -150px 0 0 -400px; | |
position: absolute; | |
top: 50%; | |
width: 300px; | |
width: 800px; | |
} | |
</style> | |
</head> | |
<body> | |
<table id="for-chart"> | |
<div id="chart"></div> |
This file contains hidden or 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
require 'haml' | |
task :pair do | |
logs = %x[git log --since '1 month' --pretty=format:"%an|%ad" --date=short].split("\n") | |
metrics = logs.reduce({}) do |dates_by_pair, log| | |
pair, date = log.split("|") | |
uniq_pair = pair.downcase.split("/").sort | |
dates_by_pair[uniq_pair] ||= [] | |
dates_by_pair[uniq_pair] << date unless dates_by_pair[uniq_pair].include?(date) | |
dates_by_pair | |
end | |
devs = metrics.keys.flatten.uniq.sort | |
report_template = %Q{ | |
%html | |
%head | |
%script{ :src => "http://raphaeljs.com/raphael.js", :type => "text/javascript", :charset => "utf-8" } | |
%script{ :src => "http://raphaeljs.com/jquery.js", :type => "text/javascript", :charset => "utf-8" } | |
%script{ :src => "http://raphaeljs.com/github/dots.js", :type => "text/javascript", :charset => "utf-8" } | |
%link{ :rel => "stylesheet", :href => "http://raphaeljs.com/demo.css", :type => "text/css", :media => "screen" } | |
%link{ :rel => "stylesheet", :href => "http://raphaeljs.com/demo-print.css", :type => "text/css", :media => "print" } | |
:css | |
body { | |
margin: 0; | |
} | |
#chart { | |
color: #333; | |
left: 50%; | |
margin: -150px 0 0 -400px; | |
position: absolute; | |
top: 50%; | |
width: 800px; | |
height: 300px; | |
} | |
%body | |
%table{ :id => "for-chart"} | |
%tfoot | |
%tr | |
- devs.each do |p| | |
%th= p | |
%tbody | |
- devs.each do |p1| | |
%tr | |
%th{:scope => 'row'}= p1 | |
- devs.each do |p2| | |
%td= metrics[[p1,p2].sort].count rescue "" | |
#chart | |
} | |
engine = Haml::Engine.new(report_template) | |
File.open("pairing_report.html", "w") do |report_file| | |
report_file.write(engine.render_proc(Object.new, :devs, :metrics).call(:devs => devs, :metrics => metrics)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fix