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.



10
11
12
# File 'lib/git_stats/git_data/author.rb', line 10

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/git_stats/git_data/author.rb', line 10

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



10
11
12
# File 'lib/git_stats/git_data/author.rb', line 10

def repo
  @repo
end

Instance Method Details

#==(other) ⇒ Object



66
67
68
# File 'lib/git_stats/git_data/author.rb', line 66

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

#activityObject



58
59
60
# File 'lib/git_stats/git_data/author.rb', line 58

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

#changed_linesObject



20
21
22
# File 'lib/git_stats/git_data/author.rb', line 20

def changed_lines
  insertions + deletions
end

#commitsObject



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

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

#commits_sumObject



16
17
18
# File 'lib/git_stats/git_data/author.rb', line 16

def commits_sum
  commits.size
end

#commits_sum_by_dateObject



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

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

#deletionsObject



28
29
30
# File 'lib/git_stats/git_data/author.rb', line 28

def deletions
  short_stats.sum(&:deletions)
end

#dirnameObject



62
63
64
# File 'lib/git_stats/git_data/author.rb', line 62

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

#insertionsObject



24
25
26
# File 'lib/git_stats/git_data/author.rb', line 24

def insertions
  short_stats.sum(&:insertions)
end

#short_statsObject



54
55
56
# File 'lib/git_stats/git_data/author.rb', line 54

def short_stats
  commits.map(&:short_stat)
end