git-graph 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/Readme.md CHANGED
@@ -19,9 +19,9 @@ git-graph --interval day --output csv "cat Readme.md | wc -l"
19
19
 
20
20
  ```Bash
21
21
  # number of lines in the readme as line-chart (via google charts)
22
- git-graph --interval year --output chart "cat Gemfile.lock | grep DEPENDENCIES -A 999 | wc -l"
22
+ git-graph --interval week --output chart "wc -l Readme.md"
23
23
  ```
24
- ![Chart](http://chart.apis.google.com/chart?chs=600x500&cht=lc&chxt=x,y&chxl=0:|2010-03-10|2013-03-09|1:|0|97&chd=s:Aos9&chdl=value&chtt=git-graph)
24
+ ![Chart](http://chart.apis.google.com/chart?chs=600x200&cht=lc&chxt=x,y&chxl=0:|2009-05-23|2013-03-09|1:|0|97&chd=s:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhiijjjkkkkkkkkkkkkkkkkllloooooooooooooooooooooopppppqqqqqqqqqqqqrrrrrrssssssssssssssssssssssssssssssssssssss2222222999999999999999&chdl=Lines&chtt=Readme+lines)
25
25
 
26
26
  ```Bash
27
27
  # number of gems the project depends on
data/bin/git-graph CHANGED
@@ -4,7 +4,11 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
4
4
  require 'git/graph'
5
5
  require 'time'
6
6
 
7
- options = {}
7
+ options = {
8
+ :chart_dimensions => '600x500',
9
+ :value_name => "value",
10
+ :chart_title => "git-chart"
11
+ }
8
12
  OptionParser.new do |opts|
9
13
  opts.banner = <<BANNER
10
14
  Make graphs from your git history.
@@ -19,6 +23,9 @@ BANNER
19
23
  opts.on("-o", "--output FORMAT", "Output format - csv|chart") { |format| options[:format] = format }
20
24
  opts.on("-i", "--interval INTERVAL", "Interval of git history - year|week|day)") { |interval| options[:interval] = interval }
21
25
  opts.on("-b", "--bundle", "Bundle before running command") { options[:bundle] = true }
26
+ opts.on("--chart-dimensions DIMENSIONS", "Dimensions of the chart (default: #{options[:chart_dimensions]})") { |v| options[:chart_dimensions] = v }
27
+ opts.on("--value-name NAME", "Name of the value (default: #{options[:value_name]})") { |v| options[:value_name] = v }
28
+ opts.on("--chart-title TITLE", "Chart title (default: #{options[:chart_title]})") { |v| options[:chart_title] = v }
22
29
  opts.on("-h", "--help","Show this.") { puts opts; exit }
23
30
  opts.on('-v', '--version','Show Version'){ puts Git::Graph::VERSION; exit}
24
31
  end.parse!
@@ -56,8 +63,6 @@ finish = (options[:end] || Time.at(run!("git log --reverse --format='%at' | head
56
63
  current = start
57
64
  raise "Backwards" if start < finish
58
65
 
59
- data = {}
60
-
61
66
  DAY = 24*60*60
62
67
  INTERVALS = {
63
68
  "day" => DAY,
@@ -65,38 +70,43 @@ INTERVALS = {
65
70
  "year" => 365 * DAY
66
71
  }
67
72
 
68
- interval = INTERVALS[options[:interval] || "year"]
73
+ data = {}
74
+ interval = (INTERVALS[options[:interval] || "year"] || raise("unsupported interval"))
69
75
 
70
- while current > finish
71
- date = current.strftime("%Y-%m-%d")
72
- command = [
73
- "git checkout `git rev-list -n 1 --before='#{date}' master`",
74
- ("bundle check || bundle" if options[:bundle]),
75
- ARGV.first
76
- ].compact
77
- success, output = without_bundler { run(command.map { |c| "(#{c})" }.join(" && ")) }
78
- data[date] = if success
79
- value = output.split("\n").last.strip
80
- value =~ /^\d+\.\d+$/ ? value.to_f : value.to_i
81
- else
82
- data.values.last || 0
76
+ begin
77
+ while current > finish
78
+ date = current.strftime("%Y-%m-%d")
79
+ command = [
80
+ "git checkout -f `git rev-list -n 1 --before='#{date}' master`",
81
+ ("bundle check || bundle" if options[:bundle]),
82
+ ARGV.first
83
+ ].compact
84
+ success, output = without_bundler { run(command.map { |c| "(#{c})" }.join(" && ")) }
85
+ data[date] = if success
86
+ value = output.split("\n").last.to_s.strip
87
+ value =~ /^\d+\.\d+$/ ? value.to_f : value.to_i
88
+ else
89
+ data.values.last || 0
90
+ end
91
+ current -= interval
83
92
  end
84
- current -= interval
93
+ rescue SystemExit, Interrupt
94
+ $stderr.puts "Data collection interrupted by user"
85
95
  end
86
96
 
97
+ # print output even if user stops execution
87
98
  case options[:format]
88
99
  when nil, "csv"
89
- puts "Date,value"
100
+ puts "Date,#{options[:value_name]}"
90
101
  data.map do |date, value|
91
102
  puts "#{date},#{value}"
92
103
  end
93
104
  when "chart"
94
105
  require "google_chart"
95
- title = "git-graph"
96
106
  dates = data.keys.reverse
97
107
  values = data.values.reverse
98
- url = GoogleChart::LineChart.new('600x500', title, false) do |line|
99
- line.data("value", values)
108
+ url = GoogleChart::LineChart.new(options[:chart_dimensions], options[:chart_title], false) do |line|
109
+ line.data(options[:value_name], values)
100
110
  line.axis :x, :labels => [dates.first, dates.last]
101
111
  line.axis :y, :labels => ['0', values.max]
102
112
  end.to_url
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Graph
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  segments:
89
89
  - 0
90
- hash: 3863793032351926901
90
+ hash: -3227504656897889005
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  none: false
93
93
  requirements:
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  segments:
98
98
  - 0
99
- hash: 3863793032351926901
99
+ hash: -3227504656897889005
100
100
  requirements: []
101
101
  rubyforge_project:
102
102
  rubygems_version: 1.8.24
metadata.gz.sig CHANGED
Binary file