Created
May 4, 2010 10:38
-
-
Save jberkel/389248 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env ruby | |
| # vim: set ts=2 expandtab: | |
| require 'rubygems' | |
| require 'nokogiri' | |
| require 'pp' | |
| require 'erb' | |
| build_dir = '/var/deploy/.hudson/jobs/SoundCloud coverage/builds/**/archive/coverage/index.html' | |
| date_and_coverage = Dir[build_dir].map do |f| | |
| doc = Nokogiri::HTML(IO.read(f)) | |
| [File.stat(f).ctime, doc.css('tt.coverage_total').first.content]#.tap { |o| pp o } | |
| end.sort { |(a,b), (c,d)| a <=> c }[-30..-1] | |
| erb = ERB.new(<<-TEMPLATE) | |
| <html> | |
| <head> | |
| <!--Load the AJAX API--> | |
| <script type="text/javascript" src="http://www.google.com/jsapi"></script> | |
| <script type="text/javascript"> | |
| // Load the Visualization API and the piechart package. | |
| google.load('visualization', '1', {'packages':['linechart']}); | |
| google.load("jquery", "1.4.2", {uncompressed:true}); | |
| google.setOnLoadCallback(function () { | |
| var data = new google.visualization.DataTable(); | |
| data.addColumn('string', 'Date'); | |
| data.addColumn('number', 'Coverage'); | |
| $('table#coverage').find('tr').each(function() { | |
| var date = $(this).children('td.date')[0].innerText, | |
| percent = $(this).children('td.coverage')[0].innerText; | |
| data.addRow( [date, parseFloat(percent.replace('%', ''))] ); | |
| }); | |
| var chart = new google.visualization.LineChart(document.getElementById('chart_div')); | |
| chart.draw(data, {width: '100%', height: 400}); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <div id="chart_div"></div> | |
| <table id="coverage"> | |
| <% date_and_coverage.each do |d, c| %> | |
| <tr> | |
| <td class="date"> <%= d %> </td> | |
| <td class="coverage"><%= c %> </td> | |
| </tr> | |
| <% end %> | |
| </table> | |
| </body> | |
| </html> | |
| TEMPLATE | |
| puts erb.result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment