Class: CommitStatisticsForCommitter
- Inherits:
-
Object
- Object
- CommitStatisticsForCommitter
- Defined in:
- lib/codespicuous/commitstatistics.rb
Instance Attribute Summary collapse
-
#commits_in_repositories ⇒ Object
Returns the value of attribute commits_in_repositories.
-
#team ⇒ Object
Returns the value of attribute team.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #amount_of_commits ⇒ Object
- #amount_of_commits_in_week(week_start) ⇒ Object
- #amount_of_commits_to_repository_in_week(name, week_start) ⇒ Object
- #amount_of_comnmits_to_repository(name) ⇒ Object
- #amount_of_weeks_committed_to_repository(name) ⇒ Object
- #commit(repository, date, amount) ⇒ Object
- #first_week_committed ⇒ Object
-
#initialize(username) ⇒ CommitStatisticsForCommitter
constructor
A new instance of CommitStatisticsForCommitter.
- #last_week_committed ⇒ Object
- #repositories_committed_to ⇒ Object
- #repository(name) ⇒ Object
Constructor Details
#initialize(username) ⇒ CommitStatisticsForCommitter
49 50 51 52 |
# File 'lib/codespicuous/commitstatistics.rb', line 49 def initialize(username) self.username = username self.commits_in_repositories = {} end |
Instance Attribute Details
#commits_in_repositories ⇒ Object
Returns the value of attribute commits_in_repositories.
47 48 49 |
# File 'lib/codespicuous/commitstatistics.rb', line 47 def commits_in_repositories @commits_in_repositories end |
#team ⇒ Object
Returns the value of attribute team.
47 48 49 |
# File 'lib/codespicuous/commitstatistics.rb', line 47 def team @team end |
#username ⇒ Object
Returns the value of attribute username.
47 48 49 |
# File 'lib/codespicuous/commitstatistics.rb', line 47 def username @username end |
Instance Method Details
#amount_of_commits ⇒ Object
66 67 68 69 70 |
# File 'lib/codespicuous/commitstatistics.rb', line 66 def amount_of_commits @commits_in_repositories.values.inject(0) { |sum, repository| sum + repository.amount_of_commits } end |
#amount_of_commits_in_week(week_start) ⇒ Object
80 81 82 83 84 |
# File 'lib/codespicuous/commitstatistics.rb', line 80 def amount_of_commits_in_week week_start @commits_in_repositories.each_value.inject(0) { |sum, commits| sum + commits.amount_of_commits_in_week(week_start) } end |
#amount_of_commits_to_repository_in_week(name, week_start) ⇒ Object
86 87 88 |
# File 'lib/codespicuous/commitstatistics.rb', line 86 def amount_of_commits_to_repository_in_week(name, week_start) repository(name).amount_of_commits_in_week(week_start) end |
#amount_of_comnmits_to_repository(name) ⇒ Object
76 77 78 |
# File 'lib/codespicuous/commitstatistics.rb', line 76 def amount_of_comnmits_to_repository name repository(name).amount_of_commits end |
#amount_of_weeks_committed_to_repository(name) ⇒ Object
72 73 74 |
# File 'lib/codespicuous/commitstatistics.rb', line 72 def amount_of_weeks_committed_to_repository name repository(name).amount_of_weeks_committed end |
#commit(repository, date, amount) ⇒ Object
54 55 56 |
# File 'lib/codespicuous/commitstatistics.rb', line 54 def commit(repository, date, amount) repository(repository.name).commit(date, amount) end |
#first_week_committed ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/codespicuous/commitstatistics.rb', line 90 def first_week_committed commit_week = DateTime.now @commits_in_repositories.each_value { |commits| commit_week = commits.first_week_committed if commits.first_week_committed < commit_week } commit_week end |
#last_week_committed ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/codespicuous/commitstatistics.rb', line 98 def last_week_committed commit_week = DateTime.new(1977) @commits_in_repositories.each_value { |commits| commit_week = commits.last_week_committed if commits.last_week_committed > commit_week } commit_week end |
#repositories_committed_to ⇒ Object
62 63 64 |
# File 'lib/codespicuous/commitstatistics.rb', line 62 def repositories_committed_to @commits_in_repositories.keys end |
#repository(name) ⇒ Object
58 59 60 |
# File 'lib/codespicuous/commitstatistics.rb', line 58 def repository name @commits_in_repositories[name] ||= CommitStatisticsForCommitterInRepository.new end |