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

#email ⇒ Object (readonly)

Returns the value of attribute email.



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

def email
  @email
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#repo ⇒ Object (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

#activity ⇒ Object



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

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

#changed_lines ⇒ Object



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

def changed_lines
  insertions + deletions
end

#commits ⇒ Object



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_sum ⇒ Object



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

def commits_sum
  commits.size
end

#commits_sum_by_date ⇒ Object



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

#deletions ⇒ Object



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

def deletions
  short_stats.sum(&:deletions)
end

#dirname ⇒ Object



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

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

#insertions ⇒ Object



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

def insertions
  short_stats.sum(&:insertions)
end

#short_stats ⇒ Object



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

def short_stats
  commits.map(&:short_stat)
end