codespicuous 0.0.1

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 (52) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/LICENSE +29 -0
  4. data/README.md +2 -0
  5. data/Rakefile +6 -0
  6. data/bin/codespicuous +4 -0
  7. data/bin/filezilla/codespicuous.yaml +23 -0
  8. data/bin/filezilla/committers.csv +4 -0
  9. data/bin/filezilla/svnlog/filezilla.log +3939 -0
  10. data/bin/filezilla/svnlog/python.log +3 -0
  11. data/bin/filezilla/svnlog/xiph.log +265 -0
  12. data/codespicuous.gemspec +22 -0
  13. data/lib/codespicuous.rb +38 -0
  14. data/lib/codespicuous/codespicuous.rb +55 -0
  15. data/lib/codespicuous/codespicuous_config.rb +35 -0
  16. data/lib/codespicuous/codespicuousconfigurator.rb +136 -0
  17. data/lib/codespicuous/commandrunner.rb +13 -0
  18. data/lib/codespicuous/commithistory.rb +71 -0
  19. data/lib/codespicuous/commithistory_builder.rb +49 -0
  20. data/lib/codespicuous/commits.rb +147 -0
  21. data/lib/codespicuous/commitstatistics.rb +245 -0
  22. data/lib/codespicuous/committer.rb +105 -0
  23. data/lib/codespicuous/danielparser.rb +31 -0
  24. data/lib/codespicuous/dateutil.rb +18 -0
  25. data/lib/codespicuous/metrics_generator.rb +22 -0
  26. data/lib/codespicuous/metrics_generator_csv.rb +67 -0
  27. data/lib/codespicuous/metrics_generator_daniel.rb +13 -0
  28. data/lib/codespicuous/participantsparser_from_csv.rb +37 -0
  29. data/lib/codespicuous/repositories.rb +80 -0
  30. data/lib/codespicuous/repository_lister.rb +8 -0
  31. data/lib/codespicuous/svn_client.rb +14 -0
  32. data/lib/codespicuous/svn_data_collector.rb +50 -0
  33. data/lib/codespicuous/svn_log_parser.rb +100 -0
  34. data/lib/codespicuous/teams.rb +99 -0
  35. data/lib/codespicuous/version.rb +4 -0
  36. data/spec/codespicuous_spec.rb +81 -0
  37. data/spec/codespicuousconfigurator_spec.rb +202 -0
  38. data/spec/commithistories_data.rb +46 -0
  39. data/spec/commithistory_spec.rb +57 -0
  40. data/spec/commits_spec.rb +93 -0
  41. data/spec/committers_spec.rb +66 -0
  42. data/spec/danielparser_spec.rb +12 -0
  43. data/spec/integration_filezilla_spec.rb +41 -0
  44. data/spec/metrics_generator_csv_spec.rb +91 -0
  45. data/spec/metrics_generator_daniel_spec.rb +10 -0
  46. data/spec/metrics_generator_spec.rb +35 -0
  47. data/spec/repositories_spec.rb +29 -0
  48. data/spec/svn_client_spec.rb +16 -0
  49. data/spec/svn_data_collector_spec.rb +93 -0
  50. data/spec/svn_log_parser_spec.rb +141 -0
  51. data/spec/teams_spec.rb +16 -0
  52. metadata +142 -0
