gitstats-rb 2.0.0

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.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/LICENSE +674 -0
  4. data/README.md +74 -0
  5. data/bin/gitstats +200 -0
  6. data/gitstats-rb.gemspec +24 -0
  7. data/lib/gitstats.rb +18 -0
  8. data/lib/gitstats/author.rb +37 -0
  9. data/lib/gitstats/git.rb +165 -0
  10. data/lib/gitstats/renderer.rb +30 -0
  11. data/lib/gitstats/renderer/gnuplot.rb +150 -0
  12. data/lib/gitstats/renderer/haml.rb +72 -0
  13. data/lib/gitstats/renderer/sass.rb +33 -0
  14. data/lib/gitstats/statgen.rb +119 -0
  15. data/lib/gitstats/stats.rb +12 -0
  16. data/lib/gitstats/stats/commit.rb +63 -0
  17. data/lib/gitstats/stats/commit/author.rb +17 -0
  18. data/lib/gitstats/stats/commit/time.rb +109 -0
  19. data/lib/gitstats/stats/file.rb +15 -0
  20. data/lib/gitstats/stats/file/filetype.rb +14 -0
  21. data/lib/gitstats/yearmonth.rb +39 -0
  22. data/template/gnuplot/activity.haml +3 -0
  23. data/template/gnuplot/asc.gif +0 -0
  24. data/template/gnuplot/authors.haml +2 -0
  25. data/template/gnuplot/bg.gif +0 -0
  26. data/template/gnuplot/commits_per_hour.plot +14 -0
  27. data/template/gnuplot/commits_per_month.plot +15 -0
  28. data/template/gnuplot/commits_per_wday.plot +15 -0
  29. data/template/gnuplot/commits_per_year.plot +11 -0
  30. data/template/gnuplot/commits_per_yearmonth.plot +11 -0
  31. data/template/gnuplot/desc.gif +0 -0
  32. data/template/gnuplot/filechanges_by_yearmonth.plot +17 -0
  33. data/template/gnuplot/files.haml +2 -0
  34. data/template/gnuplot/files_by_yearmonth.plot +11 -0
  35. data/template/gnuplot/helpers/block.rb +26 -0
  36. data/template/gnuplot/helpers/config.rb +12 -0
  37. data/template/gnuplot/helpers/names.rb +79 -0
  38. data/template/gnuplot/helpers/utils.rb +16 -0
  39. data/template/gnuplot/index.haml +2 -0
  40. data/template/gnuplot/jqplot.canvasAxisLabelRenderer.min.js +57 -0
  41. data/template/gnuplot/jqplot.canvasAxisTickRenderer.min.js +57 -0
  42. data/template/gnuplot/jqplot.canvasTextRenderer.min.js +57 -0
  43. data/template/gnuplot/jqplot.cursor.min.js +57 -0
  44. data/template/gnuplot/jqplot.dateAxisRenderer.min.js +57 -0
  45. data/template/gnuplot/jquery.jqplot.min.css +1 -0
  46. data/template/gnuplot/jquery.jqplot.min.js +57 -0
  47. data/template/gnuplot/jquery.js +4 -0
  48. data/template/gnuplot/jquery.tablesorter.js +4 -0
  49. data/template/gnuplot/lastweeks.plot +14 -0
  50. data/template/gnuplot/layouts/default.haml +117 -0
  51. data/template/gnuplot/linechanges_by_yearmonth.plot +17 -0
  52. data/template/gnuplot/lines.haml +2 -0
  53. data/template/gnuplot/lines_by_yearmonth.plot +11 -0
  54. data/template/gnuplot/partials/authors.haml +30 -0
  55. data/template/gnuplot/partials/blockheader.haml +2 -0
  56. data/template/gnuplot/partials/blocktoc.haml +7 -0
  57. data/template/gnuplot/partials/commitchart.haml +60 -0
  58. data/template/gnuplot/partials/commits_per_month.haml +27 -0
  59. data/template/gnuplot/partials/commits_per_year.haml +27 -0
  60. data/template/gnuplot/partials/commits_per_yearmonth.haml +27 -0
  61. data/template/gnuplot/partials/day_of_week.haml +28 -0
  62. data/template/gnuplot/partials/filechanges_by_yearmonth.haml +3 -0
  63. data/template/gnuplot/partials/files_by_yearmonth.haml +3 -0
  64. data/template/gnuplot/partials/fileschart.haml +86 -0
  65. data/template/gnuplot/partials/filetypes.haml +23 -0
  66. data/template/gnuplot/partials/general.haml +34 -0
  67. data/template/gnuplot/partials/hour_of_day.haml +28 -0
  68. data/template/gnuplot/partials/hour_of_week.haml +24 -0
  69. data/template/gnuplot/partials/lastweeks.haml +24 -0
  70. data/template/gnuplot/partials/linechanges_by_yearmonth.haml +3 -0
  71. data/template/gnuplot/partials/lines_by_yearmonth.haml +3 -0
  72. data/template/gnuplot/partials/lineschart.haml +86 -0
  73. data/template/gnuplot/partials/repos.haml +13 -0
  74. data/template/gnuplot/partials/top_authors_of_year.haml +30 -0
  75. data/template/gnuplot/partials/top_authors_of_yearmonth.haml +30 -0
  76. data/template/gnuplot/style.scss +132 -0
  77. data/template/highcharts/activity.haml +5 -0
  78. data/template/highcharts/authors.haml +3 -0
  79. data/template/highcharts/bootstrap-theme.min.css +10 -0
  80. data/template/highcharts/bootstrap.min.css +10 -0
  81. data/template/highcharts/bootstrap.min.js +11 -0
  82. data/template/highcharts/exporting.js +23 -0
  83. data/template/highcharts/glyphicons-halflings-regular.eot +0 -0
  84. data/template/highcharts/glyphicons-halflings-regular.svg +229 -0
  85. data/template/highcharts/glyphicons-halflings-regular.ttf +0 -0
  86. data/template/highcharts/glyphicons-halflings-regular.woff +0 -0
  87. data/template/highcharts/heatmap.js +23 -0
  88. data/template/highcharts/helpers/block.rb +27 -0
  89. data/template/highcharts/helpers/names.rb +62 -0
  90. data/template/highcharts/helpers/params.rb +35 -0
  91. data/template/highcharts/highcharts.js +308 -0
  92. data/template/highcharts/index.haml +2 -0
  93. data/template/highcharts/jquery-1.11.1.min.js +4 -0
  94. data/template/highcharts/jquery.dataTables.min.css +1 -0
  95. data/template/highcharts/jquery.dataTables.min.js +164 -0
  96. data/template/highcharts/layouts/default.haml +54 -0
  97. data/template/highcharts/partials/activity_per_day.haml +65 -0
  98. data/template/highcharts/partials/activity_per_hour.haml +42 -0
  99. data/template/highcharts/partials/activity_per_month.haml +47 -0
  100. data/template/highcharts/partials/activity_per_week_last_year.haml +47 -0
  101. data/template/highcharts/partials/activity_per_weekday.haml +44 -0
  102. data/template/highcharts/partials/activity_per_weekday_and_hour.haml +20 -0
  103. data/template/highcharts/partials/blocktoc.haml +4 -0
  104. data/template/highcharts/partials/commits_per_author.haml +64 -0
  105. data/template/highcharts/partials/commits_per_author_detailed.haml +92 -0
  106. data/template/highcharts/partials/general.haml +33 -0
  107. data/template/highcharts/partials/globalstats.haml +41 -0
  108. data/template/highcharts/partials/repos.haml +12 -0
  109. data/template/highcharts/set_highcharts.js +323 -0
  110. data/template/highcharts/style.scss +148 -0
  111. metadata +227 -0
