metior 0.1.4 → 0.2.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.
- data/.travis.yml +2 -0
- data/.yardopts +1 -0
- data/Changelog.md +23 -0
- data/Gemfile +1 -17
- data/Gemfile.lock +28 -21
- data/README.md +66 -20
- data/lib/metior.rb +30 -14
- data/lib/metior/actor.rb +28 -22
- data/lib/metior/auto_include_vcs.rb +43 -0
- data/lib/metior/collections/actor_collection.rb +97 -0
- data/lib/metior/collections/collection.rb +84 -0
- data/lib/metior/collections/commit_collection.rb +309 -0
- data/lib/metior/commit.rb +128 -48
- data/lib/metior/errors.rb +2 -2
- data/lib/metior/git/commit.rb +32 -31
- data/lib/metior/git/repository.rb +71 -6
- data/lib/metior/github/commit.rb +5 -16
- data/lib/metior/github/repository.rb +68 -40
- data/lib/metior/report.rb +139 -0
- data/lib/metior/report/view.rb +120 -0
- data/lib/metior/report/view_helper.rb +47 -0
- data/lib/metior/repository.rb +225 -56
- data/lib/metior/vcs.rb +12 -3
- data/lib/metior/version.rb +1 -1
- data/metior.gemspec +28 -26
- data/reports/default.rb +17 -0
- data/reports/default/images/favicon.png +0 -0
- data/reports/default/stylesheets/default.css +128 -0
- data/reports/default/templates/actor/minimal.mustache +1 -0
- data/reports/default/templates/commit/minimal.mustache +1 -0
- data/reports/default/templates/index.mustache +27 -0
- data/reports/default/templates/most_significant_authors.mustache +11 -0
- data/reports/default/templates/most_significant_commits.mustache +13 -0
- data/reports/default/templates/repository_information.mustache +17 -0
- data/reports/default/templates/top_committers.mustache +11 -0
- data/reports/default/views/index.rb +33 -0
- data/reports/default/views/most_significant_authors.rb +19 -0
- data/reports/default/views/most_significant_commits.rb +19 -0
- data/reports/default/views/repository_information.rb +47 -0
- data/reports/default/views/top_committers.rb +21 -0
- data/test/fixtures.rb +54 -36
- data/test/helper.rb +10 -3
- data/test/{test_class_loading.rb → test_1st_class_loading.rb} +1 -1
- data/test/test_actor_colletion.rb +78 -0
- data/test/test_collection.rb +61 -0
- data/test/test_commit_collection.rb +139 -0
- data/test/test_git.rb +58 -5
- data/test/test_github.rb +52 -9
- data/test/test_metior.rb +22 -1
- data/test/test_report.rb +49 -0
- data/test/test_repository.rb +46 -9
- data/test/test_vcs.rb +36 -13
- metadata +105 -43
data/.travis.yml
CHANGED
data/.yardopts
CHANGED
data/Changelog.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 0.2.0
|
4
|
+
|
5
|
+
* Initial support for HTML reports
|
6
|
+
* Improved caching
|
7
|
+
* Collections can be used to easily query information
|
8
|
+
* Lazy load file and line stats for Git
|
9
|
+
* Lots of bugfixes
|
10
|
+
|
11
|
+
See the
|
12
|
+
[Git history](https://github.com/koraktor/metior/compare/0.1.4...0.2.0) for
|
13
|
+
version 0.2.0
|
14
|
+
|
15
|
+
## Version 0.1.4
|
16
|
+
|
17
|
+
**June 16<sup>th</th>, 2011**
|
18
|
+
|
19
|
+
* Removed Bundler as a dependency loader
|
20
|
+
* Fixed GitHub::Commit not requiring 'time'
|
21
|
+
|
22
|
+
See the
|
23
|
+
[Git history](https://github.com/koraktor/metior/compare/0.1.3...0.1.4) for
|
24
|
+
version 0.1.4
|
25
|
+
|
3
26
|
## Version 0.1.3
|
4
27
|
|
5
28
|
**June 13<sup>th</sup>, 2011**
|
data/Gemfile
CHANGED
@@ -1,19 +1,3 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
|
4
|
-
gem 'grit', '~> 2.4.1'
|
5
|
-
end
|
6
|
-
|
7
|
-
group :github do
|
8
|
-
gem 'octokit', '~> 0.6.3'
|
9
|
-
end
|
10
|
-
|
11
|
-
group :development do
|
12
|
-
gem 'rake', '~> 0.9.1'
|
13
|
-
gem 'yard', '~> 0.7.1'
|
14
|
-
end
|
15
|
-
|
16
|
-
group :test do
|
17
|
-
gem 'mocha', '~> 0.9.12'
|
18
|
-
gem 'shoulda', '~> 2.11.3'
|
19
|
-
end
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,43 +1,50 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
metior (0.2.0)
|
5
|
+
grit (~> 2.4.1)
|
6
|
+
hashery (~> 1.4.0)
|
7
|
+
mustache (~> 0.99.4)
|
8
|
+
octokit (~> 0.6.4)
|
9
|
+
|
1
10
|
GEM
|
2
11
|
remote: http://rubygems.org/
|
3
12
|
specs:
|
4
13
|
addressable (2.2.6)
|
5
14
|
diff-lcs (1.1.2)
|
6
|
-
faraday (0.
|
7
|
-
addressable (~> 2.2.
|
15
|
+
faraday (0.7.4)
|
16
|
+
addressable (~> 2.2.6)
|
8
17
|
multipart-post (~> 1.1.0)
|
9
18
|
rack (< 2, >= 1.1.0)
|
10
|
-
faraday_middleware (0.
|
11
|
-
faraday (~> 0.
|
19
|
+
faraday_middleware (0.7.0)
|
20
|
+
faraday (~> 0.7.3)
|
12
21
|
grit (2.4.1)
|
13
22
|
diff-lcs (~> 1.1)
|
14
23
|
mime-types (~> 1.15)
|
24
|
+
hashery (1.4.0)
|
15
25
|
hashie (1.0.0)
|
16
26
|
mime-types (1.16)
|
17
27
|
mocha (0.9.12)
|
18
|
-
multi_json (1.0.
|
19
|
-
multipart-post (1.1.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
multi_json (~> 1.0.0)
|
26
|
-
rash (~> 0.3.0)
|
27
|
-
rack (1.2.2)
|
28
|
-
rake (0.9.1)
|
29
|
-
rash (0.3.0)
|
28
|
+
multi_json (1.0.3)
|
29
|
+
multipart-post (1.1.3)
|
30
|
+
mustache (0.99.4)
|
31
|
+
octokit (0.6.4)
|
32
|
+
addressable (~> 2.2.6)
|
33
|
+
faraday (~> 0.7.3)
|
34
|
+
faraday_middleware (~> 0.7.0.rc1)
|
30
35
|
hashie (~> 1.0.0)
|
36
|
+
multi_json (~> 1.0.2)
|
37
|
+
rack (1.3.2)
|
38
|
+
rake (0.9.2)
|
31
39
|
shoulda (2.11.3)
|
32
|
-
yard (0.7.
|
40
|
+
yard (0.7.2)
|
33
41
|
|
34
42
|
PLATFORMS
|
35
43
|
ruby
|
36
44
|
|
37
45
|
DEPENDENCIES
|
38
|
-
|
46
|
+
metior!
|
39
47
|
mocha (~> 0.9.12)
|
40
|
-
|
41
|
-
rake (~> 0.9.1)
|
48
|
+
rake (~> 0.9.2)
|
42
49
|
shoulda (~> 2.11.3)
|
43
|
-
yard (~> 0.7.
|
50
|
+
yard (~> 0.7.2)
|
data/README.md
CHANGED
@@ -4,61 +4,103 @@ Metior
|
|
4
4
|
Metior is a source code history analyzer API that provides various statistics
|
5
5
|
about a source code repository and its change over time.
|
6
6
|
|
7
|
-
Currently Metior provides
|
7
|
+
Currently Metior provides support for Git and GitHub repositories.
|
8
8
|
|
9
9
|
If you're interested in Metior, feel free to join the discussion on Convore in
|
10
10
|
[Metior's group](https://convore.com/metior).
|
11
11
|
|
12
|
-
##
|
12
|
+
## Reports
|
13
|
+
|
14
|
+
The most straightforward use of Metior is probably generating an out-of-the-box
|
15
|
+
report that analyzes a repository and gives a user-friendly output of the
|
16
|
+
gathered data.
|
17
|
+
|
18
|
+
Metior.report :git, '~/open-source/metior', './reports/metior'
|
19
|
+
Metior.report :github, 'koraktor/metior', './reports/metior'
|
20
|
+
|
21
|
+
## API Examples
|
22
|
+
|
23
|
+
If you want more sophisticated access to the available data, you can use the
|
24
|
+
low-level API that provides stats for repositories and their individual commits
|
25
|
+
and actors.
|
13
26
|
|
14
27
|
### One-liner for some basic statistics
|
15
28
|
|
16
29
|
Metior.simple_stats :git, '~/open-source/metior'
|
17
|
-
Metior.simple_stats :github, 'koraktor
|
30
|
+
Metior.simple_stats :github, 'koraktor/metior'
|
18
31
|
|
19
32
|
### Create a repository object for different VCSs
|
20
33
|
|
21
|
-
repo = Metior
|
22
|
-
repo = Metior
|
34
|
+
repo = Metior.repository :git, '~/open-source/metior'
|
35
|
+
repo = Metior.repository :github, 'koraktor/metior'
|
23
36
|
|
24
37
|
### More fine-grained access to repository statistics
|
25
38
|
|
26
|
-
repo.commits 'development' # Get all commits in development
|
39
|
+
repo.commits 'development' # Get all commits in branch development
|
27
40
|
repo.file_stats # Basic statistics about the files
|
28
41
|
# contained in a repository
|
29
42
|
repo.line_history # Quick access to lines added and
|
30
43
|
# removed in each commit
|
31
44
|
repo.significant_authors # Get up to 3 of the most important
|
32
45
|
# authors
|
33
|
-
repo.significant_commits
|
46
|
+
repo.significant_commits # Get up to 3 of the commits changing
|
34
47
|
# the most lines
|
35
|
-
repo.
|
48
|
+
repo.authors('master').top 5 # Get the top 5 authors in master
|
49
|
+
|
50
|
+
### Query a collection of commits
|
51
|
+
|
52
|
+
repo.commits.activity
|
53
|
+
repo.commits.after '05/29/2010'
|
54
|
+
repo.commits.additions
|
55
|
+
repo.commits.authors
|
56
|
+
repo.commits.before '05/29/2010'
|
57
|
+
repo.commits.by 'koraktor'
|
58
|
+
repo.commits.changing 'lib/metior.rb'
|
59
|
+
repo.commits.deletions
|
60
|
+
repo.commits.modifications
|
61
|
+
repo.commits.most_significant 10
|
62
|
+
repo.commits.with_impact 100
|
63
|
+
|
64
|
+
See documentation of {Metior::CommitCollection}
|
36
65
|
|
37
|
-
###
|
66
|
+
### Query a collection of actors
|
38
67
|
|
39
|
-
|
40
|
-
|
68
|
+
repo.authors.authored_commits
|
69
|
+
repo.authors.comitted_commits
|
70
|
+
repo.authors.most_significant 10
|
71
|
+
repo.authors.top 10
|
72
|
+
|
73
|
+
See documentation of {Metior::ActorCollection}
|
41
74
|
|
42
75
|
## Advanced usage
|
43
76
|
|
77
|
+
### Chain collection querys
|
78
|
+
|
79
|
+
Querys on a collection of commits or actors can be easily chained to achieve
|
80
|
+
complex filters on the available data.
|
81
|
+
|
82
|
+
repo.commits.by('koraktor').after('05/29/2010').with_impact 100
|
83
|
+
repo.authors.top(10).commits.changing 'lib/metior.rb'
|
84
|
+
|
44
85
|
### Specifying commit ranges
|
45
86
|
|
87
|
+
Usually, when Metior queries a repository for its commits and authors it will
|
88
|
+
use the default branch of the VCS, e.g. `master` for Git.
|
89
|
+
|
46
90
|
Sometimes it's more useful to not analyze the whole history of a repository's
|
47
91
|
branch. For example when analyzing the changes from one branch to another, or
|
48
92
|
from the last released version to the latest code. In that case you will have
|
49
93
|
to specify a commit range. Specifying a commit range works just like in Git:
|
50
94
|
|
51
95
|
'master..development'
|
52
|
-
'master'..'development'
|
53
|
-
'master..HEAD'
|
54
|
-
'master'..'HEAD'
|
55
96
|
'deadbeef..HEAD'
|
97
|
+
'master'..'development'
|
56
98
|
|
57
99
|
Given that your currently checked out branch is `development` and `master`
|
58
100
|
points to commit `deadbeef`, the above statements are equal. Please also note
|
59
|
-
the different syntaxes: The first
|
60
|
-
|
61
|
-
|
101
|
+
the different syntaxes: The first two example are standard strings which
|
102
|
+
will be parsed by Metior. The other one is a Ruby `Range` object which can be
|
103
|
+
used by Metior right away.
|
62
104
|
|
63
105
|
## Requirements
|
64
106
|
|
@@ -73,8 +115,8 @@ documentation of the current development version is also available [there][5].
|
|
73
115
|
|
74
116
|
## Future plans
|
75
117
|
|
76
|
-
*
|
77
|
-
* Generation of reports in
|
118
|
+
* Provide more reports
|
119
|
+
* Generation of reports in formats other than HTML
|
78
120
|
* Support for creating graphs
|
79
121
|
* Console and web application to accompany this API
|
80
122
|
* More supported VCSs, like Subversion or Mercurial
|
@@ -89,7 +131,7 @@ There are several ways of contributing to Metior's development:
|
|
89
131
|
* Report problems and request features using the [issue tracker][2].
|
90
132
|
* Write patches yourself to fix bugs and implement new functionality.
|
91
133
|
* Create a Metior fork on [GitHub][1] and start hacking. Extra points for using
|
92
|
-
|
134
|
+
feature branches and GitHub's pull requests.
|
93
135
|
|
94
136
|
## About the name
|
95
137
|
|
@@ -105,6 +147,8 @@ LICENSE file.
|
|
105
147
|
## Credits
|
106
148
|
|
107
149
|
* Sebastian Staudt – koraktor(at)gmail.com
|
150
|
+
* Alex Manelis – amanelis(at)gmail.com
|
151
|
+
* Michael Klishin – michaelklishin(at)me.com
|
108
152
|
|
109
153
|
## See Also
|
110
154
|
|
@@ -112,6 +156,7 @@ LICENSE file.
|
|
112
156
|
* [Metior's homepage][2]
|
113
157
|
* [GitHub project page][3]
|
114
158
|
* [GitHub issue tracker][4]
|
159
|
+
* [Continuous Integration at Travis CI][6]
|
115
160
|
|
116
161
|
Follow Metior on Twitter [@metiorstats](http://twitter.com/metiorstats).
|
117
162
|
|
@@ -120,3 +165,4 @@ Follow Metior on Twitter [@metiorstats](http://twitter.com/metiorstats).
|
|
120
165
|
[3]: http://github.com/koraktor/metior
|
121
166
|
[4]: http://github.com/koraktor/metior/issues
|
122
167
|
[5]: http://rubydoc.info/github/koraktor/metior/master/frames
|
168
|
+
[6]: http://travis-ci.org/koraktor/metior
|
data/lib/metior.rb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
require 'core_ext/object'
|
7
7
|
require 'metior/git'
|
8
8
|
require 'metior/github'
|
9
|
+
require 'metior/report'
|
9
10
|
require 'metior/version'
|
10
11
|
|
11
12
|
# Metior is a source code history analyzer that provides various statistics
|
@@ -21,29 +22,44 @@ module Metior
|
|
21
22
|
# repository, e.g. a file system path
|
22
23
|
# @return [Repository] A VCS specific `Repository` instance
|
23
24
|
def self.repository(type, *options)
|
24
|
-
vcs(type)::Repository.new
|
25
|
+
vcs(type)::Repository.new(*options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Generates a report for the given repository
|
29
|
+
#
|
30
|
+
# @param [Symbol] type The type of the repository, e.g. `:git`
|
31
|
+
# @param [Array<Object>] options The options to use for creating the new
|
32
|
+
# repository, e.g. a file system path
|
33
|
+
# @param [String] target_dir The target directory to save the report to
|
34
|
+
# @param [String, Range] range The commit range to analyze for the report
|
35
|
+
# @param [String] report The name of the report template to use
|
36
|
+
def self.report(type, repo_options, target_dir, range = nil, report = 'default')
|
37
|
+
repo = repository type, *repo_options
|
38
|
+
range ||= repo.vcs::DEFAULT_BRANCH
|
39
|
+
Report.create(report, repo, range).generate target_dir
|
25
40
|
end
|
26
41
|
|
27
42
|
# Calculates simplistic stats for the given repository and branch
|
28
43
|
#
|
29
44
|
# @param [Symbol] type The type of the repository, e.g. `:git`
|
30
|
-
# @param [Array<Object>]
|
45
|
+
# @param [Object, Array<Object>] repo_options The options to supply to the
|
46
|
+
# repository
|
31
47
|
# @param [String, Range] range The range of commits for which the commits
|
32
48
|
# should be loaded. This may be given as a string
|
33
|
-
# (`'master..development'`), a range (`'master'..'development'`)
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# @return [Hash] The calculated stats for the given
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
repo = repository type, *options
|
49
|
+
# (`'master..development'`), a range (`'master'..'development'`) or as
|
50
|
+
# a single ref (`'master'`). A single ref name means all commits
|
51
|
+
# reachable from that ref.
|
52
|
+
# @return [Hash<Symbol, Object>] The calculated stats for the given
|
53
|
+
# repository and branch
|
54
|
+
def self.simple_stats(type, repo_options, range = nil)
|
55
|
+
range = vcs(type)::DEFAULT_BRANCH if range.nil?
|
56
|
+
repo = repository type, *repo_options
|
42
57
|
|
58
|
+
commits = repo.commits(range)
|
43
59
|
{
|
44
|
-
:commit_count =>
|
45
|
-
:top_contributors => repo.top_contributors(
|
46
|
-
}.merge
|
60
|
+
:commit_count => commits.size,
|
61
|
+
:top_contributors => repo.top_contributors(range, 5),
|
62
|
+
}.merge commits.activity
|
47
63
|
end
|
48
64
|
|
49
65
|
end
|
data/lib/metior/actor.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Copyright (c) 2011, Sebastian Staudt
|
5
5
|
|
6
|
+
require 'metior/auto_include_vcs'
|
7
|
+
|
6
8
|
module Metior
|
7
9
|
|
8
10
|
# Represents an actor in a source code repository
|
@@ -15,15 +17,16 @@ module Metior
|
|
15
17
|
# @author Sebastian Staudt
|
16
18
|
class Actor
|
17
19
|
|
18
|
-
|
19
|
-
attr_reader :additions
|
20
|
+
include AutoIncludeVCS
|
20
21
|
|
21
|
-
# @return [
|
22
|
-
# the source code repository
|
23
|
-
attr_reader :
|
22
|
+
# @return [CommitCollection] The list of commits this actor has contributed
|
23
|
+
# to the source code repository
|
24
|
+
attr_reader :authored_commits
|
25
|
+
alias_method :commits, :authored_commits
|
24
26
|
|
25
|
-
# @return [
|
26
|
-
|
27
|
+
# @return [CommitCollection] The list of commits this actor has committed
|
28
|
+
# to the source code repository
|
29
|
+
attr_reader :committed_commits
|
27
30
|
|
28
31
|
# @return [String] The full name of the actor
|
29
32
|
attr_reader :name
|
@@ -45,20 +48,23 @@ module Metior
|
|
45
48
|
#
|
46
49
|
# @param [Repository] repo The repository this actor belongs to
|
47
50
|
def initialize(repo)
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
51
|
-
|
51
|
+
@authored_commits = CommitCollection.new
|
52
|
+
@committed_commits = CommitCollection.new
|
53
|
+
@repo = repo
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the lines of code that have been added by this actor
|
57
|
+
#
|
58
|
+
# @return [Fixnum] The lines of code that have been added
|
59
|
+
def additions
|
60
|
+
@authored_commits.additions
|
52
61
|
end
|
53
62
|
|
54
|
-
#
|
55
|
-
# the analyzed source code repository
|
63
|
+
# Returns the lines of code that have been deleted by this actor
|
56
64
|
#
|
57
|
-
# @
|
58
|
-
def
|
59
|
-
@
|
60
|
-
@commits << commit
|
61
|
-
@deletions += commit.deletions
|
65
|
+
# @return [Fixnum] The lines of code that have been deleted
|
66
|
+
def deletions
|
67
|
+
@authored_commits.deletions
|
62
68
|
end
|
63
69
|
|
64
70
|
# Creates a string representation for this actor without recursing into
|
@@ -66,10 +72,10 @@ module Metior
|
|
66
72
|
#
|
67
73
|
# @return [String] A minimal string representation for this actor
|
68
74
|
def inspect
|
69
|
-
'
|
75
|
+
'#<%s:0x%x: @commits=%d @id="%s" @name="%s" @repo="%s"' %
|
70
76
|
[
|
71
|
-
self.class.name, __id__ * 2, @
|
72
|
-
@repo.
|
77
|
+
self.class.name, __id__ * 2, @authored_commits.size, @id, @name,
|
78
|
+
@repo.path
|
73
79
|
]
|
74
80
|
end
|
75
81
|
|
@@ -77,7 +83,7 @@ module Metior
|
|
77
83
|
#
|
78
84
|
# @return [Fixnum] The total number of changed lines
|
79
85
|
def modifications
|
80
|
-
|
86
|
+
@authored_commits.modifications
|
81
87
|
end
|
82
88
|
|
83
89
|
end
|