@@ -0,0 +1,46 @@
1
+
2
+ COMMIT_HISTORY_WINE_CHEESE_DANIEL_FORMAT = "
3
+ repository: osaka
4
+ *** basvodde
5
+ team: Wine
6
+ commits in week:
7
+ 2016-04-18: 2 commits
8
+ 2016-05-02: 2 commits
9
+
10
+ *** daniel
11
+ team: Cheese
12
+ commits in week:
13
+ 2016-03-28: 1 commits
14
+
15
+ *** basvodde
16
+ team: Wine
17
+ commits in week:
18
+ 2016-03-14: 4 commits
19
+ 2016-04-04: 1 commits
20
+
21
+ repository: cpputest
22
+
23
+ *** janne
24
+ team: Wine
25
+ commits in week:
26
+ 2016-02-29: 1 commits
27
+ 2016-04-04: 3 commits
28
+ 2016-05-16: 3 commits"
29
+
30
+ COMMIT_HISTORY_WINE_CHEESE = CommitHistoryBuilder.new.
31
+ in_repository("osaka").
32
+ commits_of("basvodde").of_team("Wine").
33
+ at("2016-04-18").times(2).
34
+ at("2016-05-02").times(2).
35
+ commits_of("daniel").of_team("Cheese").
36
+ at("2016-03-28").
37
+ commits_of("basvodde").of_team("Wine").
38
+ at("2016-03-14").times(4).
39
+ at("2016-04-04").
40
+ in_repository("cpputest").
41
+ commits_of("janne").of_team("Wine").
42
+ at("2016-02-29").
43
+ at("2016-04-04").times(3).
44
+ at("2016-05-16").times(3).
45
+ build
46
+
@@ -0,0 +1,57 @@
1
+
2
+ require 'codespicuous'
3
+ require 'commithistories_data.rb'
4
+
5
+ describe "Team commits per week table" do
6
+
7
+ before :each do
8
+ @commit_history = COMMIT_HISTORY_WINE_CHEESE
9
+ end
10
+
11
+ it "can compare two commit histories" do
12
+ expect(@commit_history).to eq(@commit_history)
13
+ end
14
+
15
+ it "calculates the amount of committers" do
16
+ expect(@commit_history.amount_of_comitters).to eq(3)
17
+ end
18
+
19
+ it "knows the team the person is in" do
20
+ expect(@commit_history.committer("basvodde").team.name).to eq "Wine"
21
+ end
22
+
23
+ it "can extract the commit amounts per user per week" do
24
+ expect(@commit_history.committer("basvodde").amount_of_weeks_committed_to_repository("osaka")).to eq 4
25
+ end
26
+
27
+ it "can extract the commits per user" do
28
+ expect(@commit_history.committer("basvodde").amount_of_commits_to_repository_in_week("osaka", DateTime.new(2016,03,14))).to eq 4
29
+ expect(@commit_history.committer("basvodde").amount_of_commits_to_repository_in_week("osaka", DateTime.new(2016,04,18))).to eq 2
30
+ end
31
+
32
+ it "should be able to extract all the repositories" do
33
+ expect(@commit_history.repository_names).to include "osaka"
34
+ end
35
+
36
+ it "should be able to extract all the teams" do
37
+ expect(@commit_history.teams.team_names).to eq ["Wine", "Cheese"]
38
+ end
39
+
40
+ it "should be able to find the earliest commit date" do
41
+ expect(@commit_history.earliest_commit_date).to eq DateTime.new(2016,02,29)
42
+ end
43
+
44
+ it "should be able to find the latest commit date" do
45
+ expect(@commit_history.latest_commit_date).to eq DateTime.new(2016,05,16)
46
+ end
47
+
48
+ it "Should be able to get the amount of commits per team per week without commits" do
49
+ expect(@commit_history.amount_of_commits_for_team_in_week("Cheese", DateTime.new(2016,01,01))).to eq 0
50
+ end
51
+
52
+ it "Should be able to get the amount of commits per team per week" do
53
+ expect(@commit_history.amount_of_commits_for_team_in_week("Cheese", DateTime.new(2016,03,28))).to eq 1
54
+ end
55
+
56
+ end
57
+
@@ -0,0 +1,93 @@
1
+
2
+ require 'codespicuous.rb'
3
+
4
+ describe "commits" do
5
+
6
+ it "be able to plus to Commits" do
7
+ commit1 = Commit.new
8
+ commits1 = Commits.new
9
+ commits1.add(commit1)
10
+
11
+ commit2 = Commit.new
12
+ commits2 = Commits.new
13
+ commits2.add(commit2)
14
+
15
+ result = Commits.new
16
+ result.add(commit1)
17
+ result.add(commit2)
18
+
19
+ expect(commits1 + commits2).to eq result
20
+ end
21
+
22
+ it "can compare Commits and they are equal" do
23
+ commit1 = Commit.new
24
+ commits1 = Commits.new
25
+ commits2 = Commits.new
26
+ commits1.add(commit1)
27
+ commits2.add(commit1)
28
+
29
+ expect(commits1).to eq(commits2)
30
+ end
31
+
32
+ it "can compare Commits and they are equal with different objects" do
33
+ commit1 = Commit.new
34
+ commit2 = Commit.new
35
+
36
+ commit1.repository = Repository.new("repo", "url")
37
+ commit2.repository = Repository.new("repo", "url")
38
+ commit1.revision = 1
39
+ commit2.revision = 2
40
+
41
+ commits1 = Commits.new
42
+ commits2 = Commits.new
43
+
44
+ commits1.add(commit1)
45
+ commits2.add(commit1)
46
+
47
+ expect(commits1).to eq(commits2)
48
+ end
49
+
50
+
51
+ it "can compare Commits and they aren't equal" do
52
+ commit1 = Commit.new
53
+ commits1 = Commits.new
54
+ commits2 = Commits.new
55
+ commits1.add(commit1)
56
+
57
+ expect(commits1).not_to eq(commits2)
58
+ end
59
+
60
+ it "can inspect commits without printing the entire data structure recursively" do
61
+ commit = Commit.new
62
+ commit.repository = Repository.new("Repo", "url")
63
+ commit.revision = 10
64
+ expect(commit).to receive(:my_object_id).and_return(1)
65
+
66
+ expect(commit.inspect).to eq("Commit(o:1) Repo:10")
67
+ end
68
+
69
+ it "two commits are the same when they are in the same repository and have the same revision" do
70
+ commit1 = Commit.new
71
+ commit2 = Commit.new
72
+ commit1.repository = Repository.new("Repos", "url")
73
+ commit2.repository = Repository.new("Repos", "url")
74
+ commit1.revision = 20
75
+ commit2.revision = 20
76
+
77
+ expect(commit1).to eq(commit2)
78
+ end
79
+
80
+ it "can compare commits, but raises an exception when some of the others are not the same" do
81
+ commit1 = Commit.new
82
+ commit2 = Commit.new
83
+ commit1.repository = Repository.new("Repos", "url")
84
+ commit2.repository = Repository.new("Repos", "url")
85
+ commit1.revision = 20
86
+ commit2.revision = 20
87
+
88
+ commit1.author = "me"
89
+
90
+ expect{commit1 == commit2}.to raise_error(CommitSameButDifferentError)
91
+ end
92
+
93
+ end
@@ -0,0 +1,66 @@
1
+
2
+
3
+ describe "The committers and the teams that we're examining" do
4
+
5
+ subject { committers.new }
6
+
7
+ before (:each) do
8
+ @committers = Committers.new
9
+ @teams = Teams.new
10
+
11
+ wine = Team.new("Wine")
12
+ cheese = Team.new("Cheese")
13
+
14
+ bas = Committer.create_committer("basvodde", "Bas", "Vodde", "basv@wow.com", wine)
15
+ janne = Committer.create_committer("janne", "Janne", "Yeah", "janne@yeah.com", cheese)
16
+ daniel = Committer.create_committer("daniel", "Daniel", "Hum", "daniel@hum.com", wine)
17
+
18
+ @committers.add(bas)
19
+ @committers.add(daniel)
20
+ @committers.add(janne)
21
+
22
+ wine.add_member(bas)
23
+ wine.add_member(daniel)
24
+ cheese.add_member(janne)
25
+
26
+ @teams.add(wine)
27
+ @teams.add(cheese)
28
+
29
+ end
30
+
31
+ it "can calculate amounts" do
32
+ expect(@committers.amount).to eq 3
33
+ expect(@teams.amount).to eq 2
34
+ end
35
+
36
+ it "has all the committer information" do
37
+ bas = @committers.find_by_username('basvodde')
38
+ expect(bas.first_name).to eq "Bas"
39
+ expect(bas.last_name).to eq "Vodde"
40
+ expect(bas.email).to eq "basv@wow.com"
41
+ expect(bas.team.name).to eq "Wine"
42
+ end
43
+
44
+ it "has all the team information" do
45
+ wine = @teams.find_by_name("Wine")
46
+ expect(wine.amount_of_members).to eq 2
47
+ expect(wine.member_usernames).to include('daniel')
48
+ end
49
+
50
+ it "can compare two committers" do
51
+ team = Team.new("team")
52
+ bas = Committer.create_committer("basv", "Bas", "Vodde", "basv@wow.com", team)
53
+ dobbel_bas = Committer.create_committer("basv", "Bas", "Vodde", "basv@wow.com", team)
54
+
55
+ expect(bas).to eq dobbel_bas
56
+ end
57
+
58
+ it "can compare two committers that aren't equal" do
59
+ team = Team.new("team")
60
+ bas = Committer.create_committer("basv", "Bas", "Fake", "basv@wow.com", team)
61
+ dobbel_bas = Committer.create_committer("basv", "Bas", "Vodde", "basv@wow.com", team)
62
+
63
+ expect(bas).not_to eq dobbel_bas
64
+ end
65
+ end
66
+
@@ -0,0 +1,12 @@
1
+
2
+
3
+ describe "Daniel format parser" do
4
+
5
+ it "Should be able to parse daniel format correctly" do
6
+ daniel_format = COMMIT_HISTORY_WINE_CHEESE_DANIEL_FORMAT
7
+ commit_history = COMMIT_HISTORY_WINE_CHEESE
8
+
9
+ expect(DanielFormatParser.new.parse(daniel_format)).to eq commit_history
10
+ end
11
+
12
+ end
@@ -0,0 +1,41 @@
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+
4
+ describe "Integration tests using offline logs from the filezilla project" do
5
+
6
+ before (:each) do
7
+ @codespicuous_script = "#{File.dirname(__FILE__)}/../bin/codespicuous"
8
+ @filezilla_path = "#{File.dirname(__FILE__)}/../bin/filezilla"
9
+ @tempdir = Dir.mktmpdir
10
+
11
+ ARGV.clear
12
+ end
13
+
14
+ after (:each) do
15
+ FileUtils.remove_entry_secure @tempdir
16
+ end
17
+
18
+ it "Gives the standard error when not finding repositories" do
19
+
20
+ expect($stdout).to receive(:puts).with("Stage 1: Configuring")
21
+ expect($stdout).to receive(:puts).with("** Error: No repositories configured in \"codespicuous.yaml\"")
22
+
23
+ load @codespicuous_script
24
+ end
25
+
26
+ it "Is able to list the repositories" do
27
+ ARGV.clear
28
+ ARGV[0] = "-i"
29
+ ARGV[1] = "#{@filezilla_path}"
30
+ ARGV[2] = "-r"
31
+
32
+ expect($stdout).to receive(:puts).with("Stage 1: Configuring")
33
+ expect($stdout).to receive(:puts).with("** Configuring options with \"/Users/basvodde/git/codespicuous/spec/../bin/filezilla/codespicuous.yaml\"")
34
+ expect($stdout).to receive(:puts).with("Stage 2: Collecting input data")
35
+ expect($stdout).to receive(:puts).with("Getting svn log from repository: filezilla")
36
+ expect($stdout).to receive(:puts).with("Getting svn log from repository: xiph")
37
+ expect($stdout).to receive(:puts).with("Stage 3: Listing repositories committed to")
38
+
39
+ load @codespicuous_script
40
+ end
41
+ end
@@ -0,0 +1,91 @@
1
+
2
+ require 'commithistories_data.rb'
3
+
4
+ describe "Generate CSV files from the commit history" do
5
+
6
+ before (:each) do
7
+ @metrics_generator = MetricsGeneratorCsv.new(COMMIT_HISTORY_WINE_CHEESE)
8
+ end
9
+
10
+ it "Should be able to create the wonderful table (sorted on team)" do
11
+ table = "Committer,Team,osaka,cpputest,Total
12
+ daniel,Cheese,1,0,1
13
+ basvodde,Wine,9,0,9
14
+ janne,Wine,0,7,7
15
+ "
16
+ expect(@metrics_generator.create_commit_table_with_committers_and_repository_info).to eq table
17
+ end
18
+
19
+ it "Should make a time table with commits and team" do
20
+ table = "Week,Wine,Cheese
21
+ 2016-02-29,1,0
22
+ 2016-03-07,0,0
23
+ 2016-03-14,4,0
24
+ 2016-03-21,0,0
25
+ 2016-03-28,0,1
26
+ 2016-04-04,4,0
27
+ 2016-04-11,0,0
28
+ 2016-04-18,2,0
29
+ 2016-04-25,0,0
30
+ 2016-05-02,2,0
31
+ 2016-05-09,0,0
32
+ 2016-05-16,3,0
33
+ "
34
+ expect(@metrics_generator.create_commit_table_with_weeks_and_team_commits).to eq table
35
+ end
36
+
37
+ it "Should make a time table with commits per repository" do
38
+ table = "Week,osaka,cpputest
39
+ 2016-02-29,0,1
40
+ 2016-03-07,0,0
41
+ 2016-03-14,4,0
42
+ 2016-03-21,0,0
43
+ 2016-03-28,1,0
44
+ 2016-04-04,1,3
45
+ 2016-04-11,0,0
46
+ 2016-04-18,2,0
47
+ 2016-04-25,0,0
48
+ 2016-05-02,2,0
49
+ 2016-05-09,0,0
50
+ 2016-05-16,0,3
51
+ "
52
+ expect(@metrics_generator.create_commit_table_with_week_and_repository_info).to eq table
53
+ end
54
+
55
+ it "Should make a time table with commits per user" do
56
+ table = "Week,basvodde,janne,daniel
57
+ 2016-02-29,0,1,0
58
+ 2016-03-07,0,0,0
59
+ 2016-03-14,4,0,0
60
+ 2016-03-21,0,0,0
61
+ 2016-03-28,0,0,1
62
+ 2016-04-04,1,3,0
63
+ 2016-04-11,0,0,0
64
+ 2016-04-18,2,0,0
65
+ 2016-04-25,0,0,0
66
+ 2016-05-02,2,0,0
67
+ 2016-05-09,0,0,0
68
+ 2016-05-16,0,3,0
69
+ "
70
+ expect(@metrics_generator.create_commit_table_with_weeks_and_committers).to eq table
71
+ end
72
+
73
+ it "Should make a time table with commits per user in team" do
74
+ table = "Week,basvodde,janne
75
+ 2016-02-29,0,1
76
+ 2016-03-07,0,0
77
+ 2016-03-14,4,0
78
+ 2016-03-21,0,0
79
+ 2016-03-28,0,0
80
+ 2016-04-04,1,3
81
+ 2016-04-11,0,0
82
+ 2016-04-18,2,0
83
+ 2016-04-25,0,0
84
+ 2016-05-02,2,0
85
+ 2016-05-09,0,0
86
+ 2016-05-16,0,3
87
+ "
88
+ expect(@metrics_generator.create_commit_table_with_weeks_and_committers("Wine")).to eq table
89
+ end
90
+
91
+ end
@@ -0,0 +1,10 @@
1
+
2
+ describe "Daniel format metrics generator" do
3
+
4
+ it "exists" do
5
+ commit_history = CommitHistory.new
6
+ daniel = MetricsGeneratorDaniel.new(commit_history)
7
+ daniel.generate
8
+ end
9
+
10
+ end
@@ -0,0 +1,35 @@
1
+
2
+ describe "Generate different types of code metrics" do
3
+
4
+ before (:each) do
5
+ @commit_history = CommitHistory.new
6
+ @subject = MetricsGenerator.new
7
+ end
8
+
9
+ it "can generate different metrics" do
10
+ expect(@subject).to receive(:generate_daniel)
11
+ expect(@subject).to receive(:generate_csv)
12
+
13
+ @subject.generate(@commit_history)
14
+ end
15
+
16
+ it "generate daniel format metrics" do
17
+ @subject.commit_history = @commit_history
18
+
19
+ daniel = MetricsGeneratorDaniel.new(@commit_history)
20
+ expect(MetricsGeneratorDaniel).to receive(:new).with(@commit_history).and_return(daniel)
21
+ expect(daniel).to receive(:generate)
22
+
23
+ @subject.generate_daniel
24
+ end
25
+
26
+ it "generate csv format metrics" do
27
+ @subject.commit_history = @commit_history
28
+
29
+ csv = MetricsGeneratorCsv.new(@commit_history)
30
+ expect(MetricsGeneratorCsv).to receive(:new).with(@commit_history).and_return(csv)
31
+ expect(csv).to receive(:generate)
32
+
33
+ @subject.generate_csv
34
+ end
35
+ end