Class: CommitHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/codespicuous/commithistory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommitHistory

Returns a new instance of CommitHistory.



7
8
9
10
11
12
# File 'lib/codespicuous/commithistory.rb', line 7

def initialize
  @commits = Commits.new
  @teams = Teams.new
  @committers = teams.committers
  @repositories = Repositories.new
end

Instance Attribute Details

#commitsObject (readonly)

Returns the value of attribute commits.



5
6
7
# File 'lib/codespicuous/commithistory.rb', line 5

def commits
  @commits
end

#committersObject (readonly)

Returns the value of attribute committers.



5
6
7
# File 'lib/codespicuous/commithistory.rb', line 5

def committers
  @committers
end

#repositoriesObject (readonly)

Returns the value of attribute repositories.



5
6
7
# File 'lib/codespicuous/commithistory.rb', line 5

def repositories
  @repositories
end

#teamsObject (readonly)

Returns the value of attribute teams.



5
6
7
# File 'lib/codespicuous/commithistory.rb', line 5

def teams
  @teams
end

Instance Method Details

#==(commit_history) ⇒ Object



72
73
74
# File 'lib/codespicuous/commithistory.rb', line 72

def == commit_history
  @commits == commit_history.commits
end

#add_commit(commit) ⇒ Object



20
21
22
23
24
25
# File 'lib/codespicuous/commithistory.rb', line 20

def add_commit(commit)
  @commits.add(commit)
  committer(commit.author).add_commit(commit)
  @repositories.add(commit.repository)
  commit.repository.add_commit(commit)
end

#add_commits(commits) ⇒ Object



27
28
29
30
31
# File 'lib/codespicuous/commithistory.rb', line 27

def add_commits(commits)
  commits.each { |commit|
    add_commit(commit)
  }
end

#add_team_member(team, member) ⇒ Object



33
34
35
36
# File 'lib/codespicuous/commithistory.rb', line 33

def add_team_member(team, member)
  team = @teams.team(team)
  team.add_member(committer(member))
end

#amount_of_comittersObject



54
55
56
# File 'lib/codespicuous/commithistory.rb', line 54

def amount_of_comitters
  @committers.amount
end

#amount_of_commits_for_team_in_week(team_name, week) ⇒ Object



58
59
60
61
62
# File 'lib/codespicuous/commithistory.rb', line 58

def amount_of_commits_for_team_in_week(team_name, week)
  @commits.inject(0) { |amount_of_commits, commit|
    amount_of_commits + ((commit.by_team_with_name?(team_name) && commit.in_week?(week)) ? 1 : 0)
  }
end

#committer(name) ⇒ Object



38
39
40
# File 'lib/codespicuous/commithistory.rb', line 38

def committer(name)
  @committers.committer(name)
end

#configure(teams, repositories) ⇒ Object



14
15
16
17
18
# File 'lib/codespicuous/commithistory.rb', line 14

def configure(teams, repositories)
  @teams = teams
  @committers = teams.committers
  @repositories = repositories
end

#earliest_commit_dateObject



64
65
66
# File 'lib/codespicuous/commithistory.rb', line 64

def earliest_commit_date
  @commits.earliest_commit_date
end

#latest_commit_dateObject



68
69
70
# File 'lib/codespicuous/commithistory.rb', line 68

def latest_commit_date
  @commits.latest_commit_date
end

#repository(name) ⇒ Object



42
43
44
# File 'lib/codespicuous/commithistory.rb', line 42

def repository(name)
  @repositories.repository(name)
end

#repository_namesObject



50
51
52
# File 'lib/codespicuous/commithistory.rb', line 50

def repository_names
  @repositories.repository_names
end

#team(name) ⇒ Object



46
47
48
# File 'lib/codespicuous/commithistory.rb', line 46

def team(name)
  @teams.team(name)
end