Class: GitStats::GitData::Author

Inherits:
Object
  • Object
show all
Includes:
HashInitializable, Inspector
Defined in:
lib/git_stats/git_data/author.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#inspect, #pretty_print, #to_s

Methods included from HashInitializable

#initialize

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



12
13
14
# File 'lib/git_stats/git_data/author.rb', line 12

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/git_stats/git_data/author.rb', line 12

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



12
13
14
# File 'lib/git_stats/git_data/author.rb', line 12

def repo
  @repo
end

Instance Method Details

#==(other) ⇒ Object



68
69
70
# File 'lib/git_stats/git_data/author.rb', line 68

def ==(other)
  [repo, name, email] == [other.repo, other.name, other.email]
end

#activityObject



60
61
62
# File 'lib/git_stats/git_data/author.rb', line 60

def activity
  @activity ||= Activity.new(commits)
end

#changed_linesObject



22
23
24
# File 'lib/git_stats/git_data/author.rb', line 22

def changed_lines
  insertions + deletions
end

#commitsObject



14
15
16
# File 'lib/git_stats/git_data/author.rb', line 14

def commits
  @commits ||= repo.commits.select { |commit| commit.author == self }
end

#commits_sumObject



18
19
20
# File 'lib/git_stats/git_data/author.rb', line 18

def commits_sum
  commits.size
end

#commits_sum_by_dateObject



34
35
36
37
38
39
40
# File 'lib/git_stats/git_data/author.rb', line 34

def commits_sum_by_date
  sum = 0
  commits.map do |commit|
    sum += 1
    [commit.date, sum]
  end
end

#deletionsObject



30
31
32
# File 'lib/git_stats/git_data/author.rb', line 30

def deletions
  short_stats.sum(&:deletions)
end

#dirnameObject



64
65
66
# File 'lib/git_stats/git_data/author.rb', line 64

def dirname
  name.underscore.split.join '_'
end

#insertionsObject



26
27
28
# File 'lib/git_stats/git_data/author.rb', line 26

def insertions
  short_stats.sum(&:insertions)
end

#short_statsObject



56
57
58
# File 'lib/git_stats/git_data/author.rb', line 56

def short_stats
  commits.map(&:short_stat)
end