gitstats 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gitstats.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,4 @@
1
+ GITSTATS
2
+ ========
3
+
4
+ Generate statistics using git blame tool.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do |map|
2
+ mount Gitstats::Shitometer => '/gitstats'
3
+ end
data/gitstats.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gitstats/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gitstats"
7
+ s.version = Gitstats::VERSION
8
+ s.authors = ["Andrey Koleshko"]
9
+ s.email = ["ka8725@gmail.com"]
10
+ s.homepage = "http://ka8725.github.com/gitstats"
11
+ s.summary = %q{Show git statistics using blame}
12
+ s.description = %q{Show git statistics using blame. More metrics are coming.}
13
+
14
+ s.rubyforge_project = "gitstats"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,69 @@
1
+ module Gitstats
2
+ class Shitometer
3
+ def self.call(env)
4
+ filelist = `git ls-files --exclude-standard`.split.reject {|x| x =~ /(^vendor)|(^public\/images)|(^public\/stylesheets)/}
5
+ res = {}
6
+ filelist.map do |file|
7
+ blamelist = `git blame -e #{file} | cut -d' ' -f 2`.split.map do |line|
8
+ line.gsub!(/[()<>]/, '')
9
+ end.compact.sort.group_by(&:to_s).map do |email, group|
10
+ res[email] ||= 0; res[email] += group.size
11
+ end
12
+ end
13
+ res = res.to_a.sort {|a,b| b.last <=> a.last}
14
+ [
15
+ 200,
16
+ {'Content-Type'=>'text/html'},
17
+ <<-EOB
18
+ <html>
19
+ <head>
20
+ <!--Load the AJAX API-->
21
+ <script type="text/javascript" src="https://www.google.com/jsapi"></script>
22
+ <script type="text/javascript">
23
+
24
+ // Load the Visualization API and the piechart package.
25
+ google.load('visualization', '1.0', {'packages':['corechart', 'table']});
26
+
27
+ // Set a callback to run when the Google Visualization API is loaded.
28
+ google.setOnLoadCallback(drawChart);
29
+
30
+ // Callback that creates and populates a data table,
31
+ // instantiates the pie chart, passes in the data and
32
+ // draws it.
33
+ function drawChart() {
34
+
35
+ // Create the data table.
36
+ data = new google.visualization.DataTable();
37
+ data.addColumn('string', 'Developer');
38
+ data.addColumn('number', 'Count strings');
39
+ items = #{res.to_json};
40
+ data.addRows(items);
41
+ // Set chart options
42
+ var options = {'title':'Git stats',
43
+ 'width':700,
44
+ 'height':600};
45
+ // Instantiate and draw our chart, passing in some options.
46
+ var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
47
+ chart.draw(data, options);
48
+ var table = new google.visualization.Table(document.getElementById('table_div'));
49
+ table.draw(data, {showRowNumber: true});
50
+ google.visualization.events.addListener(table, 'select', function() {
51
+ var row = table.getSelection()[0].row;
52
+ alert('You selected ' + data.getValue(row, 0));
53
+ });
54
+ }
55
+ </script>
56
+ </head>
57
+
58
+ <body>
59
+ <!--Div that will hold the pie chart-->
60
+ <div id="chart_div" styles="margin:auto"></div>
61
+ <br />
62
+ <div id="table_div"></div>
63
+ </body>
64
+ </html>
65
+ EOB
66
+ ]
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,3 @@
1
+ module Gitstats
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gitstats.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "gitstats/version"
2
+ require "gitstats/shitometer"
3
+
4
+ module Gitstats
5
+ class Engine < Rails::Engine
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitstats
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Andrey Koleshko
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-10-09 00:00:00 +03:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Show git statistics using blame. More metrics are coming.
22
+ email:
23
+ - ka8725@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - README
34
+ - Rakefile
35
+ - config/routes.rb
36
+ - gitstats.gemspec
37
+ - lib/gitstats.rb
38
+ - lib/gitstats/shitometer.rb
39
+ - lib/gitstats/version.rb
40
+ has_rdoc: true
41
+ homepage: http://ka8725.github.com/gitstats
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project: gitstats
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Show git statistics using blame
70
+ test_files: []
71
+