buildhawk 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/HISTORY +5 -0
  2. data/README.rdoc +4 -2
  3. data/bin/buildhawk +2 -0
  4. data/lib/buildhawk.rb +39 -30
  5. metadata +4 -4
data/HISTORY CHANGED
@@ -1,2 +1,7 @@
1
+ 0.2.0 - 19 November 2010
2
+ * Depend on json_pure rather than json
3
+ * Handle times longer than a minute correctly
4
+ * Does not autorun on require, you must call Buildhawk.run
5
+
1
6
  0.1.0 - 18 September 2010
2
7
  * First release! Supports basic build time graph, no error checking.
@@ -3,9 +3,11 @@
3
3
  Historical information about your build, on a webpage!
4
4
  Currently only graphs time taken, as stored in git notes.
5
5
 
6
+ See how it looks: http://rhnh.net/2010/09/18/build-time-graph-with-buildhawk
7
+
6
8
  == Status
7
9
 
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.
10
+ 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. Depends on an unreleased experimental branch of TufteGraph (http://github.com/xaviershay/tufte-graph/tree/line).
9
11
 
10
12
  == Usage
11
13
 
@@ -14,7 +16,7 @@ Pretty raw: hackish script, no error checking, no test suite. I am adding to it
14
16
  buildhawk --title "My App Name" # In your project directory, output HTML to stdout
15
17
  buildhawk | browser # Using http://gist.github.com/318247
16
18
 
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.
19
+ You need to store the build time in git notes. This should be a single float: the build time in seconds. 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. Note that `time` does not appear to output consistent enough spacing to be used reliably with cut, you may need to tweak the `cut -f 11 -d` command to pull out the right field.
18
20
 
19
21
  namespace :build do
20
22
  desc "Run specs and store the time taken in a git note on HEAD"
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'buildhawk.rb'))
4
+
5
+ Buildhawk.run
@@ -1,37 +1,46 @@
1
1
  require 'optparse'
2
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
3
+ require 'json_pure'
16
4
 
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
5
+ class Buildhawk
6
+ def self.run
7
+ options = {}
8
+ optparse = OptionParser.new do|opts|
9
+ # Set a banner, displayed at the top
10
+ # of the help screen.
11
+ opts.banner = "Usage: buildhawk [options]"
12
+
13
+ # Define the options, and what they do
14
+ options[:title] = nil
15
+ opts.on( '-t', '--title TITLE', 'Set the title of the app' ) do |title|
16
+ options[:title] = title
17
+ end
18
+
19
+ # This displays the help screen, all programs are
20
+ # assumed to have this option.
21
+ opts.on( '-h', '--help', 'Display this screen' ) do
22
+ puts opts
23
+ exit
24
+ end
25
+ end
24
26
 
25
- optparse.parse!
27
+ optparse.parse!
26
28
 
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
29
+ data = `git log --pretty=format:"%h\t%s\t%N" --show-notes=buildtime | egrep "[0-9]$"`
30
+ data = data.lines.map {|x|
31
+ x.split("\t")
32
+ }.map {|x|
33
+ [to_seconds(x[2].chomp), {:ref => x[0], :subject => x[1..-2] * "\t"}]
34
+ }.reverse
33
35
 
34
- input = File.read(File.dirname(__FILE__) + '/template.erb')
35
- eruby = Erubis::Eruby.new(input)
36
+ input = File.read(File.dirname(__FILE__) + '/template.erb')
37
+ eruby = Erubis::Eruby.new(input)
36
38
 
37
- puts eruby.result(:data => data, :title => options[:title] || "Untitled")
39
+ puts eruby.result(:data => data, :title => options[:title] || "Untitled")
40
+ end
41
+
42
+
43
+ def self.to_seconds(str)
44
+ str.split(':').reverse.to_enum(:map).with_index {|x, i| x.to_f * 60 ** i }.inject {|a, b| a + b }
45
+ end
46
+ end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- version: "0.1"
7
+ - 2
8
+ version: "0.2"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Xavier Shay
@@ -13,11 +13,11 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-09-18 00:00:00 +01:00
16
+ date: 2010-11-19 00:00:00 +11:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
- name: json
20
+ name: json_pure
21
21
  prerelease: false
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false