@@ -0,0 +1,17 @@
1
+ defplot do |plotter|
2
+ plotter.add_steps do |x, l, y|
3
+ stats.yearmonth_stats.each_sorted do |yearmonth, stats|
4
+ x << yearmonth.to_i
5
+ l << yearmonth.to_s
6
+ y << stats.lines_added
7
+ end
8
+ end
9
+
10
+ plotter.add_steps do |x, l, y|
11
+ stats.yearmonth_stats.each_sorted do |yearmonth, stats|
12
+ x << yearmonth.to_i
13
+ l << yearmonth.to_s
14
+ y << stats.lines_deleted
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ - layout :default
2
+ = blocks :lineschart, :lines_by_yearmonth, :linechanges_by_yearmonth
@@ -0,0 +1,11 @@
1
+ defplot do |plotter|
2
+ plotter.add_steps do |x, l, y|
3
+ lines = 0
4
+ stats.yearmonth_stats.each_sorted do |yearmonth, stats|
5
+ lines += stats.lines
6
+ x << yearmonth.to_i
7
+ l << yearmonth.to_s
8
+ y << lines
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#author_table").tablesorter({sortList: [[1, 1]]});
4
+ });
5
+ - block(:authors) do
6
+ .blocktable
7
+ %table#author_table.tablesorter.striped
8
+ %thead
9
+ %tr
10
+ %th Author
11
+ %th Commits
12
+ %th Percent
13
+ %th Files added
14
+ %th Files deleted
15
+ %th Lines added
16
+ %th Lines deleted
17
+ %th First commit
18
+ %th Last commit
19
+ %tbody
20
+ - stats.author_stats.sort{ |a, b| a[1].commits <=> b[1].commits }.reverse[0, author_count].each do |author, commits|
21
+ %tr
22
+ %td&= author
23
+ %td&= commits.commits
24
+ %td&= '%.2f%%' % (commits.commits * 100.0 / stats.num_commits.to_f)
25
+ %td&= commits.files_added
26
+ %td&= commits.files_deleted
27
+ %td&= commits.lines_added
28
+ %td&= commits.lines_deleted
29
+ %td&= commits.first_commit.strftime('%Y-%m-%d')
30
+ %td&= commits.last_commit.strftime('%Y-%m-%d')
@@ -0,0 +1,2 @@
1
+ %h2.blockheader
2
+ %a{ :name => name.to_s }= label(name)
@@ -0,0 +1,7 @@
1
+ #toc
2
+ %h2
3
+ %a{ :name => 'toc' } Blocks
4
+ %ul
5
+ - blocks.each do |name|
6
+ %li
7
+ %a{:href => "##{name.to_s}"}= label(name)
@@ -0,0 +1,60 @@
1
+ - block(:commitchart) do
2
+ .blockdiagram
3
+ #commitchart{ :style => 'height:240px; width:640px' }
4
+
5
+ - lst = Array.new
6
+ - stats.date_stats.each_sorted do |a, b|
7
+ - lst << "['#{a}', #{b.commits}]"
8
+
9
+ :javascript
10
+ $(document).ready(function(){
11
+ var line = [#{lst.join(',')}];
12
+ var plot = $.jqplot('commitchart', [line], {
13
+ legend: {
14
+ show: true,
15
+ rowSpacing: '0',
16
+ location: 'nw',
17
+ },
18
+ axes: {
19
+ xaxis: {
20
+ pad: 0,
21
+ renderer: $.jqplot.DateAxisRenderer,
22
+ tickRenderer: $.jqplot.CanvasAxisTickRenderer,
23
+ tickOptions: {
24
+ angle: 30
25
+ }
26
+ },
27
+ yaxis: {
28
+ label: 'Commits',
29
+ min: 0,
30
+ labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
31
+ tickRenderer: $.jqplot.CanvasAxisTickRenderer,
32
+ tickOptions: {
33
+ angle: 30,
34
+ formatString: '%d'
35
+ }
36
+ }
37
+ },
38
+ series: [
39
+ {
40
+ label: 'Commits',
41
+ showMarker: false
42
+ }
43
+ ],
44
+ cursor: {
45
+ show: true,
46
+ zoom: true,
47
+ looseZoom: false,
48
+ constrainZoomTo: 'x',
49
+ showTooltip: true,
50
+ tooltipLocation: 'sw',
51
+ showTooltipUnitPosition: false,
52
+ showTooltipDataPosition: true,
53
+ showVerticalLine: true,
54
+ tooltipFormatString: '<b>%2$s</b> %1$s: %3$s'
55
+ }
56
+ });
57
+
58
+ plot.target.bind('jqplotZoom', jqplot_zoom);
59
+ plot.target.bind('jqplotResetZoom', jqplot_zoom_reset);
60
+ });
@@ -0,0 +1,27 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#month_table").tablesorter();
4
+ });
5
+ - block(:commits_per_month) do
6
+ .blockdiagram
7
+ %img{ :src => 'commits_per_month.png' }
8
+ %a.toggle{:href => '#'} Table
9
+ .blocktable.toggleable
10
+ %table#month_table.tablesorter.striped
11
+ %thead
12
+ %tr
13
+ %th Month
14
+ %th Commits
15
+ %th Files added
16
+ %th Files deleted
17
+ %th Lines added
18
+ %th Lines deleted
19
+ %tbody
20
+ - stats.month_stats.each do |month, commits|
21
+ %tr
22
+ %td&= monthname(month)
23
+ %td&= commits.commits
24
+ %td&= commits.files_added
25
+ %td&= commits.files_deleted
26
+ %td&= commits.lines_added
27
+ %td&= commits.lines_deleted
@@ -0,0 +1,27 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#year_table").tablesorter({sortList: [[0, 1]]});
4
+ });
5
+ - block(:commits_per_year) do
6
+ .blockdiagram
7
+ %img{ :src => 'commits_per_year.png' }
8
+ %a.toggle{:href => '#'} Table
9
+ .blocktable.toggleable
10
+ %table#year_table.tablesorter.striped
11
+ %thead
12
+ %tr
13
+ %th Year
14
+ %th Commits
15
+ %th Files added
16
+ %th Files deleted
17
+ %th Lines added
18
+ %th Lines deleted
19
+ %tbody
20
+ - stats.year_stats.each do |year, commits|
21
+ %tr
22
+ %td&= year
23
+ %td&= commits.commits
24
+ %td&= commits.files_added
25
+ %td&= commits.files_deleted
26
+ %td&= commits.lines_added
27
+ %td&= commits.lines_deleted
@@ -0,0 +1,27 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#yearmonth_table").tablesorter({sortList: [[0, 1]]});
4
+ });
5
+ - block(:commits_per_yearmonth) do
6
+ .blockdiagram
7
+ %img{ :src => 'commits_per_yearmonth.png' }
8
+ %a.toggle{:href => '#'} Table
9
+ .blocktable.toggleable
10
+ %table#yearmonth_table.tablesorter.striped
11
+ %thead
12
+ %tr
13
+ %th Year-Month
14
+ %th Commits
15
+ %th Files added
16
+ %th Files deleted
17
+ %th Lines added
18
+ %th Lines deleted
19
+ %tbody
20
+ - stats.yearmonth_stats.each do |yearmonth, commits|
21
+ %tr
22
+ %td&= yearmonth
23
+ %td&= commits.commits
24
+ %td&= commits.files_added
25
+ %td&= commits.files_deleted
26
+ %td&= commits.lines_added
27
+ %td&= commits.lines_deleted
@@ -0,0 +1,28 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#dayofweek_table").tablesorter();
4
+ });
5
+ - block(:day_of_week) do
6
+ .blockdiagram
7
+ %img{ :src => 'commits_per_wday.png' }
8
+ %a.toggle{:href => '#'} Table
9
+ .blocktable.toggleable
10
+ %table#dayofweek_table.tablesorter.striped
11
+ %thead
12
+ %tr
13
+ %th Weekday
14
+ %th Commits
15
+ %th Files added
16
+ %th Files deleted
17
+ %th Lines added
18
+ %th Lines deleted
19
+ %tbody
20
+ - for wday in 0..6
21
+ - s = stats.wday_stats[(wday + 1) % 7]
22
+ %tr
23
+ %th&= weekday(wday)
24
+ %td&= (s.nil? ? 0 : s.commits)
25
+ %td&= (s.nil? ? 0 : s.files_added)
26
+ %td&= (s.nil? ? 0 : s.files_deleted)
27
+ %td&= (s.nil? ? 0 : s.lines_added)
28
+ %td&= (s.nil? ? 0 : s.lines_deleted)
@@ -0,0 +1,3 @@
1
+ - block(:filechanges_by_yearmonth) do
2
+ .blockdiagram
3
+ %img{ :src => 'filechanges_by_yearmonth.png' }
@@ -0,0 +1,3 @@
1
+ - block(:files_by_yearmonth) do
2
+ .blockdiagram
3
+ %img{ :src => 'files_by_yearmonth.png' }
@@ -0,0 +1,86 @@
1
+ - block(:fileschart) do
2
+ .blockdiagram
3
+ #fileschart{ :style => 'height:240px; width:640px' }
4
+
5
+ - old = 0
6
+ - lst1 = Array.new
7
+ - lst2 = Array.new
8
+ - lst3 = Array.new
9
+ - stats.date_stats.each_sorted do |a, b|
10
+ - old += b.files
11
+ - lst1 << "['#{a}', #{old}]"
12
+ - lst2 << "['#{a}', #{b.files_added}]"
13
+ - lst3 << "['#{a}', #{b.files_deleted}]"
14
+
15
+ :javascript
16
+ $(document).ready(function(){
17
+ var line1 = [#{lst1.join(',')}];
18
+ var line2 = [#{lst2.join(',')}];
19
+ var line3 = [#{lst3.join(',')}];
20
+ var plot = $.jqplot('fileschart', [line1, line2, line3], {
21
+ legend: {
22
+ show: true,
23
+ rowSpacing: '0',
24
+ location: 'nw',
25
+ },
26
+ axes: {
27
+ xaxis: {
28
+ pad: 0,
29
+ renderer: $.jqplot.DateAxisRenderer,
30
+ tickRenderer: $.jqplot.CanvasAxisTickRenderer,
31
+ tickOptions: {
32
+ angle: 30
33
+ }
34
+ },
35
+ yaxis: {
36
+ label: 'Files',
37
+ min: 0,
38
+ labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
39
+ tickRenderer: $.jqplot.CanvasAxisTickRenderer,
40
+ tickOptions: {
41
+ angle: 30,
42
+ formatString: '%d'
43
+ }
44
+ },
45
+ y2axis: {
46
+ label: 'Changes',
47
+ min: 0,
48
+ labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
49
+ tickRenderer: $.jqplot.CanvasAxisTickRenderer,
50
+ tickOptions: {
51
+ angle: 30,
52
+ formatString: '%d'
53
+ }
54
+ }
55
+ },
56
+ series: [
57
+ {
58
+ label: 'Files',
59
+ showMarker: false
60
+ },{
61
+ label: 'Added',
62
+ showMarker: false,
63
+ yaxis: 'y2axis'
64
+ },{
65
+ label: 'Deleted',
66
+ showMarker: false,
67
+ yaxis: 'y2axis'
68
+ }
69
+ ],
70
+ cursor: {
71
+ show: true,
72
+ zoom: true,
73
+ looseZoom: false,
74
+ constrainZoomTo: 'x',
75
+ showTooltip: true,
76
+ tooltipLocation: 'sw',
77
+ showTooltipUnitPosition: false,
78
+ showTooltipDataPosition: true,
79
+ showVerticalLine: true,
80
+ tooltipFormatString: '<b>%2$s</b> %1$s: %3$s'
81
+ }
82
+ });
83
+
84
+ plot.target.bind('jqplotZoom', jqplot_zoom);
85
+ plot.target.bind('jqplotResetZoom', jqplot_zoom_reset);
86
+ });
@@ -0,0 +1,23 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#filetypes_table").tablesorter({
4
+ sortList: [[1, 1]],
5
+ headers: {
6
+ 2: { sorter: 'size' }
7
+ }
8
+ });
9
+ });
10
+ - block(:filetypes) do
11
+ .blocktable
12
+ %table#filetypes_table.tablesorter.striped
13
+ %thead
14
+ %tr
15
+ %th Extension
16
+ %th Count
17
+ %th Size
18
+ %tbody
19
+ - stats.filetype_stats.each do |type, file|
20
+ %tr
21
+ %td&= type
22
+ %td&= file.count
23
+ %td&= filesize(file.size)
@@ -0,0 +1,34 @@
1
+ - commits = stats.general_stats.commits
2
+ - age = ((stats.general_stats.last_commit - stats.general_stats.first_commit + 86399) / 86400).to_i
3
+ - active = stats.general_stats.days
4
+ - block(:general) do
5
+ .blocktable
6
+ %table.simpletable
7
+ %tbody
8
+ %tr
9
+ %th Generation time
10
+ %td&= Time.now.to_s
11
+ %tr
12
+ %th Authors
13
+ %td= '%d (average %.1f commits per author)' % [stats.num_authors, commits / stats.num_authors]
14
+ %tr
15
+ %th Commits
16
+ %td= '%d (average %.1f commits per active day, %.1f per all days)' % [commits, commits / active, commits / age]
17
+ %tr
18
+ %th Files
19
+ %td= '%d (%d added, %d deleted)' % [stats.general_stats.files, stats.general_stats.files_added, stats.general_stats.files_deleted]
20
+ %tr
21
+ %th Lines
22
+ %td= '%d (%d added, %d deleted)' % [stats.general_stats.lines, stats.general_stats.lines_added, stats.general_stats.lines_deleted]
23
+ %tr
24
+ %th Size
25
+ %td= '%d bytes' % stats.file_stats.size
26
+ %tr
27
+ %th First commit
28
+ %td= stats.general_stats.first_commit.to_s
29
+ %tr
30
+ %th Last commit
31
+ %td= stats.general_stats.last_commit.to_s
32
+ %tr
33
+ %th Age
34
+ %td= '%d / %d active days (%.2f%%)' % [active, age, active * 100.0 / age.to_f]
@@ -0,0 +1,28 @@
1
+ :javascript
2
+ $(document).ready(function() {
3
+ $("#hourofday_table").tablesorter({sortList: [[0, 0]]});
4
+ });
5
+ - block(:hour_of_day) do
6
+ .blockdiagram
7
+ %img{ :src => 'commits_per_hour.png' }
8
+ %a.toggle{:href => '#'} Table
9
+ .blocktable.toggleable
10
+ %table#hourofday_table.tablesorter.striped
11
+ %thead
12
+ %tr
13
+ %th Hour
14
+ %th Commits
15
+ %th Files added
16
+ %th Files deleted
17
+ %th Lines added
18
+ %th Lines deleted
19
+ %tbody
20
+ - for hour in 0..23
21
+ - s = stats.hour_stats[hour]
22
+ %tr
23
+ %th&= hour
24
+ %td&= (s.nil? ? 0 : s.commits)
25
+ %td&= (s.nil? ? 0 : s.files_added)
26
+ %td&= (s.nil? ? 0 : s.files_deleted)
27
+ %td&= (s.nil? ? 0 : s.lines_added)
28
+ %td&= (s.nil? ? 0 : s.lines_deleted)
@@ -0,0 +1,24 @@
1
+ - block(:hour_of_week) do
2
+ .blocktable
3
+ %table
4
+ %thead
5
+ %tr
6
+ %th Weekday
7
+ - for i in 0..23
8
+ %th= i
9
+ %tbody
10
+ - max = stats.wday_stats.inject(0) do |r, i|
11
+ - i[1].inject(r) do |r2, i2|
12
+ - i2[1].commits > r2 ? i2[1].commits : r2
13
+ - for wday in 0..6
14
+ %tr
15
+ %th= weekday(wday)
16
+ - for hour in 0..23
17
+ - d = stats.wday_stats[(wday + 1) % 7]
18
+ - s = d.nil? ? nil : d[hour]
19
+ - cnt = s.nil? ? 0 : s.commits
20
+ - percent = (100 * cnt / max).to_i
21
+ - if cnt == 0
22
+ %td
23
+ - else
24
+ %td{:class => "gradient-#{percent}"}= cnt