buildhawk 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY +2 -0
- data/README.rdoc +34 -0
- data/bin/buildhawk +3 -0
- data/lib/buildhawk.rb +37 -0
- data/lib/template.erb +91 -0
- metadata +93 -0
data/HISTORY
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
= Buildhawk
|
2
|
+
|
3
|
+
Historical information about your build, on a webpage!
|
4
|
+
Currently only graphs time taken, as stored in git notes.
|
5
|
+
|
6
|
+
== Status
|
7
|
+
|
8
|
+
Pretty raw: hackish script, no error checking, no test suite. I am adding to it as I use on one of my projects. Only checked on ruby 1.9.2.
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
|
12
|
+
gem install buildhawk
|
13
|
+
|
14
|
+
buildhawk --title "My App Name" # In your project directory, output HTML to stdout
|
15
|
+
buildhawk | browser # Using http://gist.github.com/318247
|
16
|
+
|
17
|
+
You need to store the build time in git notes. The following rake task should work for a standard ruby project with rvm. See http://rhnh.net/2010/09/06/storing-build-time-in-git-notes-with-zsh for more explanation.
|
18
|
+
|
19
|
+
namespace :build do
|
20
|
+
desc "Run specs and store the time taken in a git note on HEAD"
|
21
|
+
task :time do
|
22
|
+
# ruby/rake are not aliased by rvm in the new zsh environment, so
|
23
|
+
# have to explicitly call it using the rvm command stored in .rvmrc:
|
24
|
+
# rvm 1.9.2@myapp rake
|
25
|
+
#
|
26
|
+
# "2> >( )" construct redirects STDERR (where @time@ prints to) to the
|
27
|
+
# bracketed commands. ZSH allows us to redirect it twice, once to git,
|
28
|
+
# once to cat (back to STDOUT).
|
29
|
+
formatter = "tail -n 1 | cut -f 11 -d ' ' - "
|
30
|
+
exec((%{zsh -c "(time `cat .rvmrc` rake) } +
|
31
|
+
%{2> >(#{formatter} | git notes --ref=buildtime add -F - -f ) } +
|
32
|
+
%{2> >(#{formatter} | cat)"}))
|
33
|
+
end
|
34
|
+
end
|
data/bin/buildhawk
ADDED
data/lib/buildhawk.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'erubis'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
optparse = OptionParser.new do|opts|
|
7
|
+
# Set a banner, displayed at the top
|
8
|
+
# of the help screen.
|
9
|
+
opts.banner = "Usage: buildhawk [options]"
|
10
|
+
|
11
|
+
# Define the options, and what they do
|
12
|
+
options[:title] = nil
|
13
|
+
opts.on( '-t', '--title TITLE', 'Set the title of the app' ) do |title|
|
14
|
+
options[:title] = title
|
15
|
+
end
|
16
|
+
|
17
|
+
# This displays the help screen, all programs are
|
18
|
+
# assumed to have this option.
|
19
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
20
|
+
puts opts
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
optparse.parse!
|
26
|
+
|
27
|
+
data = `git log --pretty=format:"%h\t%s\t%N" --show-notes=buildtime | egrep "[0-9]$"`
|
28
|
+
data = data.lines.map {|x|
|
29
|
+
x.split("\t")
|
30
|
+
}.map {|x|
|
31
|
+
[x[2].chomp, {:ref => x[0], :subject => x[1..-2] * "\t"}]
|
32
|
+
}.reverse
|
33
|
+
|
34
|
+
input = File.read(File.dirname(__FILE__) + '/template.erb')
|
35
|
+
eruby = Erubis::Eruby.new(input)
|
36
|
+
|
37
|
+
puts eruby.result(:data => data, :title => options[:title] || "Untitled")
|
data/lib/template.erb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
|
5
|
+
|
6
|
+
<script type="text/javascript" src="http://github.com/xaviershay/tufte-graph/raw/line/raphael.js"></script>
|
7
|
+
<script type="text/javascript" src="http://github.com/xaviershay/tufte-graph/raw/line/raphael.path.methods.js"></script>
|
8
|
+
<script type="text/javascript" src="http://github.com/xaviershay/tufte-graph/raw/line/jquery.enumerable.js"></script>
|
9
|
+
<script type="text/javascript" src="http://github.com/xaviershay/tufte-graph/raw/line/jquery.tufte-graph.js"></script>
|
10
|
+
<link rel="stylesheet" href="http://github.com/xaviershay/tufte-graph/raw/line/tufte-graph.css" type="text/css" media="screen" charset="utf-8" />
|
11
|
+
|
12
|
+
<script>
|
13
|
+
var data = <%= data.to_json %>;
|
14
|
+
|
15
|
+
$(function () {
|
16
|
+
var hitTarget;
|
17
|
+
|
18
|
+
$('#build-time-graph').tufteGraph('line', {
|
19
|
+
colors: ['#333', '#0C0F66'],
|
20
|
+
data: data,
|
21
|
+
afterDraw: {
|
22
|
+
point: function(ctx, index, stackedIndex) {
|
23
|
+
if (!data[index][1].dots)
|
24
|
+
data[index][1].dots = [];
|
25
|
+
|
26
|
+
var coords = [ctx.scale.X(index + 0.5), ctx.scale.Y(data[index][0])]
|
27
|
+
data[index][1].dots.push(ctx.circle(coords[0], coords[1], 4).attr({
|
28
|
+
fill:['#333', '#0C0F66'][stackedIndex],
|
29
|
+
stroke: "#FFF"
|
30
|
+
}));
|
31
|
+
},
|
32
|
+
stack: function(ctx, index) {
|
33
|
+
(function(index) {
|
34
|
+
hitTarget = ctx.rect(ctx.scale.X(index), 0, ctx.scale.X(index + 1), ctx.axis.y.pixelLength).attr({
|
35
|
+
stroke: 'none',
|
36
|
+
fill: '#FFF',
|
37
|
+
opacity: 0
|
38
|
+
});
|
39
|
+
$(hitTarget.node).hover(function () {
|
40
|
+
// Highlight dots
|
41
|
+
$(data[index][1].dots).each(function() { this.attr({r: 5}); });
|
42
|
+
|
43
|
+
// Show label
|
44
|
+
var ref = data[index][1].ref;
|
45
|
+
$('#commits li:not(#' + ref + ')').animate({opacity: 0.3}, {duration: 500, queue: false});
|
46
|
+
$('#' + ref).animate({opacity: 1.0}, {duration: 500, queue: false});
|
47
|
+
}, function() {
|
48
|
+
// Unhighlight dots
|
49
|
+
$(data[index][1].dots).each(function() { this.attr({r: 4}); });
|
50
|
+
});
|
51
|
+
})(index);
|
52
|
+
},
|
53
|
+
graph: function(ctx) {
|
54
|
+
hitTarget.toFront();
|
55
|
+
}
|
56
|
+
}
|
57
|
+
});
|
58
|
+
});
|
59
|
+
</script>
|
60
|
+
<style>
|
61
|
+
body {
|
62
|
+
width: 500px;
|
63
|
+
margin: 0 auto;
|
64
|
+
font-family: Monofur, monospace;
|
65
|
+
text-align: center;
|
66
|
+
}
|
67
|
+
.ref { float: right }
|
68
|
+
.time { display: inline-block; }
|
69
|
+
ol { margin: 0;width: 500px;padding: 0; list-style: none }
|
70
|
+
ol li { text-align: left; opacity: 0.3; height: 1em; overflow: hidden;}
|
71
|
+
#commits { float: left; }
|
72
|
+
#build-time-graph { margin-top: -1.5em }
|
73
|
+
</style>
|
74
|
+
<title><%= title %> - BuildHawk</title>
|
75
|
+
</head>
|
76
|
+
<body>
|
77
|
+
<h1><%= title %> Build Time</h1>
|
78
|
+
<div id='build-time-graph' style=" width: 500px; height: 100px;"></div>
|
79
|
+
<div id='commits'>
|
80
|
+
<ol>
|
81
|
+
<% data.each do |time, data| %>
|
82
|
+
<li id='<%= data[:ref] %>'>
|
83
|
+
<span class='ref'><%= data[:ref] %></span>
|
84
|
+
<span class='time'><%= "%.1f" % time.to_f %></span>
|
85
|
+
<%= data[:subject] %>
|
86
|
+
</li>
|
87
|
+
<% end %>
|
88
|
+
</ol>
|
89
|
+
</div>
|
90
|
+
</body>
|
91
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: buildhawk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
version: "0.1"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Xavier Shay
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2010-09-18 00:00:00 +01:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: json
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: erubis
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id002
|
45
|
+
description:
|
46
|
+
email:
|
47
|
+
- contact@rhnh.net
|
48
|
+
executables:
|
49
|
+
- buildhawk
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
files:
|
55
|
+
- bin/buildhawk
|
56
|
+
- lib/buildhawk.rb
|
57
|
+
- lib/template.erb
|
58
|
+
- README.rdoc
|
59
|
+
- HISTORY
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://github.com/xaviershay/buildhawk
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.3.7
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: Display historical stats about your build
|
92
|
+
test_files: []
|
93
|
+
|