Skip to content

Instantly share code, notes, and snippets.

@irfn
Created May 10, 2012 15:50
Show Gist options
  • Save irfn/2654056 to your computer and use it in GitHub Desktop.
Save irfn/2654056 to your computer and use it in GitHub Desktop.
paring
<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>
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
@irfn
Copy link
Author

irfn commented May 21, 2012

fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment