metior 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.travis.yml +2 -0
  2. data/.yardopts +1 -0
  3. data/Changelog.md +23 -0
  4. data/Gemfile +1 -17
  5. data/Gemfile.lock +28 -21
  6. data/README.md +66 -20
  7. data/lib/metior.rb +30 -14
  8. data/lib/metior/actor.rb +28 -22
  9. data/lib/metior/auto_include_vcs.rb +43 -0
  10. data/lib/metior/collections/actor_collection.rb +97 -0
  11. data/lib/metior/collections/collection.rb +84 -0
  12. data/lib/metior/collections/commit_collection.rb +309 -0
  13. data/lib/metior/commit.rb +128 -48
  14. data/lib/metior/errors.rb +2 -2
  15. data/lib/metior/git/commit.rb +32 -31
  16. data/lib/metior/git/repository.rb +71 -6
  17. data/lib/metior/github/commit.rb +5 -16
  18. data/lib/metior/github/repository.rb +68 -40
  19. data/lib/metior/report.rb +139 -0
  20. data/lib/metior/report/view.rb +120 -0
  21. data/lib/metior/report/view_helper.rb +47 -0
  22. data/lib/metior/repository.rb +225 -56
  23. data/lib/metior/vcs.rb +12 -3
  24. data/lib/metior/version.rb +1 -1
  25. data/metior.gemspec +28 -26
  26. data/reports/default.rb +17 -0
  27. data/reports/default/images/favicon.png +0 -0
  28. data/reports/default/stylesheets/default.css +128 -0
  29. data/reports/default/templates/actor/minimal.mustache +1 -0
  30. data/reports/default/templates/commit/minimal.mustache +1 -0
  31. data/reports/default/templates/index.mustache +27 -0
  32. data/reports/default/templates/most_significant_authors.mustache +11 -0
  33. data/reports/default/templates/most_significant_commits.mustache +13 -0
  34. data/reports/default/templates/repository_information.mustache +17 -0
  35. data/reports/default/templates/top_committers.mustache +11 -0
  36. data/reports/default/views/index.rb +33 -0
  37. data/reports/default/views/most_significant_authors.rb +19 -0
  38. data/reports/default/views/most_significant_commits.rb +19 -0
  39. data/reports/default/views/repository_information.rb +47 -0
  40. data/reports/default/views/top_committers.rb +21 -0
  41. data/test/fixtures.rb +54 -36
  42. data/test/helper.rb +10 -3
  43. data/test/{test_class_loading.rb → test_1st_class_loading.rb} +1 -1
  44. data/test/test_actor_colletion.rb +78 -0
  45. data/test/test_collection.rb +61 -0
  46. data/test/test_commit_collection.rb +139 -0
  47. data/test/test_git.rb +58 -5
  48. data/test/test_github.rb +52 -9
  49. data/test/test_metior.rb +22 -1
  50. data/test/test_report.rb +49 -0
  51. data/test/test_repository.rb +46 -9
  52. data/test/test_vcs.rb +36 -13
  53. metadata +105 -43
@@ -6,6 +6,6 @@
6
6
  module Metior
7
7
 
8
8
  # The current version of the Metior gem
9
- VERSION = '0.1.4'
9
+ VERSION = '0.2.0' unless defined? Metior::VERSION
10
10
 
11
11
  end
@@ -1,26 +1,28 @@
1
- require 'bundler'
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/lib/metior/version')
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "metior"
7
- s.version = Metior::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = [ 'Sebastian Staudt' ]
10
- s.email = [ 'koraktor@gmail.com' ]
11
- s.homepage = 'http://koraktor.de/metior'
12
- s.summary = 'A source code history analyzer API'
13
- s.description = 'Metior is a source code history analyzer that provides various statistics about a source code repository and its change over time.'
14
-
15
- Bundler.definition.dependencies.each do |dep|
16
- if dep.groups.include?(:development) || dep.groups.include?(:test)
17
- s.add_development_dependency(dep.name, dep.requirement.to_s)
18
- else
19
- s.add_dependency(dep.name, dep.requirement.to_s)
20
- end
21
- end
22
-
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- test/*`.split("\n")
25
- s.require_paths = [ 'lib' ]
26
- end
1
+ require 'bundler'
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/metior/version')
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "metior"
7
+ s.version = Metior::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = [ 'Sebastian Staudt' ]
10
+ s.email = [ 'koraktor@gmail.com' ]
11
+ s.homepage = 'http://koraktor.de/metior'
12
+ s.summary = 'A source code history analyzer API'
13
+ s.description = 'Metior is a source code history analyzer that provides various statistics about a source code repository and its change over time.'
14
+
15
+ s.add_dependency 'grit', '~> 2.4.1'
16
+ s.add_dependency 'hashery', '~> 1.4.0' if RUBY_VERSION.match(/^1\.8/)
17
+ s.add_dependency 'mustache', '~> 0.99.4'
18
+ s.add_dependency 'octokit', '~> 0.6.4'
19
+
20
+ s.add_development_dependency 'mocha', '~> 0.9.12'
21
+ s.add_development_dependency 'rake', '~> 0.9.2'
22
+ s.add_development_dependency 'shoulda', '~> 2.11.3'
23
+ s.add_development_dependency 'yard', '~> 0.7.2'
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.test_files = `git ls-files -- test/*`.split("\n")
27
+ s.require_paths = [ 'lib' ]
28
+ end
@@ -0,0 +1,17 @@
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ class Metior::Report
7
+
8
+ # @author Sebastian Staudt
9
+ class Default < self
10
+
11
+ @@name = :default
12
+
13
+ @@views = [ :index ]
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,128 @@
1
+ html {
2
+ background: #382211;
3
+ width: 100%;
4
+ }
5
+
6
+ body {
7
+ color: #ffb;
8
+ font-family: Helvetica, sans-serif;
9
+ margin: 2em 0 1em 5em;
10
+ width: 980px;
11
+ }
12
+
13
+ div#content {
14
+ border: 2px solid #ffb;
15
+ border-radius: 5px;
16
+ box-shadow: #000 4px 4px 4px;
17
+
18
+ -moz-border-radius: 5px;
19
+ -moz-box-shadow: #000 4px 4px 4px;
20
+ -webkit-border-radius: 5px;
21
+ -webkit-box-shadow: #000 4px 4px 4px;
22
+ }
23
+
24
+
25
+ div#content div {
26
+ padding: 0.5em 0.5em 1em 0.5em;
27
+ }
28
+
29
+ div#content div:not(:last-child) {
30
+ border-bottom: 2px solid #ffb;
31
+ }
32
+
33
+ div#footer {
34
+ padding-top: 0.5em;
35
+ text-align: center;
36
+ }
37
+
38
+ div#footer, h4 {
39
+ color: #aa5;
40
+ font-size: 10pt;
41
+ }
42
+
43
+ div#repository_information strong {
44
+ margin-left: 2em;
45
+ }
46
+
47
+ div#most_significant_commits th {
48
+ width: 87%;
49
+ }
50
+
51
+ em {
52
+ color: #f95;
53
+ font-style: normal;
54
+ }
55
+
56
+ em, h1, h2, h3 {
57
+ font-family: Bevan, serif;
58
+ }
59
+
60
+ h1 {
61
+ font-size: 25pt;
62
+ line-height: 25pt;
63
+ margin-bottom: 0;
64
+ }
65
+
66
+ h2, h3 {
67
+ color: #f95;
68
+ text-shadow: #000 1px 1px 2px;
69
+
70
+ -moz-text-shadow: #000 1px 1px 2px;
71
+ -webkit-text-shadow: #000 1px 1px 2px;
72
+ }
73
+
74
+ h4 {
75
+ margin-top: 0;
76
+ text-align: right;
77
+ }
78
+
79
+ span.add, span.del {
80
+ font-weight: bold;
81
+ }
82
+
83
+ table {
84
+ border-collapse: collapse;
85
+ margin: 0 auto;
86
+ width: 98%;
87
+ }
88
+
89
+ td:last-child {
90
+ text-align: right;
91
+ }
92
+
93
+ td.add {
94
+ color: #090;
95
+ }
96
+
97
+ td.del {
98
+ color: #a00;
99
+ }
100
+
101
+ td.no_padding {
102
+ padding: 0 0.2em;
103
+ }
104
+
105
+ td, th {
106
+ padding: 0.2em;
107
+ }
108
+
109
+ th {
110
+ text-align: left;
111
+ }
112
+
113
+ tr:not(:last-child) {
114
+ border-bottom: 1px solid #652;
115
+ }
116
+
117
+ tr.even {
118
+ background: #521;
119
+ }
120
+
121
+ tr.odd {
122
+ background: #563412;
123
+ }
124
+
125
+ ul {
126
+ list-style: square;
127
+ margin-bottom: 0;
128
+ }
@@ -0,0 +1 @@
1
+ <span title="{{id}}">{{name}}</span>
@@ -0,0 +1 @@
1
+ <span title="{{id}}">{{subject}}</span>
@@ -0,0 +1,27 @@
1
+ <html>
2
+ <head>
3
+ <title>{{title}}</title>
4
+
5
+ <link href="./images/favicon.png" rel="icon" type="image/png" />
6
+ <link href="./stylesheets/default.css" rel="stylesheet" type="text/css" charset="utf-8" />
7
+ <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Bevan:regular" type="text/css" />
8
+
9
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
10
+ <meta name="date" content="{{meta_now}}">
11
+ <meta name="description" content="Metior report for {{repo_name}}" />
12
+ <meta name="generator" content="Metior {{version}}" />
13
+ </head>
14
+ <body>
15
+ <h1>Stats for <em>{{repo_name}}</em></h1>
16
+ <h4>generated by Metior {{version}}</h4>
17
+
18
+ <div id="content">
19
+ {{{repository_information}}}
20
+ {{{most_significant_authors}}}
21
+ {{{top_committers}}}
22
+ {{{most_significant_commits}}}
23
+ </div>
24
+
25
+ <div id="footer">Generated at {{now}}</div>
26
+ </body>
27
+ </html>
@@ -0,0 +1,11 @@
1
+ <div id="most_significant_authors">
2
+ <h3>Top authors by line changes</h3>
3
+ <table>
4
+ {{#authors}}
5
+ <tr class="{{even_odd}}">
6
+ <th>{{> actor/minimal}}</th>
7
+ <td>{{modifications}} line changes</td>
8
+ </tr>
9
+ {{/authors}}
10
+ </table>
11
+ </div>
@@ -0,0 +1,13 @@
1
+ <div id="most_significant_commits">
2
+ <h3>Top commits by line changes</h3>
3
+ <table>
4
+ {{#commits}}
5
+ <tr class="{{even_odd}}">
6
+ <th>{{> commit/minimal}}</th>
7
+ <td class="add no_padding">+{{additions}}</td>
8
+ <td class="no_padding">/</td>
9
+ <td class="del no_padding">-{{deletions}}</td>
10
+ </tr>
11
+ {{/commits}}
12
+ </table>
13
+ </div>
@@ -0,0 +1,17 @@
1
+ <div id="repository_information">
2
+ <h2>Repository information</h2>
3
+ {{#name?}}
4
+ <strong>Project name:</strong> {{name}}<br />
5
+ {{/name?}}
6
+ {{#description?}}
7
+ <strong>Project description:</strong> {{description}}<br />
8
+ {{/description?}}
9
+ <strong>Version control system:</strong> {{vcs_name}}<br />
10
+ <strong>Repository path:</strong> {{repository_path}}<br />
11
+ <strong>Analyzed commit range:</strong> {{range}}<br />
12
+ <strong>Number of commits:</strong> {{commit_count}}<br />
13
+ <strong>Initial commit date:</strong> {{initial_commit_date}}<br />
14
+ <strong>Last commit date:</strong> {{last_commit_date}}<br />
15
+ <strong>Most active day:</strong> {{most_active_day}}<br />
16
+ <strong>Average commits:</strong> {{commits_per_active_day}} per active day
17
+ </div>
@@ -0,0 +1,11 @@
1
+ <div id="top_committers">
2
+ <h3>Top authors by commits</h3>
3
+ <table>
4
+ {{#committers}}
5
+ <tr class="{{even_odd}}">
6
+ <th>{{> actor/minimal}}</th>
7
+ <td>{{commit_count}} commits</td>
8
+ </tr>
9
+ {{/committers}}
10
+ </table>
11
+ </div>
@@ -0,0 +1,33 @@
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ class Metior::Report::Default
7
+
8
+ # @author Sebastian Staudt
9
+ class Index < View
10
+
11
+ def meta_now
12
+ now.strftime('%FT%H:%M:%S%z').insert(-3, ':')
13
+ end
14
+
15
+ def now
16
+ Time.now
17
+ end
18
+
19
+ def repo_name
20
+ repository.name.empty? ? repository.path : repository.name
21
+ end
22
+
23
+ def title
24
+ "Stats for #{repo_name}"
25
+ end
26
+
27
+ def version
28
+ Metior::VERSION
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,19 @@
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ class Metior::Report::Default
7
+
8
+ # @author Sebastian Staudt
9
+ class MostSignificantAuthors < View
10
+
11
+ requires :line_stats
12
+
13
+ def authors
14
+ repository.authors(@report.range).most_significant(5).values
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ class Metior::Report::Default
7
+
8
+ # @author Sebastian Staudt
9
+ class MostSignificantCommits < View
10
+
11
+ requires :line_stats
12
+
13
+ def commits
14
+ repository.commits(@report.range).most_significant(5).values
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,47 @@
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ class Metior::Report::Default
7
+
8
+ # @author Sebastian Staudt
9
+ class RepositoryInformation < View
10
+
11
+ def initialize(report)
12
+ super
13
+
14
+ @activity = repository.commits(report.range).activity
15
+ end
16
+
17
+ def commit_count
18
+ repository.commits(@report.range).size
19
+ end
20
+
21
+ def commits_per_active_day
22
+ (@activity[:commits_per_active_day] * 100).round / 100.0
23
+ end
24
+
25
+ def initial_commit_date
26
+ @activity[:first_commit_date]
27
+ end
28
+
29
+ def last_commit_date
30
+ @activity[:last_commit_date]
31
+ end
32
+
33
+ def most_active_day
34
+ @activity[:most_active_day].strftime '%m/%d/%Y'
35
+ end
36
+
37
+ def range
38
+ @report.range
39
+ end
40
+
41
+ def repository_path
42
+ repository.path
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,21 @@
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ class Metior::Report::Default
7
+
8
+ # @author Sebastian Staudt
9
+ class TopCommitters < View
10
+
11
+ def committers
12
+ repository.authors(@report.range).top(5).values
13
+ end
14
+
15
+ def commit_count
16
+ self[:authored_commits].size
17
+ end
18
+
19
+ end
20
+
21
+ end