caelum-git-reports 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/VERSION +1 -1
- data/bin/git-report.rb +7 -1
- data/git-reports.gemspec +2 -2
- data/lib/reporter.rb +3 -2
- data/lib/repository.rb +8 -1
- data/spec/reporter_spec.rb +1 -1
- data/spec/repository_spec.rb +10 -6
- metadata +2 -2
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/git-report.rb
CHANGED
@@ -9,6 +9,7 @@ require 'reporter'
|
|
9
9
|
require 'date'
|
10
10
|
require 'html_report'
|
11
11
|
require 'html_summary'
|
12
|
+
require 'yaml'
|
12
13
|
|
13
14
|
# Command line arguments
|
14
15
|
workdir = ARGV[0]
|
@@ -17,12 +18,17 @@ max_commits = ARGV[2].to_i
|
|
17
18
|
if (max_commits <= 0)
|
18
19
|
max_commits = 50
|
19
20
|
end
|
21
|
+
if (ARGV[3])
|
22
|
+
translations = YAML::load(File.open(ARGV[3]))
|
23
|
+
else
|
24
|
+
translations = {}
|
25
|
+
end
|
20
26
|
|
21
27
|
# Action!
|
22
28
|
if (workdir and days > 0)
|
23
29
|
puts "Git stats for repositories under #{workdir}"
|
24
30
|
|
25
|
-
reporter = Reporter.new(workdir)
|
31
|
+
reporter = Reporter.new(workdir, translations)
|
26
32
|
reporter.extract_all_stats(Date.new - days) do |name|
|
27
33
|
puts "Checking #{name}..."
|
28
34
|
end
|
data/git-reports.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{git-reports}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Caue Guerra", "Pedro Matiello"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-01}
|
10
10
|
s.default_executable = %q{git-report.rb}
|
11
11
|
s.email = %q{caue.guerra@gmail.com}
|
12
12
|
s.executables = ["git-report.rb"]
|
data/lib/reporter.rb
CHANGED
@@ -6,12 +6,13 @@ class Reporter
|
|
6
6
|
attr_reader :repositories
|
7
7
|
attr_accessor :repository_stats, :commiter_stats, :repository_summaries
|
8
8
|
|
9
|
-
def initialize(work_dir)
|
9
|
+
def initialize(work_dir, translations)
|
10
10
|
@work_dir = work_dir
|
11
11
|
@repositories = Hash.new
|
12
12
|
@repository_stats = Hash.new
|
13
13
|
@commiter_stats = Hash.new
|
14
14
|
@repository_summaries = Hash.new
|
15
|
+
@translations = translations
|
15
16
|
discover_repositories
|
16
17
|
initialize_repositories
|
17
18
|
end
|
@@ -51,7 +52,7 @@ class Reporter
|
|
51
52
|
|
52
53
|
def initialize_repositories
|
53
54
|
for repository_name in @repositories_names
|
54
|
-
repository = Repository.new(repository_name, @work_dir + "/#{repository_name}")
|
55
|
+
repository = Repository.new(repository_name, @work_dir + "/#{repository_name}", @translations)
|
55
56
|
@repositories[repository_name] = repository
|
56
57
|
end
|
57
58
|
end
|
data/lib/repository.rb
CHANGED
@@ -5,10 +5,11 @@ class Repository
|
|
5
5
|
attr_accessor :name, :dir, :url
|
6
6
|
attr_reader :commiters, :summary
|
7
7
|
|
8
|
-
def initialize(name, dir)
|
8
|
+
def initialize(name, dir, translations)
|
9
9
|
@name = name
|
10
10
|
@dir = dir
|
11
11
|
@delimiter = "#{200.chr}@@@"
|
12
|
+
@translations = translations
|
12
13
|
end
|
13
14
|
|
14
15
|
def clone
|
@@ -41,6 +42,9 @@ class Repository
|
|
41
42
|
for info in commit.split("\n")
|
42
43
|
temp.push info unless info == ""
|
43
44
|
end
|
45
|
+
if (@translations[temp[0]])
|
46
|
+
temp[0] = @translations[temp[0]]
|
47
|
+
end
|
44
48
|
@summary[temp[1]] = {:commiter => temp[0], :time => Time.at(temp[1].to_i), :message => temp[2]} if temp[1]
|
45
49
|
end
|
46
50
|
end
|
@@ -54,6 +58,9 @@ class Repository
|
|
54
58
|
@commiters = Hash.new
|
55
59
|
while !match.nil?
|
56
60
|
email = match[1].gsub("\n", "")
|
61
|
+
if (@translations[email])
|
62
|
+
email = @translations[email]
|
63
|
+
end
|
57
64
|
|
58
65
|
if @commiters[email].nil?
|
59
66
|
@commiters[email] = 0
|
data/spec/reporter_spec.rb
CHANGED
data/spec/repository_spec.rb
CHANGED
@@ -13,20 +13,24 @@ User1
|
|
13
13
|
|
14
14
|
User1
|
15
15
|
|
16
|
-
1 1 File1
|
17
16
|
2 2 File3
|
18
17
|
|
18
|
+
User 1
|
19
|
+
|
20
|
+
1 1 File1
|
21
|
+
|
19
22
|
User2
|
20
23
|
|
21
24
|
7 0 File1
|
22
25
|
0 3 File2
|
23
26
|
"
|
24
27
|
|
25
|
-
repository = Repository.new("SampleRepository","ArbitraryDirectory")
|
28
|
+
repository = Repository.new("SampleRepository","ArbitraryDirectory", {"User 1"=> "User1"})
|
26
29
|
repository.stub(:extract_log).and_return(log)
|
27
30
|
repository.calculate_stats
|
28
31
|
repository.commiters['User1'].should be(18)
|
29
32
|
repository.commiters['User2'].should be(10)
|
33
|
+
repository.commiters['User 1'].should be(nil)
|
30
34
|
end
|
31
35
|
|
32
36
|
it "should generate a summary" do
|
@@ -34,17 +38,17 @@ User2
|
|
34
38
|
log = "User 1
|
35
39
|
12345
|
36
40
|
Message number 1#{delimiter}
|
37
|
-
|
41
|
+
User2
|
38
42
|
12344
|
39
43
|
Message number 2#{delimiter}
|
40
44
|
"
|
41
|
-
repository = Repository.new("SampleRepository","ArbitraryDirectory")
|
45
|
+
repository = Repository.new("SampleRepository","ArbitraryDirectory", {"User 1"=> "User1"})
|
42
46
|
repository.stub(:extract_log_with_messages).and_return(log)
|
43
47
|
repository.generate_summary
|
44
|
-
repository.summary['12345'][:commiter].should eql("
|
48
|
+
repository.summary['12345'][:commiter].should eql("User1")
|
45
49
|
repository.summary['12345'][:time].should eql(Time.at(12345))
|
46
50
|
repository.summary['12345'][:message].should eql("Message number 1")
|
47
|
-
repository.summary['12344'][:commiter].should eql("
|
51
|
+
repository.summary['12344'][:commiter].should eql("User2")
|
48
52
|
repository.summary['12344'][:time].should eql(Time.at(12344))
|
49
53
|
repository.summary['12344'][:message].should eql("Message number 2")
|
50
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caelum-git-reports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caue Guerra
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-07-01 00:00:00 -07:00
|
14
14
|
default_executable: git-report.rb
|
15
15
|
dependencies: []
|
16
16
|
|